Communitygithub.com

使用Malpedia分析惡意軟體家族關係

查詢Malpedia API以查找惡意軟體家族別名和命名。

使用Malpedia分析惡意軟體家族關係 是什麼?

該技能提供了通過程式化查詢Malpedia API來分析惡意軟體家族關係的全面方法。Malpedia由Fraunhofer FKIE維護,是一個協作平台,收錄了超過2600個惡意軟體家族及其別名、YARA規則、威脅行為者關聯和參考報告。技能指南涵蓋了從API獲取家族列表、詳細資訊和YARA規則,到構建惡意軟體家族關係圖譜(例如加載器-有效載荷鏈和共享工具分析),再到編譯YARA規則以進行檢測的整個工作流程。該技能基於Python,利用`requests`、`yara-python`和`stix2`庫,並且需要Malpedia API金鑰。支援的應用情境包括安全事件調查、威脅狩獵、檢測規則構建以及SOC分析程序。輸出的結構化數據可與威脅情報平台(如MISP或OpenCTI)集成,以增強威脅追蹤和歸因能力。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-malware-family-relationships-with-malpedia

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

使用 Malpedia 分析惡意軟體家族關係

概述

Malpedia 是由 Fraunhofer FKIE 維護的協作平台,收錄了惡意軟體家族及其別名、YARA 規則、威脅行為者關聯和參考報告。該平台記錄了超過 2,600 個惡意軟體家族,是了解惡意軟體譜系、追蹤變種演化以及將惡意軟體連結到特定威脅組織的權威資源。此技能涵蓋了查詢 Malpedia API、繪製惡意軟體家族關係圖譜、提取用於偵測的 YARA 規則,以及建立關於對手所用惡意軟體生態系的情報。

使用時機

  • 在調查安全事件時,需要使用 Malpedia 分析惡意軟體家族關係
  • 在為此領域建立偵測規則或威脅狩獵查詢時
  • 當 SOC 分析師需要此分析類型的結構化程序時
  • 在驗證相關攻擊技術的安全監控覆蓋範圍時

先決條件

  • Python 3.9+,並安裝 requests、yara-python、stix2 函式庫
  • Malpedia API 金鑰(請在 https://malpedia.caad.fkie.fraunhofer.de/ 註冊)
  • 了解惡意軟體分類和命名慣例
  • 熟悉 YARA 規則語法以進行偵測
  • 可存取惡意軟體樣本進行驗證(可選)

關鍵概念

Malpedia 資料模型

Malpedia 將惡意軟體組織成「家族」(例如 win.cobalt_strike),每個家族包含:別名(供應商特定的名稱,如 "Beacon"、"CobaltStrike")、YARA 規則(社群和供應商貢獻的)、行為者關聯(使用該家族的威脅組織)、參考報告(記錄該家族的 CTI 報告)以及樣本雜湊(每個變種的代表性樣本)。

惡意軟體家族命名

Malpedia 使用 平台.家族名稱 的格式(例如 win.emotet、elf.mirai、apk.flubot)。平台包括 win(Windows)、elf(Linux)、apk(Android)、osx(macOS)和 py(Python)。這種標準化命名解決了「多名」問題,即不同供應商對同一惡意軟體賦予不同名稱。

家族關係

惡意軟體家族具有以下關係:父子(程式碼重用、分支)、加載器-有效載荷(Emotet 加載 TrickBot,再加載 Ryuk)、共享作者(同一威脅行為者開發多種工具)以及共享基礎設施(共同的 C2 框架)。

工作流程

步驟 1:查詢 Malpedia API 以取得惡意軟體家族

import requests
import json
from collections import defaultdict

class MalpediaClient:
    BASE_URL = "https://malpedia.caad.fkie.fraunhofer.de/api"

    def __init__(self, api_key):
        self.headers = {"Authorization": f"apitoken {api_key}"}

    def get_family_list(self):
        """取得所有惡意軟體家族的列表。"""
        resp = requests.get(f"{self.BASE_URL}/list/families",
                           headers=self.headers, timeout=30)
        if resp.status_code == 200:
            families = resp.json()
            print(f"[+] Malpedia: {len(families)} 個惡意軟體家族")
            return families
        return {}

    def get_family_info(self, family_name):
        """取得惡意軟體家族的詳細資訊。"""
        resp = requests.get(f"{self.BASE_URL}/get/family/{family_name}",
                           headers=self.headers, timeout=30)
        if resp.status_code == 200:
            info = resp.json()
            print(f"[+] 家族: {family_name}")
            print(f"    別名: {info.get('alt_names', [])}")
            print(f"    行為者: {[a.get('value', '') for a in info.get('attribution', [])]}")
            print(f"    URL: {len(info.get('urls', []))} 個參考")
            return info
        print(f"[-] 找不到家族: {family_name}")
        return None

    def get_family_yara(self, family_name):
        """取得惡意軟體家族的 YARA 規則。"""
        resp = requests.get(f"{self.BASE_URL}/get/yara/{family_name}",
                           headers=self.headers, timeout=30)
        if resp.status_code == 200:
            rules = resp.json()
            rule_count = sum(len(v) for v in rules.values()) if isinstance(rules, dict) else 0
            print(f"[+] {family_name} 的 YARA 規則: {rule_count} 條規則")
            return rules
        return {}

    def get_actor_families(self, actor_name):
        """取得與威脅行為者相關聯的惡意軟體家族。"""
        resp = requests.get(f"{self.BASE_URL}/get/actor/{actor_name}",
                           headers=self.headers, timeout=30)
        if resp.status_code == 200:
            data = resp.json()
            families = data.get("families", {})
            print(f"[+] {actor_name}: {len(families)} 個惡意軟體家族")
            return data
        return {}

    def search_families(self, keyword):
        """根據關鍵字搜尋家族。"""
        all_families = self.get_family_list()
        matches = {
            name: info for name, info in all_families.items()
            if keyword.lower() in name.lower()
            or keyword.lower() in str(info.get("alt_names", [])).lower()
        }
        print(f"[+] 搜尋 '{keyword}': {len(matches)} 個符合")
        return matches

client = MalpediaClient("YOUR_MALPEDIA_API_KEY")
families = client.get_family_list()
emotet_info = client.get_family_info("win.emotet")

步驟 2:繪製惡意軟體家族關係圖譜

class MalwareFamilyMapper:
    def __init__(self, malpedia_client):
        self.client = malpedia_client
        self.relationship_graph = defaultdict(list)

    def map_actor_ecosystem(self, actor_name):
        """繪製威脅行為者使用的惡意軟體生態系。"""
        actor_data = self.client.get_actor_families(actor_name)
        families = actor_data.get("families", {})

        ecosystem = {
            "actor": actor_name,
            "families": [],
            "family_count": len(families),
        }

        for family_name in families:
            info = self.client.get_family_info(family_name)
            if info:
                ecosystem["families"].append({
                    "name": family_name,
                    "aliases": info.get("alt_names", []),
                    "description": info.get("description", "")[:200],
                    "shared_actors": [
                        a.get("value", "")
                        for a in info.get("attribution", [])
                    ],
                    "reference_count": len(info.get("urls", [])),
                })

        print(f"\n=== {actor_name} 惡意軟體生態系 ===")
        for fam in ecosystem["families"]:
            shared = [a for a in fam["shared_actors"] if a != actor_name]
            print(f"  {fam['name']}")
            print(f"    別名: {fam['aliases'][:5]}")
            if shared:
                print(f"    也被用於: {shared}")

        return ecosystem

    def find_shared_tooling(self, actor_names):
        """尋找威脅行為者之間共享的惡意軟體工具。"""
        actor_families = {}
        for actor in actor_names:
            data = self.client.get_actor_families(actor)
            actor_families[actor] = set(data.get("families", {}).keys())

        # 找出重疊
        shared = {}
        for i, actor1 in enumerate(actor_names):
            for actor2 in actor_names[i+1:]:
                common = actor_families[actor1] & actor_families[actor2]
                if common:
                    shared[f"{actor1} <-> {actor2}"] = sorted(common)

        print(f"\n=== 共享工具分析 ===")
        for pair, families in shared.items():
            print(f"  {pair}: {len(families)} 個共享家族")
            for f in families[:5]:
                print(f"    - {f}")

        return shared

    def build_loader_payload_chain(self, family_name):
        """建立某個家族的加載器-有效載荷傳遞鏈。"""
        info = self.client.get_family_info(family_name)
        if not info:
            return {}

        chain = {
            "family": family_name,
            "description": info.get("description", ""),
            "known_loaders": [],
            "known_payloads": [],
        }

        # 已知的常見傳遞鏈
        known_chains = {
            "win.emotet": {"loaders": ["email/macro"], "payloads": ["win.trickbot", "win.qakbot", "win.cobalt_strike"]},
            "win.trickbot": {"loaders": ["win.emotet"], "payloads": ["win.ryuk", "win.conti", "win.cobalt_strike"]},
            "win.qakbot": {"loaders": ["email/macro", "win.emotet"], "payloads": ["win.cobalt_strike", "win.blackbasta"]},
            "win.cobalt_strike": {"loaders": ["win.emotet", "win.trickbot", "win.qakbot"], "payloads": ["ransomware"]},
        }

        if family_name in known_chains:
            chain["known_loaders"] = known_chains[family_name]["loaders"]
            chain["known_payloads"] = known_chains[family_name]["payloads"]

        return chain

mapper = MalwareFamilyMapper(client)
ecosystem = mapper.map_actor_ecosystem("Wizard Spider")
shared = mapper.find_shared_tooling(["Wizard Spider", "FIN7", "Lazarus Group"])
chain = mapper.build_loader_payload_chain("win.emotet")

步驟 3:提取並編譯 YARA 規則

def compile_yara_ruleset(client, family_names, output_file="malware_yara_rules.yar"):
    """編譯多個惡意軟體家族的 YARA 規則。"""
    all_rules = []
    for family in family_names:
        yara_data = client.get_family_yara(family)
        if isinstance(yara_data, dict):
            for source, rules in yara_data.items():
                if isinstance(rules, list):
                    for rule in rules:
                        all_rules.append(f"// Source: {source} - Family: {family}\n{rule}")
                elif isinstance(rules, str):
                    all_rules.append(f"// Source: {source} - Family: {family}\n{rules}")

    with open(output_file, "w") as f:
        f.write(f"// Malpedia YARA Rules - {len(all_rules)} rules\n")
        f.write(f"// Families: {', '.join(family_names)}\n\n")
        for rule in all_rules:
            f.write(rule + "\n\n")

    print(f"[+] 已編譯 {len(all_rules)} 條 YARA 規則至 {output_file}")
    return all_rules

compile_yara_ruleset(client, ["win.emotet", "win.trickbot", "win.cobalt_strike"])

驗證標準

  • 成功查詢 Malpedia API 以取得惡意軟體家族
  • 檢索的家族資訊包含別名、行為者和參考資料
  • 正確繪製行為者-家族關係圖譜
  • 識別出行為者之間的共享工具
  • 提取並編譯 YARA 規則以進行偵測
  • 記錄加載器-有效載荷鏈以用於威脅情報

參考資料

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

相關技能