[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7B6N3TCKRDX2CJANXESKB9J":3,"skill-same:01M7B6N3TCKRDX2CJANXESKB9J":80},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":13,"repositoryHtmlUrl":47,"repositoryHomepageUrl":6,"ownerHtmlUrl":48,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":49,"install":50,"resources":63},"01M7B6N3TCKRDX2CJANXESKB9J","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.","vikasvardhanv\u002Fjerry_skills","vikasvardhanv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F99010657?v=4","01M7B2B0VN78W7529RQX5BR6DZ","01M7B2B0WDNTXJHRK3QNPNWRP6",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\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":24,"author":30,"domain":31,"license":14,"version":32,"nist_csf":33,"subdomain":38,"description":7,"mitre_attack":39},[25,26,27,28,29],"malware","IOC-extraction","threat-intelligence","indicators","detection","mahipal","cybersecurity","1.0.0",[34,35,36,37],"DE.AE-02","RS.AN-03","ID.RA-01","DE.CM-01","malware-analysis",[40,41,42,43],"T1027","T1055","T1140","T1497","main","1eb986d0b0ecc180291597e08eb5a58288843536","skills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fextracting-iocs-from-malware-samples","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv","2026-08-25 13:16:33",{"source":8,"skillName":5,"commands":51,"prompt":61,"zipAvailable":62},[52,55,58],{"tool":53,"command":54},"npx","npx skills add vikasvardhanv\u002Fjerry_skills --skill extracting-iocs-from-malware-samples",{"tool":56,"command":57},"bunx","bunx skills add vikasvardhanv\u002Fjerry_skills --skill extracting-iocs-from-malware-samples",{"tool":59,"command":60},"pnpm","pnpm dlx skills add vikasvardhanv\u002Fjerry_skills --skill extracting-iocs-from-malware-samples","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002FSKILL.md",true,[64,68,74],{"path":65,"resourceType":65,"resourceTypeDesc":66,"sizeBytes":67,"sourceHtmlUrl":15},"LICENSE","许可证",11255,{"path":69,"resourceType":70,"resourceTypeDesc":71,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fapi-reference.md","REFERENCE","参考文档",2640,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002Freferences\u002Fapi-reference.md",{"path":75,"resourceType":76,"resourceTypeDesc":77,"sizeBytes":78,"sourceHtmlUrl":79},"scripts\u002Fagent.py","SCRIPT","脚本",10921,"https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fcurated_premium_skills\u002FAnthropic-Cybersecurity-Skills\u002Fskills\u002Fextracting-iocs-from-malware-samples\u002Fscripts\u002Fagent.py",[81,89,96,103,110,117],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7BESR1CJ3H5SP9XM8KYJZ9W","syllabus","Generates a curated supplementary reading list from any course syllabus using Consensus academic search. Grill-me intake (syllabus input format + course audience + year range) plus a grouping forcing-options checkpoint before any search runs — so the reading list matches the course's level and recency need. Parses the syllabus to extract topics and learning outcomes, searches Consensus for recent peer-reviewed papers per topic, and produces a professionally formatted .docx with clickable Consensus links, plain-language summaries calibrated to audience level, and Bloom-higher-order discussion questions tied to course learning goals. Use when the user uploads a syllabus, course outline, or curriculum document and wants supplementary readings (e.g., 'create a reading list from this syllabus', 'find recent papers for my course') — even casual mentions with a syllabus attached should trigger this skill.","MIT","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fsyllabus\u002Fskills\u002Fsyllabus\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":19},"01M7BES1YA6R97W7QPMFFM1PED","pulse","Multi-source recency research skill that takes the pulse of any topic across Reddit, Hacker News, the open web, and optionally X\u002FTwitter within a configurable recent window (default 30 days). Forcing intake clarifies topic specificity, angle (trend\u002Fsentiment\u002Fproblems\u002Fopportunities\u002Fcomparison), time window, and platform scope before searching. Returns a synthesized briefing with citations, engagement metrics, and cross-platform pattern analysis. Use when the user requests multi-source recency intelligence on a topic (e.g., 'pulse on [topic]', 'what's happening with [topic]', 'what are people saying about [topic]', 'current conversation about [topic]', 'take the pulse of [topic]', 'trending: [topic]', 'find me info on [topic]'), and for competitor research, trend discovery, tool comparisons, and audience sentiment analysis.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpulse\u002Fskills\u002Fpulse\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":19},"01M7BERNHYGY035AR00VRT03KE","patent","Patent prior-art and landscape intelligence skill — not generic patent help. Commits to one of five sub-use-cases via forcing intake (novelty search \u002F freedom-to-operate \u002F competitive landscape \u002F acquisition diligence \u002F litigation prior-art) before any search runs. Searches Google Patents, Espacenet, USPTO, and optionally Lens.org for citation-graph signals. Output is an editable Word document (.docx) with verdict, ranked closest art (claim-text extracted), CPC-class-aware landscape, family-resolved hits, geographic coverage, FTO flags where applicable, strategy recommendations, and full audit log. Use when the user asks for patent searching or analysis (e.g., 'prior art search for [invention]', 'freedom to operate analysis for [product]'). Produces search signal, not legal advice — always recommends consulting a patent attorney before filing or licensing decisions. Trademark, copyright, and trade-secret questions are out of scope.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fpatent\u002Fskills\u002Fpatent\u002FSKILL.md",[],[],{"skillNo":104,"name":105,"nameZh":6,"description":106,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":107,"categories":108,"keywords":109,"publishedAt":19},"01M7BERCK1EAKTWW7R436WAR0J","notebooklm","Browser automation skill for controlling Google's NotebookLM. Use when the user wants anything done in NotebookLM (e.g., 'open NotebookLM', 'check my [name] notebook', 'ask my notebook about X', 'add [source] to NotebookLM', 'generate a Video Overview from my notebook', 'use NotebookLM Studio'). Handles reading and querying notebooks, adding sources (URLs, text, files, YouTube links, synthesized content), generating Studio outputs (Audio\u002FVideo Overviews, Mind Maps, Reports incl. Briefing Doc\u002FStudy Guide\u002FFAQ, Flashcards, Quiz, slide decks, infographics — discover the exact set from the live Studio panel; the UI evolves fast), and creating new notebooks. Requires browser automation environment — fails gracefully when unavailable.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fnotebooklm\u002Fskills\u002Fnotebooklm\u002FSKILL.md",[],[],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":19},"01M7BEQZAZAQRTXFJRY7RHV3TY","litreview","Academic literature orientation skill that searches papers via free keyless APIs (PubMed E-utilities + OpenAlex) by default — with the Consensus MCP as an optional enhancement lane when connected — builds a strategic search plan using PICO (default) or SPIDER \u002F Decomposition \u002F hybrid as fallbacks, and synthesizes findings into a formatted Word (.docx) research guide. Grill-me intake (research question specificity + framework hint + tentative depth) before the recon search; a second forcing checkpoint after Phase 2 confirms framework + sub-areas + depth before searches consume budget. Configurable depth (5\u002F10\u002F20 queries) controls coverage vs. speed. Output is a 'launching pad' — an orientation guide that lets a researcher dive in confidently, not a finished review. Use when the user starts literature-oriented research (e.g., 'litreview on [topic]', 'literature review on [topic]', 'I'm starting a literature review on X', 'I'm writing a paper on X', 'help me research X', 'I'm doing research on X', 'can you help me research X'). Do NOT use for single one-off paper searches wanting a quick list — that's a plain PubMed\u002FOpenAlex (or Consensus) query.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Flitreview\u002Fskills\u002Flitreview\u002FSKILL.md",[],[],{"skillNo":118,"name":119,"nameZh":6,"description":120,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":85,"licenseFileUrl":6,"sourceHtmlUrl":121,"categories":122,"keywords":123,"publishedAt":19},"01M7BEQKJ45K31QK5VRAQSVJCJ","grants","NIH grant research skill for clinical researchers. Grill-me intake (research idea + career stage + preliminary data + environment + submission posture + known institute targets) locks down the funding strategy before any search runs. Runs a 5-facet Consensus positioning analysis (with draft Significance\u002FInnovation language), maps the research to the right NIH institutes and study sections via RePORTER, finds NOSIs and funded overlap, and produces an editable Word document (.docx) with budget\u002Fscope-aware mechanism recommendations, submission timelines, and a mandatory program officer recommendation. Use when the user asks about research funding or makes any grant-related request (e.g., 'grants for [topic]', 'find grants for my research idea', 'what grants match my research', 'help me find NIH funding', 'grant opportunities for my research'). NIH-only scope — non-NIH funders (PCORI, DOD CDMRP, VA, foundations) are out of scope and flagged at intake.","https:\u002F\u002Fgithub.com\u002Fvikasvardhanv\u002Fjerry_skills\u002Fblob\u002Fmain\u002Fskills\u002Fresearch\u002Fgrants\u002Fskills\u002Fgrants\u002FSKILL.md",[],[]]