[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7A74D8NE4DV3KCFY44GH5P6":3,"skill-same:01M7A74D8NE4DV3KCFY44GH5P6":82},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":14,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M7A74D8NE4DV3KCFY44GH5P6","extracting-iocs-from-malware-samples",null,"Extracts indicators of compromise (IOCs) from malware samples, including file hashes, network indicators (IPs, domains, URLs, PCAP indicators), host artifacts (file paths, registry keys, mutexes), and behavioral patterns, using tools like CyberChef, then defangs and exports them in standard threat-intel formats. Use for IOC extraction, threat indicator harvesting, or building detection content from a sample.","NeelakshSaxena\u002FVayu","NeelakshSaxena","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F87892838?v=4","01M7A3B9YFS6F6N9DD1787DT86","Neelaksh Saxena","01M7A3B9ZKBT09MNMPX2XN69BY",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: extracting-iocs-from-malware-samples\ndescription: Extracts indicators of compromise (IOCs) from malware samples, including\n  file hashes, network indicators (IPs, domains, URLs, PCAP indicators), host artifacts\n  (file paths, registry keys, mutexes), and behavioral patterns, using tools like\n  CyberChef, then defangs and exports them in standard threat-intel formats. Use\n  for IOC extraction, threat indicator harvesting, or building detection content\n  from a sample.\ndomain: cybersecurity\nsubdomain: malware-analysis\ntags:\n- malware\n- IOC-extraction\n- threat-intelligence\n- indicators\n- detection\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- DE.AE-02\n- RS.AN-03\n- ID.RA-01\n- DE.CM-01\nmitre_attack:\n- T1027\n- T1055\n- T1140\n- T1497\n---\n\n# Extracting IOCs from Malware Samples\n\n## When to Use\n\n- A malware analysis (static or dynamic) is complete and actionable indicators need to be extracted for defense teams\n- Building blocklists for firewalls, proxies, and DNS sinkholes from analyzed samples\n- Creating YARA rules, Snort\u002FSuricata signatures, or SIEM detection content from malware artifacts\n- Contributing to threat intelligence sharing platforms (MISP, OTX, ThreatConnect)\n- Tracking malware campaigns by correlating IOCs across multiple samples\n\n**Do not use** for IOCs from unverified sources without validation; false positives in blocklists can disrupt legitimate business operations.\n\n## Prerequisites\n\n- Python 3.8+ with `iocextract`, `pefile`, `yara-python` libraries installed\n- Completed malware analysis report (static analysis, dynamic analysis, or reverse engineering)\n- Access to PCAP files, memory dumps, or sandbox reports from the analysis\n- MISP instance or STIX\u002FTAXII server for structured IOC sharing\n- VirusTotal API key for IOC enrichment and validation\n- CyberChef for decoding obfuscated indicators\n\n## Workflow\n\n### Step 1: Extract File-Based IOCs\n\nCompute hashes and identify file metadata indicators:\n\n```bash\n# Generate all standard hashes\nmd5sum malware_sample.exe\nsha1sum malware_sample.exe\nsha256sum malware_sample.exe\n\n# Generate ssdeep fuzzy hash for similarity matching\nssdeep malware_sample.exe\n\n# Generate imphash (import hash) for PE files\npython3 -c \"\nimport pefile\npe = pefile.PE('malware_sample.exe')\nprint(f'Imphash: {pe.get_imphash()}')\n\"\n\n# Generate TLSH (Trend Micro Locality Sensitive Hash)\npython3 -c \"\nimport tlsh\nwith open('malware_sample.exe', 'rb') as f:\n    h = tlsh.hash(f.read())\nprint(f'TLSH: {h}')\n\"\n\n# Compile file metadata IOCs\npython3 \u003C\u003C 'PYEOF'\nimport pefile\nimport os\nimport hashlib\nimport datetime\n\npe = pefile.PE(\"malware_sample.exe\")\n\nprint(\"FILE IOCs:\")\nwith open(\"malware_sample.exe\", \"rb\") as f:\n    data = f.read()\n    print(f\"  MD5:        {hashlib.md5(data).hexdigest()}\")\n    print(f\"  SHA-1:      {hashlib.sha1(data).hexdigest()}\")\n    print(f\"  SHA-256:    {hashlib.sha256(data).hexdigest()}\")\n    print(f\"  File Size:  {len(data)} bytes\")\n\nts = pe.FILE_HEADER.TimeDateStamp\nprint(f\"  Compile:    {datetime.datetime.utcfromtimestamp(ts)} UTC\")\nprint(f\"  Imphash:    {pe.get_imphash()}\")\nPYEOF\n```\n\n### Step 2: Extract Network IOCs\n\nPull network indicators from strings, PCAP, and sandbox reports:\n\n```python\n# Extract network IOCs from strings\nimport re\n\nwith open(\"malware_sample.exe\", \"rb\") as f:\n    data = f.read()\n\n# Extract ASCII and Unicode strings\nascii_strings = re.findall(b'[ -~]{4,}', data)\nunicode_strings = re.findall(b'(?:[ -~]\\x00){4,}', data)\n\nall_strings = [s.decode('ascii', errors='ignore') for s in ascii_strings]\nall_strings += [s.decode('utf-16-le', errors='ignore') for s in unicode_strings]\n\n# IP addresses (excluding private ranges for C2 indicators)\nip_pattern = re.compile(r'\\b(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\b')\nips = set()\nfor s in all_strings:\n    for ip in ip_pattern.findall(s):\n        # Filter out private\u002Freserved ranges\n        octets = [int(o) for o in ip.split('.')]\n        if octets[0] not in [10, 127, 0] and not (octets[0] == 172 and 16 \u003C= octets[1] \u003C= 31) and not (octets[0] == 192 and octets[1] == 168):\n            ips.add(ip)\n\n# Domain names\ndomain_pattern = re.compile(r'\\b[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z]{2,})+\\b')\ndomains = set()\nfor s in all_strings:\n    for d in domain_pattern.findall(s):\n        if not d.endswith(('.dll', '.exe', '.sys', '.com.au')):\n            domains.add(d)\n\n# URLs\nurl_pattern = re.compile(r'https?:\u002F\u002F[^\\s\u003C>\"{}|\\\\^`\\[\\]]+')\nurls = set()\nfor s in all_strings:\n    for u in url_pattern.findall(s):\n        urls.add(u)\n\nprint(\"NETWORK IOCs:\")\nprint(f\"  IPs:     {ips}\")\nprint(f\"  Domains: {domains}\")\nprint(f\"  URLs:    {urls}\")\n```\n\n### Step 3: Extract Host-Based IOCs\n\nIdentify file paths, registry keys, mutexes, and services:\n\n```python\n# Extract host-based IOCs from sandbox report\nimport json\n\nwith open(\"cuckoo_report.json\") as f:\n    report = json.load(f)\n\nprint(\"HOST IOCs:\")\n\n# File paths created or modified\nprint(\"\\nFile Paths:\")\nfor f in report[\"behavior\"][\"summary\"].get(\"files\", []):\n    if any(p in f.lower() for p in [\"temp\", \"appdata\", \"system32\", \"programdata\"]):\n        print(f\"  [DROPPED] {f}\")\n\n# Registry keys for persistence\nprint(\"\\nRegistry Keys:\")\nfor key in report[\"behavior\"][\"summary\"].get(\"write_keys\", []):\n    if any(p in key.lower() for p in [\"run\", \"service\", \"startup\", \"shell\"]):\n        print(f\"  [PERSIST] {key}\")\n\n# Mutexes (unique to malware family)\nprint(\"\\nMutexes:\")\nfor mutex in report[\"behavior\"][\"summary\"].get(\"mutexes\", []):\n    if mutex not in [\"Local\\\\!IETld!Mutex\", \"RasPbFile\"]:  # Filter known Windows mutexes\n        print(f\"  [MUTEX] {mutex}\")\n\n# Created services\nprint(\"\\nServices:\")\nfor svc in report[\"behavior\"][\"summary\"].get(\"started_services\", []):\n    print(f\"  [SERVICE] {svc}\")\n```\n\n### Step 4: Extract Network IOCs from PCAP\n\nParse network captures for additional indicators:\n\n```bash\n# Extract DNS queries from PCAP\ntshark -r capture.pcap -T fields -e dns.qry.name -Y \"dns.flags.response == 0\" | sort -u\n\n# Extract HTTP hosts and URLs\ntshark -r capture.pcap -T fields -e http.host -e http.request.uri -Y \"http.request\" | sort -u\n\n# Extract TLS server names (SNI)\ntshark -r capture.pcap -T fields -e tls.handshake.extensions_server_name -Y \"tls.handshake.type == 1\" | sort -u\n\n# Extract JA3 hashes\ntshark -r capture.pcap -T fields -e tls.handshake.ja3 -Y \"tls.handshake.type == 1\" | sort -u\n\n# Extract unique destination IPs\ntshark -r capture.pcap -T fields -e ip.dst -Y \"ip.src == 10.0.2.15\" | sort -u\n\n# Extract User-Agent strings\ntshark -r capture.pcap -T fields -e http.user_agent -Y \"http.user_agent\" | sort -u\n```\n\n### Step 5: Defang and Validate IOCs\n\nDefang indicators for safe sharing and validate against threat intelligence:\n\n```python\n# Defang IOCs for safe sharing\ndef defang_ip(ip):\n    return ip.replace(\".\", \"[.]\")\n\ndef defang_url(url):\n    return url.replace(\"http\", \"hxxp\").replace(\".\", \"[.]\")\n\ndef defang_domain(domain):\n    return domain.replace(\".\", \"[.]\")\n\n# Validate IOCs against VirusTotal\nimport requests\n\nVT_API_KEY = \"your_api_key\"\n\ndef check_vt_ip(ip):\n    resp = requests.get(f\"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fip_addresses\u002F{ip}\",\n                       headers={\"x-apikey\": VT_API_KEY})\n    data = resp.json()\n    stats = data[\"data\"][\"attributes\"][\"last_analysis_stats\"]\n    return stats[\"malicious\"]\n\ndef check_vt_domain(domain):\n    resp = requests.get(f\"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fdomains\u002F{domain}\",\n                       headers={\"x-apikey\": VT_API_KEY})\n    data = resp.json()\n    stats = data[\"data\"][\"attributes\"][\"last_analysis_stats\"]\n    return stats[\"malicious\"]\n\n# Validate each IOC\nfor ip in ips:\n    detections = check_vt_ip(ip)\n    print(f\"  {defang_ip(ip)} - VT: {detections} detections\")\n```\n\n### Step 6: Export IOCs in Standard Formats\n\nGenerate structured IOC outputs for sharing and ingestion:\n\n```python\n# Export as STIX 2.1 bundle\nfrom stix2 import Indicator, Bundle, Malware, Relationship\nimport datetime\n\nindicators = []\n\n# File hash indicator\nindicators.append(Indicator(\n    name=\"Malware SHA-256 Hash\",\n    pattern=f\"[file:hashes.'SHA-256' = '{sha256_hash}']\",\n    pattern_type=\"stix\",\n    valid_from=datetime.datetime.now(datetime.timezone.utc),\n    labels=[\"malicious-activity\"]\n))\n\n# IP indicator\nfor ip in ips:\n    indicators.append(Indicator(\n        name=f\"C2 IP Address {ip}\",\n        pattern=f\"[ipv4-addr:value = '{ip}']\",\n        pattern_type=\"stix\",\n        valid_from=datetime.datetime.now(datetime.timezone.utc),\n        labels=[\"malicious-activity\"]\n    ))\n\n# Domain indicator\nfor domain in domains:\n    indicators.append(Indicator(\n        name=f\"C2 Domain {domain}\",\n        pattern=f\"[domain-name:value = '{domain}']\",\n        pattern_type=\"stix\",\n        valid_from=datetime.datetime.now(datetime.timezone.utc),\n        labels=[\"malicious-activity\"]\n    ))\n\nbundle = Bundle(objects=indicators)\nwith open(\"iocs_stix.json\", \"w\") as f:\n    f.write(bundle.serialize(pretty=True))\n\n# Export as CSV for SIEM ingestion\nimport csv\nwith open(\"iocs.csv\", \"w\", newline=\"\") as f:\n    writer = csv.writer(f)\n    writer.writerow([\"type\", \"value\", \"context\", \"confidence\"])\n    writer.writerow([\"sha256\", sha256_hash, \"malware_sample\", \"high\"])\n    for ip in ips:\n        writer.writerow([\"ipv4\", ip, \"c2_server\", \"high\"])\n    for domain in domains:\n        writer.writerow([\"domain\", domain, \"c2_domain\", \"high\"])\n    for url in urls:\n        writer.writerow([\"url\", url, \"c2_url\", \"high\"])\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **IOC (Indicator of Compromise)** | Forensic artifact observed in a network or system that indicates a potential intrusion: hashes, IPs, domains, file paths, registry keys |\n| **Defanging** | Modifying IOCs to prevent accidental activation (e.g., replacing dots with [.] in URLs and IPs for safe sharing in reports) |\n| **Imphash** | MD5 hash of the import table functions in a PE file; samples from the same malware family often share the same imphash |\n| **STIX\u002FTAXII** | Structured Threat Information Expression \u002F Trusted Automated Exchange; standards for encoding and transmitting threat intelligence |\n| **JA3\u002FJA3S** | TLS client\u002Fserver fingerprint based on ClientHello\u002FServerHello parameters; identifies specific malware families by their TLS implementation |\n| **Fuzzy Hashing (ssdeep)** | Context-triggered piecewise hashing that identifies similar files even with minor modifications; useful for malware variant detection |\n| **MISP** | Malware Information Sharing Platform; open-source threat intelligence platform for collecting, storing, and sharing IOCs |\n\n## Tools & Systems\n\n- **iocextract (Python)**: Automated IOC extraction library supporting IPs, URLs, domains, hashes, and YARA rules from text\n- **MISP**: Open-source threat intelligence sharing platform for structured IOC management and distribution\n- **CyberChef**: Web-based tool for decoding, decrypting, and transforming data useful for deobfuscating encoded IOCs\n- **tshark**: Command-line network protocol analyzer for extracting network IOCs from PCAP files\n- **VirusTotal**: Online service for validating and enriching IOCs with community detection results and threat intelligence\n\n## Common Scenarios\n\n### Scenario: Building a Comprehensive IOC Package from a Ransomware Sample\n\n**Context**: A ransomware incident requires rapid IOC extraction for blocking across the enterprise while the full investigation continues. Multiple data sources are available: the sample binary, PCAP from network monitoring, and a Cuckoo sandbox report.\n\n**Approach**:\n1. Compute all file hashes (MD5, SHA-1, SHA-256, imphash, ssdeep) for the ransomware binary and any dropped files\n2. Extract network IOCs from strings in the binary (hardcoded C2 addresses)\n3. Parse the PCAP for DNS queries, HTTP requests, and TLS SNI fields\n4. Extract host IOCs from the sandbox report (file paths, registry keys, mutexes, ransom note filenames)\n5. Validate all network IOCs against VirusTotal to confirm malicious status and check for known associations\n6. Defang all indicators and compile into STIX 2.1 format for sharing and CSV for SIEM ingestion\n7. Submit to MISP event for organizational and community sharing\n\n**Pitfalls**:\n- Including IP addresses of legitimate CDNs or cloud services without validating context (e.g., AWS IPs used for hosting, not inherently malicious)\n- Not defanging URLs and IPs in reports, leading to accidental clicks or DNS resolution\n- Extracting strings from packed binaries (IOCs from packed samples are unreliable; unpack first)\n- Forgetting to include dropped file hashes (the initial dropper and the final payload are separate IOCs)\n\n## Output Format\n\n```\nIOC EXTRACTION REPORT\n======================\nSample:           ransomware.exe\nAnalysis Date:    2025-09-15\nAnalyst:          [Name]\n\nFILE INDICATORS\nSHA-256:          e3b0c44298fc1c149afbf4c8996fb924...\nSHA-1:            da39a3ee5e6b4b0d3255bfef95601890afd80709\nMD5:              d41d8cd98f00b204e9800998ecf8427e\nImphash:          a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6\nssdeep:           3072:kJh3bN7fY+aUkJh3bN7fY+aU:kJh3R7aUkJh3R7aU\n\nNETWORK INDICATORS\nC2 IPs:           185.220.101[.]42, 91.215.85[.]17\nC2 Domains:       update.malicious[.]com, backup.evil[.]net\nC2 URLs:          hxxps:\u002F\u002Fupdate.malicious[.]com\u002Fgate.php\n                  hxxps:\u002F\u002Fbackup.evil[.]net\u002Fgate.php\nJA3 Hash:         a0e9f5d64349fb13191bc781f81f42e1\nUser-Agent:       Mozilla\u002F5.0 (compatible; MSIE 10.0)\n\nHOST INDICATORS\nFile Paths:       C:\\Users\\Public\\svchost.exe\n                  C:\\Users\\%USER%\\AppData\\Local\\Temp\\payload.dll\n                  C:\\Users\\%USER%\\Desktop\\README_DECRYPT.txt\nRegistry Keys:    HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\WindowsUpdate\nMutexes:          Global\\CryptLocker_2025_Q3\nServices:         FakeWindowsUpdate\n\nCONFIDENCE ASSESSMENT\nHigh Confidence:  SHA-256, C2 IPs (validated via VT), Mutexes\nMedium Confidence: Domains (could be compromised legitimate sites)\nLow Confidence:   User-Agent (common string, high false positive risk)\n\nEXPORT FILES\nstix_bundle.json  - STIX 2.1 format for TIP ingestion\niocs.csv          - Flat CSV for SIEM blocklist import\nyara_rule.yar     - YARA detection rule\n```\n","# Extracting IOCs from Malware Samples\n\n## When to Use\n\n- A malware analysis (static or dynamic) is complete and actionable indicators need to be extracted for defense teams\n- Building blocklists for firewalls, proxies, and DNS sinkholes from analyzed samples\n- Creating YARA rules, Snort\u002FSuricata signatures, or SIEM detection content from malware artifacts\n- Contributing to threat intelligence sharing platforms (MISP, OTX, ThreatConnect)\n- Tracking malware campaigns by correlating IOCs across multiple samples\n\n**Do not use** for IOCs from unverified sources without validation; false positives in blocklists can disrupt legitimate business operations.\n\n## Prerequisites\n\n- Python 3.8+ with `iocextract`, `pefile`, `yara-python` libraries installed\n- Completed malware analysis report (static analysis, dynamic analysis, or reverse engineering)\n- Access to PCAP files, memory dumps, or sandbox reports from the analysis\n- MISP instance or STIX\u002FTAXII server for structured IOC sharing\n- VirusTotal API key for IOC enrichment and validation\n- CyberChef for decoding obfuscated indicators\n\n## Workflow\n\n### Step 1: Extract File-Based IOCs\n\nCompute hashes and identify file metadata indicators:\n\n```bash\n# Generate all standard hashes\nmd5sum malware_sample.exe\nsha1sum malware_sample.exe\nsha256sum malware_sample.exe\n\n# Generate ssdeep fuzzy hash for similarity matching\nssdeep malware_sample.exe\n\n# Generate imphash (import hash) for PE files\npython3 -c \"\nimport pefile\npe = pefile.PE('malware_sample.exe')\nprint(f'Imphash: {pe.get_imphash()}')\n\"\n\n# Generate TLSH (Trend Micro Locality Sensitive Hash)\npython3 -c \"\nimport tlsh\nwith open('malware_sample.exe', 'rb') as f:\n    h = tlsh.hash(f.read())\nprint(f'TLSH: {h}')\n\"\n\n# Compile file metadata IOCs\npython3 \u003C\u003C 'PYEOF'\nimport pefile\nimport os\nimport hashlib\nimport datetime\n\npe = pefile.PE(\"malware_sample.exe\")\n\nprint(\"FILE IOCs:\")\nwith open(\"malware_sample.exe\", \"rb\") as f:\n    data = f.read()\n    print(f\"  MD5:        {hashlib.md5(data).hexdigest()}\")\n    print(f\"  SHA-1:      {hashlib.sha1(data).hexdigest()}\")\n    print(f\"  SHA-256:    {hashlib.sha256(data).hexdigest()}\")\n    print(f\"  File Size:  {len(data)} bytes\")\n\nts = pe.FILE_HEADER.TimeDateStamp\nprint(f\"  Compile:    {datetime.datetime.utcfromtimestamp(ts)} UTC\")\nprint(f\"  Imphash:    {pe.get_imphash()}\")\nPYEOF\n```\n\n### Step 2: Extract Network IOCs\n\nPull network indicators from strings, PCAP, and sandbox reports:\n\n```python\n# Extract network IOCs from strings\nimport re\n\nwith open(\"malware_sample.exe\", \"rb\") as f:\n    data = f.read()\n\n# Extract ASCII and Unicode strings\nascii_strings = re.findall(b'[ -~]{4,}', data)\nunicode_strings = re.findall(b'(?:[ -~]\\x00){4,}', data)\n\nall_strings = [s.decode('ascii', errors='ignore') for s in ascii_strings]\nall_strings += [s.decode('utf-16-le', errors='ignore') for s in unicode_strings]\n\n# IP addresses (excluding private ranges for C2 indicators)\nip_pattern = re.compile(r'\\b(?:(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]?\\d)\\b')\nips = set()\nfor s in all_strings:\n    for ip in ip_pattern.findall(s):\n        # Filter out private\u002Freserved ranges\n        octets = [int(o) for o in ip.split('.')]\n        if octets[0] not in [10, 127, 0] and not (octets[0] == 172 and 16 \u003C= octets[1] \u003C= 31) and not (octets[0] == 192 and octets[1] == 168):\n            ips.add(ip)\n\n# Domain names\ndomain_pattern = re.compile(r'\\b[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z]{2,})+\\b')\ndomains = set()\nfor s in all_strings:\n    for d in domain_pattern.findall(s):\n        if not d.endswith(('.dll', '.exe', '.sys', '.com.au')):\n            domains.add(d)\n\n# URLs\nurl_pattern = re.compile(r'https?:\u002F\u002F[^\\s\u003C>\"{}|\\\\^`\\[\\]]+')\nurls = set()\nfor s in all_strings:\n    for u in url_pattern.findall(s):\n        urls.add(u)\n\nprint(\"NETWORK IOCs:\")\nprint(f\"  IPs:     {ips}\")\nprint(f\"  Domains: {domains}\")\nprint(f\"  URLs:    {urls}\")\n```\n\n### Step 3: Extract Host-Based IOCs\n\nIdentify file paths, registry keys, mutexes, and services:\n\n```python\n# Extract host-based IOCs from sandbox report\nimport json\n\nwith open(\"cuckoo_report.json\") as f:\n    report = json.load(f)\n\nprint(\"HOST IOCs:\")\n\n# File paths created or modified\nprint(\"\\nFile Paths:\")\nfor f in report[\"behavior\"][\"summary\"].get(\"files\", []):\n    if any(p in f.lower() for p in [\"temp\", \"appdata\", \"system32\", \"programdata\"]):\n        print(f\"  [DROPPED] {f}\")\n\n# Registry keys for persistence\nprint(\"\\nRegistry Keys:\")\nfor key in report[\"behavior\"][\"summary\"].get(\"write_keys\", []):\n    if any(p in key.lower() for p in [\"run\", \"service\", \"startup\", \"shell\"]):\n        print(f\"  [PERSIST] {key}\")\n\n# Mutexes (unique to malware family)\nprint(\"\\nMutexes:\")\nfor mutex in report[\"behavior\"][\"summary\"].get(\"mutexes\", []):\n    if mutex not in [\"Local\\\\!IETld!Mutex\", \"RasPbFile\"]:  # Filter known Windows mutexes\n        print(f\"  [MUTEX] {mutex}\")\n\n# Created services\nprint(\"\\nServices:\")\nfor svc in report[\"behavior\"][\"summary\"].get(\"started_services\", []):\n    print(f\"  [SERVICE] {svc}\")\n```\n\n### Step 4: Extract Network IOCs from PCAP\n\nParse network captures for additional indicators:\n\n```bash\n# Extract DNS queries from PCAP\ntshark -r capture.pcap -T fields -e dns.qry.name -Y \"dns.flags.response == 0\" | sort -u\n\n# Extract HTTP hosts and URLs\ntshark -r capture.pcap -T fields -e http.host -e http.request.uri -Y \"http.request\" | sort -u\n\n# Extract TLS server names (SNI)\ntshark -r capture.pcap -T fields -e tls.handshake.extensions_server_name -Y \"tls.handshake.type == 1\" | sort -u\n\n# Extract JA3 hashes\ntshark -r capture.pcap -T fields -e tls.handshake.ja3 -Y \"tls.handshake.type == 1\" | sort -u\n\n# Extract unique destination IPs\ntshark -r capture.pcap -T fields -e ip.dst -Y \"ip.src == 10.0.2.15\" | sort -u\n\n# Extract User-Agent strings\ntshark -r capture.pcap -T fields -e http.user_agent -Y \"http.user_agent\" | sort -u\n```\n\n### Step 5: Defang and Validate IOCs\n\nDefang indicators for safe sharing and validate against threat intelligence:\n\n```python\n# Defang IOCs for safe sharing\ndef defang_ip(ip):\n    return ip.replace(\".\", \"[.]\")\n\ndef defang_url(url):\n    return url.replace(\"http\", \"hxxp\").replace(\".\", \"[.]\")\n\ndef defang_domain(domain):\n    return domain.replace(\".\", \"[.]\")\n\n# Validate IOCs against VirusTotal\nimport requests\n\nVT_API_KEY = \"your_api_key\"\n\ndef check_vt_ip(ip):\n    resp = requests.get(f\"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fip_addresses\u002F{ip}\",\n                       headers={\"x-apikey\": VT_API_KEY})\n    data = resp.json()\n    stats = data[\"data\"][\"attributes\"][\"last_analysis_stats\"]\n    return stats[\"malicious\"]\n\ndef check_vt_domain(domain):\n    resp = requests.get(f\"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fdomains\u002F{domain}\",\n                       headers={\"x-apikey\": VT_API_KEY})\n    data = resp.json()\n    stats = data[\"data\"][\"attributes\"][\"last_analysis_stats\"]\n    return stats[\"malicious\"]\n\n# Validate each IOC\nfor ip in ips:\n    detections = check_vt_ip(ip)\n    print(f\"  {defang_ip(ip)} - VT: {detections} detections\")\n```\n\n### Step 6: Export IOCs in Standard Formats\n\nGenerate structured IOC outputs for sharing and ingestion:\n\n```python\n# Export as STIX 2.1 bundle\nfrom stix2 import Indicator, Bundle, Malware, Relationship\nimport datetime\n\nindicators = []\n\n# File hash indicator\nindicators.append(Indicator(\n    name=\"Malware SHA-256 Hash\",\n    pattern=f\"[file:hashes.'SHA-256' = '{sha256_hash}']\",\n    pattern_type=\"stix\",\n    valid_from=datetime.datetime.now(datetime.timezone.utc),\n    labels=[\"malicious-activity\"]\n))\n\n# IP indicator\nfor ip in ips:\n    indicators.append(Indicator(\n        name=f\"C2 IP Address {ip}\",\n        pattern=f\"[ipv4-addr:value = '{ip}']\",\n        pattern_type=\"stix\",\n        valid_from=datetime.datetime.now(datetime.timezone.utc),\n        labels=[\"malicious-activity\"]\n    ))\n\n# Domain indicator\nfor domain in domains:\n    indicators.append(Indicator(\n        name=f\"C2 Domain {domain}\",\n        pattern=f\"[domain-name:value = '{domain}']\",\n        pattern_type=\"stix\",\n        valid_from=datetime.datetime.now(datetime.timezone.utc),\n        labels=[\"malicious-activity\"]\n    ))\n\nbundle = Bundle(objects=indicators)\nwith open(\"iocs_stix.json\", \"w\") as f:\n    f.write(bundle.serialize(pretty=True))\n\n# Export as CSV for SIEM ingestion\nimport csv\nwith open(\"iocs.csv\", \"w\", newline=\"\") as f:\n    writer = csv.writer(f)\n    writer.writerow([\"type\", \"value\", \"context\", \"confidence\"])\n    writer.writerow([\"sha256\", sha256_hash, \"malware_sample\", \"high\"])\n    for ip in ips:\n        writer.writerow([\"ipv4\", ip, \"c2_server\", \"high\"])\n    for domain in domains:\n        writer.writerow([\"domain\", domain, \"c2_domain\", \"high\"])\n    for url in urls:\n        writer.writerow([\"url\", url, \"c2_url\", \"high\"])\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **IOC (Indicator of Compromise)** | Forensic artifact observed in a network or system that indicates a potential intrusion: hashes, IPs, domains, file paths, registry keys |\n| **Defanging** | Modifying IOCs to prevent accidental activation (e.g., replacing dots with [.] in URLs and IPs for safe sharing in reports) |\n| **Imphash** | MD5 hash of the import table functions in a PE file; samples from the same malware family often share the same imphash |\n| **STIX\u002FTAXII** | Structured Threat Information Expression \u002F Trusted Automated Exchange; standards for encoding and transmitting threat intelligence |\n| **JA3\u002FJA3S** | TLS client\u002Fserver fingerprint based on ClientHello\u002FServerHello parameters; identifies specific malware families by their TLS implementation |\n| **Fuzzy Hashing (ssdeep)** | Context-triggered piecewise hashing that identifies similar files even with minor modifications; useful for malware variant detection |\n| **MISP** | Malware Information Sharing Platform; open-source threat intelligence platform for collecting, storing, and sharing IOCs |\n\n## Tools & Systems\n\n- **iocextract (Python)**: Automated IOC extraction library supporting IPs, URLs, domains, hashes, and YARA rules from text\n- **MISP**: Open-source threat intelligence sharing platform for structured IOC management and distribution\n- **CyberChef**: Web-based tool for decoding, decrypting, and transforming data useful for deobfuscating encoded IOCs\n- **tshark**: Command-line network protocol analyzer for extracting network IOCs from PCAP files\n- **VirusTotal**: Online service for validating and enriching IOCs with community detection results and threat intelligence\n\n## Common Scenarios\n\n### Scenario: Building a Comprehensive IOC Package from a Ransomware Sample\n\n**Context**: A ransomware incident requires rapid IOC extraction for blocking across the enterprise while the full investigation continues. Multiple data sources are available: the sample binary, PCAP from network monitoring, and a Cuckoo sandbox report.\n\n**Approach**:\n1. Compute all file hashes (MD5, SHA-1, SHA-256, imphash, ssdeep) for the ransomware binary and any dropped files\n2. Extract network IOCs from strings in the binary (hardcoded C2 addresses)\n3. Parse the PCAP for DNS queries, HTTP requests, and TLS SNI fields\n4. Extract host IOCs from the sandbox report (file paths, registry keys, mutexes, ransom note filenames)\n5. Validate all network IOCs against VirusTotal to confirm malicious status and check for known associations\n6. Defang all indicators and compile into STIX 2.1 format for sharing and CSV for SIEM ingestion\n7. Submit to MISP event for organizational and community sharing\n\n**Pitfalls**:\n- Including IP addresses of legitimate CDNs or cloud services without validating context (e.g., AWS IPs used for hosting, not inherently malicious)\n- Not defanging URLs and IPs in reports, leading to accidental clicks or DNS resolution\n- Extracting strings from packed binaries (IOCs from packed samples are unreliable; unpack first)\n- Forgetting to include dropped file hashes (the initial dropper and the final payload are separate IOCs)\n\n## Output Format\n\n```\nIOC EXTRACTION REPORT\n======================\nSample:           ransomware.exe\nAnalysis Date:    2025-09-15\nAnalyst:          [Name]\n\nFILE INDICATORS\nSHA-256:          e3b0c44298fc1c149afbf4c8996fb924...\nSHA-1:            da39a3ee5e6b4b0d3255bfef95601890afd80709\nMD5:              d41d8cd98f00b204e9800998ecf8427e\nImphash:          a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6\nssdeep:           3072:kJh3bN7fY+aUkJh3bN7fY+aU:kJh3R7aUkJh3R7aU\n\nNETWORK INDICATORS\nC2 IPs:           185.220.101[.]42, 91.215.85[.]17\nC2 Domains:       update.malicious[.]com, backup.evil[.]net\nC2 URLs:          hxxps:\u002F\u002Fupdate.malicious[.]com\u002Fgate.php\n                  hxxps:\u002F\u002Fbackup.evil[.]net\u002Fgate.php\nJA3 Hash:         a0e9f5d64349fb13191bc781f81f42e1\nUser-Agent:       Mozilla\u002F5.0 (compatible; MSIE 10.0)\n\nHOST INDICATORS\nFile Paths:       C:\\Users\\Public\\svchost.exe\n                  C:\\Users\\%USER%\\AppData\\Local\\Temp\\payload.dll\n                  C:\\Users\\%USER%\\Desktop\\README_DECRYPT.txt\nRegistry Keys:    HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\WindowsUpdate\nMutexes:          Global\\CryptLocker_2025_Q3\nServices:         FakeWindowsUpdate\n\nCONFIDENCE ASSESSMENT\nHigh Confidence:  SHA-256, C2 IPs (validated via VT), Mutexes\nMedium Confidence: Domains (could be compromised legitimate sites)\nLow Confidence:   User-Agent (common string, high false positive risk)\n\nEXPORT FILES\nstix_bundle.json  - STIX 2.1 format for TIP ingestion\niocs.csv          - Flat CSV for SIEM blocklist import\nyara_rule.yar     - YARA detection rule\n```\n",{"name":5,"tags":25,"author":31,"domain":32,"license":15,"version":33,"nist_csf":34,"subdomain":39,"description":7,"mitre_attack":40},[26,27,28,29,30],"malware","IOC-extraction","threat-intelligence","indicators","detection","mahipal","cybersecurity","1.0.0",[35,36,37,38],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[41,42,43,44],"T1027","T1055","T1140","T1497","main","7540bbccf0c1ded6156a467b02c95b61ad62413f",".agents\u002Fskills\u002Fextracting-iocs-from-malware-samples","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena","Currently exploring the intersection of tech","2026-09-11 03:02:31",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add NeelakshSaxena\u002FVayu --skill extracting-iocs-from-malware-samples",{"tool":58,"command":59},"bunx","bunx skills add NeelakshSaxena\u002FVayu --skill extracting-iocs-from-malware-samples",{"tool":61,"command":62},"pnpm","pnpm dlx skills add NeelakshSaxena\u002FVayu --skill extracting-iocs-from-malware-samples","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002FSKILL.md",true,[66,70,76],{"path":67,"resourceType":67,"resourceTypeDesc":68,"sizeBytes":69,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},"references\u002Fapi-reference.md","REFERENCE","参考文档",2640,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002Freferences\u002Fapi-reference.md",{"path":77,"resourceType":78,"resourceTypeDesc":79,"sizeBytes":80,"sourceHtmlUrl":81},"scripts\u002Fagent.py","SCRIPT","脚本",10921,"https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002Fscripts\u002Fagent.py",[83,90,97,104,111,118],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":20},"01M7ACCCVNCFKMA9X6D15X6G98","runpodctl","Runpod CLI for managing GPU\u002FCPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send\u002Freceive). Use for terminal\u002FCI\u002Fscripting, Hub browse\u002Fdeploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpodctl\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":20},"01M7ACC63SRHEA5KMCHSMZK2TC","runpod","Start here for any Runpod task — running GPU\u002FCPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":20},"01M7ACC0Q1C89N9BZBV91CTQTF","runpod-usage","How Runpod works and how to work it — pods vs serverless, GPU\u002FVRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv\u002Fapt). Use to answer \"how does X work\", \"which GPU\", \"how do I build a container\", or \"how do I stand up a workload on a pod\". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-usage\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":20},"01M7ACBRPE345GF5GM5B8P8RRC","runpod-templates","Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says \"run \u003CX> on a pod\" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-templates\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":20},"01M7ACBJATHKVX1TWES2F44GY8","runpod-migrate","Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-migrate\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":20},"01M7ACBC7GHVH6T9YEAPCG2AP8","runpod-mcp","Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU\u002FCPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.","https:\u002F\u002Fgithub.com\u002FNeelakshSaxena\u002FVayu\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frunpod-mcp\u002FSKILL.md",[],[]]