[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ADN76MPXWR676P233WJFVZ":3,"skill-same:01M6ADN76MPXWR676P233WJFVZ":132},{"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":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":91,"commitSha":92,"skillDirectory":93,"forksCount":94,"repositoryHtmlUrl":95,"repositoryHomepageUrl":96,"ownerHtmlUrl":97,"ownerBlogUrl":98,"ownerDescription":99,"updatedAt":100,"install":101,"resources":114},"01M6ADN76MPXWR676P233WJFVZ","analyzing-email-headers-for-phishing-investigation",null,"Parse and analyze email headers (Received chain, Return-Path, Message-ID) to trace the true origin of a phishing email and validate SPF, DKIM, and DMARC results to confirm or rule out sender spoofing. Use when triaging a suspicious or reported email, investigating a phishing incident, or verifying whether a message's sender domain was spoofed.","mukul975\u002FAnthropic-Cybersecurity-Skills","mukul975","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42860185?v=4","01M6ADEQR8T5M4EEG6C67BQCWF","Mahipal","01M6ADJPMYWG1E5GM1FWBE3128",36078,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000005","邮件与沟通","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"email","analyzing email headers for phishing investigation","phishing","official","infrastructure","development","create","website","suspicious","forensics","validate","email-analysis","spf","dkim","dmarc","header-analysis","cybersecurity","2026-11-10 10:12:30",false,"---\nname: analyzing-email-headers-for-phishing-investigation\ndescription: Parse and analyze email headers (Received chain, Return-Path, Message-ID)\n  to trace the true origin of a phishing email and validate SPF, DKIM, and DMARC\n  results to confirm or rule out sender spoofing. Use when triaging a suspicious or\n  reported email, investigating a phishing incident, or verifying whether a message's\n  sender domain was spoofed.\ndomain: cybersecurity\nsubdomain: digital-forensics\ntags:\n- forensics\n- email-analysis\n- phishing\n- spf\n- dkim\n- dmarc\n- header-analysis\nversion: '1.0'\nauthor: mahipal\nlicense: Apache-2.0\natlas_techniques:\n- AML.T0052\nnist_csf:\n- RS.AN-03\n- DE.AE-02\n- RS.MA-01\nmitre_attack:\n- T1566.001\n- T1566.002\n- T1598.003\nmitre_f3:\n  version: '1.1'\n  tactics:\n  - reconnaissance\n  - initial-access\n  - stealth\n  - resource-development\n  techniques:\n  - id: T1598\n    name: Phishing for Information\n    tactic: reconnaissance\n    source: attack\n  - id: T1660\n    name: Phishing\n    tactic: initial-access\n    source: attack\n  - id: T1672\n    name: Email Spoofing\n    tactic: stealth\n    source: attack\n  - id: F1032\n    name: Impersonate Official\n    tactic: initial-access\n    source: f3\n  - id: T1583.001\n    name: 'Acquire Infrastructure: Domains'\n    tactic: resource-development\n    source: attack\n  - id: F1020.002\n    name: 'Create Fake Materials: Fake Website'\n    tactic: resource-development\n    source: f3\n---\n\n# Analyzing Email Headers for Phishing Investigation\n\n## When to Use\n- When investigating a suspected phishing email to determine its true origin\n- For verifying sender authenticity and detecting email spoofing\n- During incident response when a user has clicked a phishing link\n- When tracing the delivery path and relay servers of a suspicious email\n- For validating SPF, DKIM, and DMARC alignment to identify forgery\n\n## Prerequisites\n- Raw email headers from the suspicious message (EML or MSG format)\n- Understanding of SMTP protocol and email header fields\n- Access to DNS lookup tools (dig, nslookup) for SPF\u002FDKIM\u002FDMARC verification\n- Email header analysis tools (MHA, emailheaders.net concepts)\n- Python with email parsing libraries for automated analysis\n- Access to threat intelligence platforms for IP\u002Fdomain reputation\n\n## Workflow\n\n### Step 1: Extract Raw Email Headers\n\n```bash\n# Export from Outlook: Open email > File > Properties > Internet Headers\n# Export from Gmail: Open email > Three dots > Show original\n# Export from Thunderbird: View > Message Source\n\n# If working with EML file from forensic image\ncp \u002Fmnt\u002Fevidence\u002FUsers\u002Fsuspect\u002FAppData\u002FLocal\u002FMicrosoft\u002FOutlook\u002Fphishing_email.eml \\\n   \u002Fcases\u002Fcase-2024-001\u002Femail\u002F\n\n# If working with PST file, extract individual messages\npip install pypff\npython3 \u003C\u003C 'PYEOF'\nimport pypff\n\npst = pypff.file()\npst.open(\"\u002Fcases\u002Fcase-2024-001\u002Femail\u002Foutlook.pst\")\nroot = pst.get_root_folder()\n\ndef extract_messages(folder, path=\"\"):\n    for i in range(folder.get_number_of_sub_messages()):\n        msg = folder.get_sub_message(i)\n        headers = msg.get_transport_headers()\n        subject = msg.get_subject()\n        if headers:\n            filename = f\"\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fmsg_{i}_{subject[:30]}.txt\"\n            with open(filename, 'w') as f:\n                f.write(headers)\n    for i in range(folder.get_number_of_sub_folders()):\n        extract_messages(folder.get_sub_folder(i))\n\nextract_messages(root)\nPYEOF\n```\n\n### Step 2: Parse the Email Header Chain\n\n```bash\n# Parse headers using Python email library\npython3 \u003C\u003C 'PYEOF'\nimport email\nfrom email import policy\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fphishing_email.eml', 'r') as f:\n    msg = email.message_from_file(f, policy=policy.default)\n\nprint(\"=== KEY HEADER FIELDS ===\")\nprint(f\"From:          {msg['From']}\")\nprint(f\"To:            {msg['To']}\")\nprint(f\"Subject:       {msg['Subject']}\")\nprint(f\"Date:          {msg['Date']}\")\nprint(f\"Message-ID:    {msg['Message-ID']}\")\nprint(f\"Reply-To:      {msg['Reply-To']}\")\nprint(f\"Return-Path:   {msg['Return-Path']}\")\nprint(f\"X-Mailer:      {msg['X-Mailer']}\")\nprint(f\"X-Originating-IP: {msg['X-Originating-IP']}\")\n\nprint(\"\\n=== RECEIVED HEADERS (bottom-up = chronological) ===\")\nreceived_headers = msg.get_all('Received')\nif received_headers:\n    for i, header in enumerate(reversed(received_headers)):\n        print(f\"\\nHop {i+1}: {header.strip()}\")\n\nprint(\"\\n=== AUTHENTICATION RESULTS ===\")\nauth_results = msg.get_all('Authentication-Results')\nif auth_results:\n    for result in auth_results:\n        print(result)\n\nprint(f\"\\nARC-Authentication-Results: {msg.get('ARC-Authentication-Results', 'Not present')}\")\nprint(f\"Received-SPF: {msg.get('Received-SPF', 'Not present')}\")\nprint(f\"DKIM-Signature: {msg.get('DKIM-Signature', 'Not present')}\")\nPYEOF\n```\n\n### Step 3: Validate SPF, DKIM, and DMARC Records\n\n```bash\n# Extract the envelope sender domain\nSENDER_DOMAIN=\"example-corp.com\"\n\n# Check SPF record\ndig TXT $SENDER_DOMAIN +short | grep \"v=spf1\"\n# Example: \"v=spf1 include:_spf.google.com include:sendgrid.net ~all\"\n\n# Check DKIM record (selector from DKIM-Signature header, e.g., \"s=selector1\")\nDKIM_SELECTOR=\"selector1\"\ndig TXT ${DKIM_SELECTOR}._domainkey.${SENDER_DOMAIN} +short\n\n# Check DMARC record\ndig TXT _dmarc.${SENDER_DOMAIN} +short\n# Example: \"v=DMARC1; p=reject; rua=mailto:dmarc@example-corp.com; pct=100\"\n\n# Verify the sending IP against SPF\n# Extract IP from first Received header\nSENDING_IP=\"203.0.113.45\"\n\n# Manual SPF check using python\npython3 \u003C\u003C 'PYEOF'\nimport spf  # pip install pyspf\n\nresult, explanation = spf.check2(\n    i='203.0.113.45',\n    s='sender@example-corp.com',\n    h='mail.example-corp.com'\n)\nprint(f\"SPF Result: {result}\")\nprint(f\"Explanation: {explanation}\")\n# Results: pass, fail, softfail, neutral, none, temperror, permerror\nPYEOF\n\n# Check if sending IP is in known malicious IP lists\n# Query AbuseIPDB or VirusTotal\ncurl -s \"https:\u002F\u002Fapi.abuseipdb.com\u002Fapi\u002Fv2\u002Fcheck?ipAddress=${SENDING_IP}\" \\\n   -H \"Key: YOUR_API_KEY\" -H \"Accept: application\u002Fjson\" | python3 -m json.tool\n```\n\n### Step 4: Analyze Sender Domain and Infrastructure\n\n```bash\n# WHOIS lookup on sender domain\nwhois $SENDER_DOMAIN | grep -iE '(registrar|creation|expiration|registrant|nameserver)'\n\n# Check domain age (recently registered domains are suspicious)\n# DNS record investigation\ndig A $SENDER_DOMAIN +short\ndig MX $SENDER_DOMAIN +short\ndig NS $SENDER_DOMAIN +short\n\n# Reverse DNS on sending IP\ndig -x $SENDING_IP +short\n\n# Check for lookalike\u002Ftyposquatting domains\n# Compare with legitimate domain using visual similarity\npython3 \u003C\u003C 'PYEOF'\nimport Levenshtein  # pip install python-Levenshtein\n\nlegitimate = \"microsoft.com\"\nsuspicious = \"micr0soft.com\"\n\ndistance = Levenshtein.distance(legitimate, suspicious)\nratio = Levenshtein.ratio(legitimate, suspicious)\nprint(f\"Edit distance: {distance}\")\nprint(f\"Similarity ratio: {ratio:.2%}\")\nif ratio > 0.8:\n    print(\"WARNING: Likely typosquatting\u002Flookalike domain!\")\nPYEOF\n\n# Check domain reputation on VirusTotal\ncurl -s \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fdomains\u002F${SENDER_DOMAIN}\" \\\n   -H \"x-apikey: YOUR_VT_API_KEY\" | python3 -m json.tool\n\n# Check if the Reply-To differs from From (common phishing indicator)\npython3 -c \"\nimport email\nwith open('\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fphishing_email.eml') as f:\n    msg = email.message_from_file(f)\nfrom_addr = email.utils.parseaddr(msg['From'])[1]\nreply_to = email.utils.parseaddr(msg.get('Reply-To', msg['From']))[1]\nif from_addr != reply_to:\n    print(f'WARNING: From ({from_addr}) != Reply-To ({reply_to})')\nelse:\n    print('From and Reply-To match')\n\"\n```\n\n### Step 5: Examine Email Body and Attachments\n\n```bash\n# Extract URLs from email body\npython3 \u003C\u003C 'PYEOF'\nimport email\nimport re\nfrom email import policy\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fphishing_email.eml', 'r') as f:\n    msg = email.message_from_file(f, policy=policy.default)\n\nbody = msg.get_body(preferencelist=('html', 'plain'))\nif body:\n    content = body.get_content()\n    urls = re.findall(r'https?:\u002F\u002F[^\\s\u003C>\"\\']+', content)\n    print(\"=== URLs FOUND IN EMAIL BODY ===\")\n    for url in set(urls):\n        print(f\"  {url}\")\n\n    # Check for URL obfuscation (display text != href)\n    href_pattern = re.findall(r'\u003Ca[^>]*href=[\"\\']([^\"\\']+)[\"\\'][^>]*>(.*?)\u003C\u002Fa>', content, re.DOTALL)\n    print(\"\\n=== HYPERLINK ANALYSIS ===\")\n    for href, text in href_pattern:\n        display_url = re.findall(r'https?:\u002F\u002F[^\\s\u003C]+', text)\n        if display_url and display_url[0] != href:\n            print(f\"  MISMATCH: Display='{display_url[0]}' -> Actual='{href}'\")\n\n# Extract and hash attachments\nprint(\"\\n=== ATTACHMENTS ===\")\nfor part in msg.walk():\n    if part.get_content_disposition() == 'attachment':\n        filename = part.get_filename()\n        content = part.get_payload(decode=True)\n        import hashlib\n        sha256 = hashlib.sha256(content).hexdigest()\n        print(f\"  File: {filename}, Size: {len(content)}, SHA-256: {sha256}\")\n        with open(f'\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fattachments\u002F{filename}', 'wb') as af:\n            af.write(content)\nPYEOF\n\n# Submit attachment hashes to VirusTotal\n# Submit URLs to URLhaus or PhishTank for reputation check\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| SPF (Sender Policy Framework) | DNS record specifying authorized mail servers for a domain |\n| DKIM (DomainKeys Identified Mail) | Cryptographic signature verifying email content integrity |\n| DMARC | Policy framework combining SPF and DKIM for sender authentication |\n| Received headers | Server-added headers showing each hop in the delivery chain (read bottom to top) |\n| Return-Path | Envelope sender address used for bounce messages; may differ from From |\n| Message-ID | Unique identifier assigned by the originating mail server |\n| X-Originating-IP | Original sender IP address (added by some mail services) |\n| Header forgery | Attackers can forge From, Reply-To, and other headers but not Received chains |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| MXToolbox | Online email header analyzer and DNS lookup |\n| dig\u002Fnslookup | DNS record queries for SPF, DKIM, DMARC verification |\n| pyspf | Python SPF record validation library |\n| dkimpy | Python DKIM signature verification library |\n| PhishTool | Specialized phishing email analysis platform |\n| VirusTotal | URL and file reputation checking service |\n| AbuseIPDB | IP address reputation database |\n| whois | Domain registration information lookup |\n\n## Common Scenarios\n\n**Scenario 1: CEO Fraud \u002F Business Email Compromise**\nThe email claims to be from the CEO but Reply-To points to a Gmail address, SPF fails because the sending IP is not authorized for the spoofed domain, DKIM is missing, and the From domain is a lookalike (ceo-company.com vs company.com).\n\n**Scenario 2: Credential Harvesting Phishing**\nEmail contains a link that displays \"login.microsoft.com\" but href points to a lookalike domain, the attachment is an HTML file containing a fake login page with credential exfiltration JavaScript, the sending domain was registered 3 days ago.\n\n**Scenario 3: Malware Delivery via Attachment**\nEmail with an Office document attachment containing macros, the sender domain passes SPF but the account was compromised, DKIM signature is valid (sent from legitimate infrastructure), attachment SHA-256 matches known malware on VirusTotal.\n\n**Scenario 4: Spear Phishing with Legitimate Service**\nAttacker uses a legitimate email marketing service to send phishing, SPF and DKIM pass because the service is authorized, the phishing is in the content not the infrastructure, requires URL and content analysis rather than header authentication checks.\n\n## Output Format\n\n```\nEmail Header Analysis Report:\n  Subject:     \"Urgent: Invoice Payment Required\"\n  From:        accounting@examp1e-corp.com (SPOOFED)\n  Reply-To:    payments.urgent@gmail.com (MISMATCH)\n  Return-Path: \u003Cbounce@mail-server.xyz>\n  Date:        2024-01-15 09:23:45 UTC\n\n  Delivery Path (4 hops):\n    Hop 1: mail-server.xyz [203.0.113.45] -> relay1.isp.com\n    Hop 2: relay1.isp.com -> mx.target-company.com\n    Hop 3: mx.target-company.com -> internal-filter.target.com\n    Hop 4: internal-filter.target.com -> mailbox\n\n  Authentication:\n    SPF:    FAIL (203.0.113.45 not authorized for examp1e-corp.com)\n    DKIM:   NONE (no signature present)\n    DMARC:  FAIL (p=none, no enforcement)\n\n  Indicators of Phishing:\n    - Lookalike domain (examp1e-corp.com vs example-corp.com, 96% similar)\n    - From\u002FReply-To mismatch\n    - Domain registered 2 days before email sent\n    - URL in body points to credential harvesting page\n    - Attachment: invoice.xlsm (SHA-256: a3f2...) - Known malware on VT\n\n  Risk Level: HIGH\n```\n","# Analyzing Email Headers for Phishing Investigation\n\n## When to Use\n- When investigating a suspected phishing email to determine its true origin\n- For verifying sender authenticity and detecting email spoofing\n- During incident response when a user has clicked a phishing link\n- When tracing the delivery path and relay servers of a suspicious email\n- For validating SPF, DKIM, and DMARC alignment to identify forgery\n\n## Prerequisites\n- Raw email headers from the suspicious message (EML or MSG format)\n- Understanding of SMTP protocol and email header fields\n- Access to DNS lookup tools (dig, nslookup) for SPF\u002FDKIM\u002FDMARC verification\n- Email header analysis tools (MHA, emailheaders.net concepts)\n- Python with email parsing libraries for automated analysis\n- Access to threat intelligence platforms for IP\u002Fdomain reputation\n\n## Workflow\n\n### Step 1: Extract Raw Email Headers\n\n```bash\n# Export from Outlook: Open email > File > Properties > Internet Headers\n# Export from Gmail: Open email > Three dots > Show original\n# Export from Thunderbird: View > Message Source\n\n# If working with EML file from forensic image\ncp \u002Fmnt\u002Fevidence\u002FUsers\u002Fsuspect\u002FAppData\u002FLocal\u002FMicrosoft\u002FOutlook\u002Fphishing_email.eml \\\n   \u002Fcases\u002Fcase-2024-001\u002Femail\u002F\n\n# If working with PST file, extract individual messages\npip install pypff\npython3 \u003C\u003C 'PYEOF'\nimport pypff\n\npst = pypff.file()\npst.open(\"\u002Fcases\u002Fcase-2024-001\u002Femail\u002Foutlook.pst\")\nroot = pst.get_root_folder()\n\ndef extract_messages(folder, path=\"\"):\n    for i in range(folder.get_number_of_sub_messages()):\n        msg = folder.get_sub_message(i)\n        headers = msg.get_transport_headers()\n        subject = msg.get_subject()\n        if headers:\n            filename = f\"\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fmsg_{i}_{subject[:30]}.txt\"\n            with open(filename, 'w') as f:\n                f.write(headers)\n    for i in range(folder.get_number_of_sub_folders()):\n        extract_messages(folder.get_sub_folder(i))\n\nextract_messages(root)\nPYEOF\n```\n\n### Step 2: Parse the Email Header Chain\n\n```bash\n# Parse headers using Python email library\npython3 \u003C\u003C 'PYEOF'\nimport email\nfrom email import policy\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fphishing_email.eml', 'r') as f:\n    msg = email.message_from_file(f, policy=policy.default)\n\nprint(\"=== KEY HEADER FIELDS ===\")\nprint(f\"From:          {msg['From']}\")\nprint(f\"To:            {msg['To']}\")\nprint(f\"Subject:       {msg['Subject']}\")\nprint(f\"Date:          {msg['Date']}\")\nprint(f\"Message-ID:    {msg['Message-ID']}\")\nprint(f\"Reply-To:      {msg['Reply-To']}\")\nprint(f\"Return-Path:   {msg['Return-Path']}\")\nprint(f\"X-Mailer:      {msg['X-Mailer']}\")\nprint(f\"X-Originating-IP: {msg['X-Originating-IP']}\")\n\nprint(\"\\n=== RECEIVED HEADERS (bottom-up = chronological) ===\")\nreceived_headers = msg.get_all('Received')\nif received_headers:\n    for i, header in enumerate(reversed(received_headers)):\n        print(f\"\\nHop {i+1}: {header.strip()}\")\n\nprint(\"\\n=== AUTHENTICATION RESULTS ===\")\nauth_results = msg.get_all('Authentication-Results')\nif auth_results:\n    for result in auth_results:\n        print(result)\n\nprint(f\"\\nARC-Authentication-Results: {msg.get('ARC-Authentication-Results', 'Not present')}\")\nprint(f\"Received-SPF: {msg.get('Received-SPF', 'Not present')}\")\nprint(f\"DKIM-Signature: {msg.get('DKIM-Signature', 'Not present')}\")\nPYEOF\n```\n\n### Step 3: Validate SPF, DKIM, and DMARC Records\n\n```bash\n# Extract the envelope sender domain\nSENDER_DOMAIN=\"example-corp.com\"\n\n# Check SPF record\ndig TXT $SENDER_DOMAIN +short | grep \"v=spf1\"\n# Example: \"v=spf1 include:_spf.google.com include:sendgrid.net ~all\"\n\n# Check DKIM record (selector from DKIM-Signature header, e.g., \"s=selector1\")\nDKIM_SELECTOR=\"selector1\"\ndig TXT ${DKIM_SELECTOR}._domainkey.${SENDER_DOMAIN} +short\n\n# Check DMARC record\ndig TXT _dmarc.${SENDER_DOMAIN} +short\n# Example: \"v=DMARC1; p=reject; rua=mailto:dmarc@example-corp.com; pct=100\"\n\n# Verify the sending IP against SPF\n# Extract IP from first Received header\nSENDING_IP=\"203.0.113.45\"\n\n# Manual SPF check using python\npython3 \u003C\u003C 'PYEOF'\nimport spf  # pip install pyspf\n\nresult, explanation = spf.check2(\n    i='203.0.113.45',\n    s='sender@example-corp.com',\n    h='mail.example-corp.com'\n)\nprint(f\"SPF Result: {result}\")\nprint(f\"Explanation: {explanation}\")\n# Results: pass, fail, softfail, neutral, none, temperror, permerror\nPYEOF\n\n# Check if sending IP is in known malicious IP lists\n# Query AbuseIPDB or VirusTotal\ncurl -s \"https:\u002F\u002Fapi.abuseipdb.com\u002Fapi\u002Fv2\u002Fcheck?ipAddress=${SENDING_IP}\" \\\n   -H \"Key: YOUR_API_KEY\" -H \"Accept: application\u002Fjson\" | python3 -m json.tool\n```\n\n### Step 4: Analyze Sender Domain and Infrastructure\n\n```bash\n# WHOIS lookup on sender domain\nwhois $SENDER_DOMAIN | grep -iE '(registrar|creation|expiration|registrant|nameserver)'\n\n# Check domain age (recently registered domains are suspicious)\n# DNS record investigation\ndig A $SENDER_DOMAIN +short\ndig MX $SENDER_DOMAIN +short\ndig NS $SENDER_DOMAIN +short\n\n# Reverse DNS on sending IP\ndig -x $SENDING_IP +short\n\n# Check for lookalike\u002Ftyposquatting domains\n# Compare with legitimate domain using visual similarity\npython3 \u003C\u003C 'PYEOF'\nimport Levenshtein  # pip install python-Levenshtein\n\nlegitimate = \"microsoft.com\"\nsuspicious = \"micr0soft.com\"\n\ndistance = Levenshtein.distance(legitimate, suspicious)\nratio = Levenshtein.ratio(legitimate, suspicious)\nprint(f\"Edit distance: {distance}\")\nprint(f\"Similarity ratio: {ratio:.2%}\")\nif ratio > 0.8:\n    print(\"WARNING: Likely typosquatting\u002Flookalike domain!\")\nPYEOF\n\n# Check domain reputation on VirusTotal\ncurl -s \"https:\u002F\u002Fwww.virustotal.com\u002Fapi\u002Fv3\u002Fdomains\u002F${SENDER_DOMAIN}\" \\\n   -H \"x-apikey: YOUR_VT_API_KEY\" | python3 -m json.tool\n\n# Check if the Reply-To differs from From (common phishing indicator)\npython3 -c \"\nimport email\nwith open('\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fphishing_email.eml') as f:\n    msg = email.message_from_file(f)\nfrom_addr = email.utils.parseaddr(msg['From'])[1]\nreply_to = email.utils.parseaddr(msg.get('Reply-To', msg['From']))[1]\nif from_addr != reply_to:\n    print(f'WARNING: From ({from_addr}) != Reply-To ({reply_to})')\nelse:\n    print('From and Reply-To match')\n\"\n```\n\n### Step 5: Examine Email Body and Attachments\n\n```bash\n# Extract URLs from email body\npython3 \u003C\u003C 'PYEOF'\nimport email\nimport re\nfrom email import policy\n\nwith open('\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fphishing_email.eml', 'r') as f:\n    msg = email.message_from_file(f, policy=policy.default)\n\nbody = msg.get_body(preferencelist=('html', 'plain'))\nif body:\n    content = body.get_content()\n    urls = re.findall(r'https?:\u002F\u002F[^\\s\u003C>\"\\']+', content)\n    print(\"=== URLs FOUND IN EMAIL BODY ===\")\n    for url in set(urls):\n        print(f\"  {url}\")\n\n    # Check for URL obfuscation (display text != href)\n    href_pattern = re.findall(r'\u003Ca[^>]*href=[\"\\']([^\"\\']+)[\"\\'][^>]*>(.*?)\u003C\u002Fa>', content, re.DOTALL)\n    print(\"\\n=== HYPERLINK ANALYSIS ===\")\n    for href, text in href_pattern:\n        display_url = re.findall(r'https?:\u002F\u002F[^\\s\u003C]+', text)\n        if display_url and display_url[0] != href:\n            print(f\"  MISMATCH: Display='{display_url[0]}' -> Actual='{href}'\")\n\n# Extract and hash attachments\nprint(\"\\n=== ATTACHMENTS ===\")\nfor part in msg.walk():\n    if part.get_content_disposition() == 'attachment':\n        filename = part.get_filename()\n        content = part.get_payload(decode=True)\n        import hashlib\n        sha256 = hashlib.sha256(content).hexdigest()\n        print(f\"  File: {filename}, Size: {len(content)}, SHA-256: {sha256}\")\n        with open(f'\u002Fcases\u002Fcase-2024-001\u002Femail\u002Fattachments\u002F{filename}', 'wb') as af:\n            af.write(content)\nPYEOF\n\n# Submit attachment hashes to VirusTotal\n# Submit URLs to URLhaus or PhishTank for reputation check\n```\n\n## Key Concepts\n\n| Concept | Description |\n|---------|-------------|\n| SPF (Sender Policy Framework) | DNS record specifying authorized mail servers for a domain |\n| DKIM (DomainKeys Identified Mail) | Cryptographic signature verifying email content integrity |\n| DMARC | Policy framework combining SPF and DKIM for sender authentication |\n| Received headers | Server-added headers showing each hop in the delivery chain (read bottom to top) |\n| Return-Path | Envelope sender address used for bounce messages; may differ from From |\n| Message-ID | Unique identifier assigned by the originating mail server |\n| X-Originating-IP | Original sender IP address (added by some mail services) |\n| Header forgery | Attackers can forge From, Reply-To, and other headers but not Received chains |\n\n## Tools & Systems\n\n| Tool | Purpose |\n|------|---------|\n| MXToolbox | Online email header analyzer and DNS lookup |\n| dig\u002Fnslookup | DNS record queries for SPF, DKIM, DMARC verification |\n| pyspf | Python SPF record validation library |\n| dkimpy | Python DKIM signature verification library |\n| PhishTool | Specialized phishing email analysis platform |\n| VirusTotal | URL and file reputation checking service |\n| AbuseIPDB | IP address reputation database |\n| whois | Domain registration information lookup |\n\n## Common Scenarios\n\n**Scenario 1: CEO Fraud \u002F Business Email Compromise**\nThe email claims to be from the CEO but Reply-To points to a Gmail address, SPF fails because the sending IP is not authorized for the spoofed domain, DKIM is missing, and the From domain is a lookalike (ceo-company.com vs company.com).\n\n**Scenario 2: Credential Harvesting Phishing**\nEmail contains a link that displays \"login.microsoft.com\" but href points to a lookalike domain, the attachment is an HTML file containing a fake login page with credential exfiltration JavaScript, the sending domain was registered 3 days ago.\n\n**Scenario 3: Malware Delivery via Attachment**\nEmail with an Office document attachment containing macros, the sender domain passes SPF but the account was compromised, DKIM signature is valid (sent from legitimate infrastructure), attachment SHA-256 matches known malware on VirusTotal.\n\n**Scenario 4: Spear Phishing with Legitimate Service**\nAttacker uses a legitimate email marketing service to send phishing, SPF and DKIM pass because the service is authorized, the phishing is in the content not the infrastructure, requires URL and content analysis rather than header authentication checks.\n\n## Output Format\n\n```\nEmail Header Analysis Report:\n  Subject:     \"Urgent: Invoice Payment Required\"\n  From:        accounting@examp1e-corp.com (SPOOFED)\n  Reply-To:    payments.urgent@gmail.com (MISMATCH)\n  Return-Path: \u003Cbounce@mail-server.xyz>\n  Date:        2024-01-15 09:23:45 UTC\n\n  Delivery Path (4 hops):\n    Hop 1: mail-server.xyz [203.0.113.45] -> relay1.isp.com\n    Hop 2: relay1.isp.com -> mx.target-company.com\n    Hop 3: mx.target-company.com -> internal-filter.target.com\n    Hop 4: internal-filter.target.com -> mailbox\n\n  Authentication:\n    SPF:    FAIL (203.0.113.45 not authorized for examp1e-corp.com)\n    DKIM:   NONE (no signature present)\n    DMARC:  FAIL (p=none, no enforcement)\n\n  Indicators of Phishing:\n    - Lookalike domain (examp1e-corp.com vs example-corp.com, 96% similar)\n    - From\u002FReply-To mismatch\n    - Domain registered 2 days before email sent\n    - URL in body points to credential harvesting page\n    - Attachment: invoice.xlsm (SHA-256: a3f2...) - Known malware on VT\n\n  Risk Level: HIGH\n```\n",{"name":5,"tags":49,"author":50,"domain":43,"license":15,"version":51,"mitre_f3":52,"nist_csf":80,"subdomain":84,"description":7,"mitre_attack":85,"atlas_techniques":89},[36,38,29,39,40,41,42],"mahipal","1.0",{"tactics":53,"version":58,"techniques":59},[54,55,56,57],"reconnaissance","initial-access","stealth","resource-development","1.1",[60,64,67,70,74,77],{"id":61,"name":62,"source":63,"tactic":54},"T1598","Phishing for Information","attack",{"id":65,"name":66,"source":63,"tactic":55},"T1660","Phishing",{"id":68,"name":69,"source":63,"tactic":56},"T1672","Email Spoofing",{"id":71,"name":72,"source":73,"tactic":55},"F1032","Impersonate Official","f3",{"id":75,"name":76,"source":63,"tactic":57},"T1583.001","Acquire Infrastructure: Domains",{"id":78,"name":79,"source":73,"tactic":57},"F1020.002","Create Fake Materials: Fake Website",[81,82,83],"RS.AN-03","DE.AE-02","RS.MA-01","digital-forensics",[86,87,88],"T1566.001","T1566.002","T1598.003",[90],"AML.T0052","main","54a798831d2266a3ca61ce68a7acb80b81160d57","skills\u002Fanalyzing-email-headers-for-phishing-investigation",4414,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","https:\u002F\u002Fmahipal.engineer\u002FAnthropic-Cybersecurity-Skills\u002F","https:\u002F\u002Fgithub.com\u002Fmukul975","Mahipal.engineer","🔐 Cybersecurity | 💻 Dev | 📷 Street Photographer\r\n🎓 MSc | 📚 Research & AI Security","2026-08-31 12:32:44",{"source":8,"skillName":5,"commands":102,"prompt":112,"zipAvailable":113},[103,106,109],{"tool":104,"command":105},"npx","npx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill analyzing-email-headers-for-phishing-investigation",{"tool":107,"command":108},"bunx","bunx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill analyzing-email-headers-for-phishing-investigation",{"tool":110,"command":111},"pnpm","pnpm dlx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill analyzing-email-headers-for-phishing-investigation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002FSKILL.md",true,[115,120,126],{"path":116,"resourceType":116,"resourceTypeDesc":117,"sizeBytes":118,"sourceHtmlUrl":119},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002FLICENSE",{"path":121,"resourceType":122,"resourceTypeDesc":123,"sizeBytes":124,"sourceHtmlUrl":125},"references\u002Fapi-reference.md","REFERENCE","参考文档",2772,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002Freferences\u002Fapi-reference.md",{"path":127,"resourceType":128,"resourceTypeDesc":129,"sizeBytes":130,"sourceHtmlUrl":131},"scripts\u002Fagent.py","SCRIPT","脚本",8576,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002Fscripts\u002Fagent.py",[133,160,184,211,236,263],{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":140,"publishedAt":44},"01M6AGDM3HJXTKXX15ZZ0ZVCJ3","verifying-build-provenance-with-slsa-sigstore","Verifies artifact signatures and SLSA provenance using Sigstore's cosign (verify, verify-attestation, verify-blob-attestation) and slsa-verifier (verify-artifact), enforcing keyless OIDC builder identity and source repo against SLSA Build levels. Use in CI\u002FCD before deploying artifacts, when consuming third-party attestations, establishing a SLSA Build L3 pipeline, or confirming provenance during incident response or admission control.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fverifying-build-provenance-with-slsa-sigstore\u002FSKILL.md",[139],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[141,142,143,144,145,43,146,147,148,149,150,151,152,153,154,155,156,157,158,159],"sigstore","provenance","slsa","verifying build provenance with slsa sigstore","security","incident response","identity","pr","code","artifacts","ci","supply-chain","pipeline","supply-chain-security","t1195","attestation","code-signing","cosign","keyless",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":167,"publishedAt":44},"01M6AGDGBPWYVZ2F11GFKJ4HZ9","validating-tpm-measured-boot-attestation","Verifies TPM 2.0 measured-boot integrity and remote attestation with tpm2-tools -- reading PCRs (tpm2_pcrread), replaying the boot event log, generating and checking signed quotes (tpm2_quote\u002Ftpm2_checkquote), and sealing secrets to a PCR policy. Use to confirm a system booted trusted firmware\u002Fkernel for Zero Trust device posture, detect boot-chain tampering via PCR drift, or build a golden-value baseline for fleet attestation.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-tpm-measured-boot-attestation\u002FSKILL.md",[166],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[168,156,169,170,145,171,43,148,172,173,174,175,176,177,178,179,180,181,182,183],"boot","TPM","validating tpm measured boot attestation","policy","verification","ZeRO","firmware","Tools","measured-boot","PCR","integrity","secrets","remote-attestation","tpm2-tools","integrity-verification","trusted-computing",{"skillNo":185,"name":186,"nameZh":6,"description":187,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":188,"categories":189,"keywords":194,"publishedAt":44},"01M6AGDCW0Y4FXZ3362GT1941M","validating-backup-integrity-for-recovery","Validates backup integrity through cryptographic hash verification, automated restore testing, corruption detection, and recoverability checks to confirm backups are reliable for disaster recovery and ransomware response. Use before relying on backups for recovery, when building post-backup validation pipelines, auditing backup infrastructure for compliance, or checking immutable\u002Fair-gapped backups for silent corruption or tampering.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-backup-integrity-for-recovery\u002FSKILL.md",[190,193],{"categoryNo":191,"categoryName":192,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[178,195,196,197,198,43,31,199,172,200,201,202,203,204,205,206,207,208,209,210],"backup","recovery","validating backup integrity for recovery","testing","validation","compliance","hash-verification","incident-response","ransomware","cryptocurrency","detection","t1078","t1490","immutable","disaster-recovery","restore-testing",{"skillNo":212,"name":213,"nameZh":6,"description":214,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":215,"categories":216,"keywords":218,"publishedAt":44},"01M6AGD9GBG2KZ336AE763J3WH","triaging-windows-with-kape","Runs KAPE (Kroll Artifact Parser and Extractor) to collect targeted forensic artifacts (registry hives, $MFT, event logs, prefetch, browser data) via Targets and parse them with Modules wrapping Eric Zimmerman's EZ Tools (PECmd, MFTECmd, RECmd). Use during early incident containment\u002Ftriage when full disk imaging is impractical but a defensible, parseable Windows artifact set is needed quickly, including at-scale remote collection.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-windows-with-kape\u002FSKILL.md",[217],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[219,220,221,43,222,223,224,225,226,227,228,229,230,231,84,232,175,233,234,235],"windows","kape","triaging windows with kape","registry","browser","logs","windows-forensics","dfir","mft","mftecmd","data","prefetch","eric-zimmerman","SET","collection","pecmd","artifact-collection",{"skillNo":237,"name":238,"nameZh":6,"description":239,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":240,"categories":241,"keywords":243,"publishedAt":44},"01M6AGD5PW5J4EVZM958WD74ZQ","triaging-vulnerabilities-with-ssvc-framework","Triages and prioritizes vulnerabilities with CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree, weighing exploitation status (via the CISA KEV catalog and FIRST EPSS API), technical impact, automatability, and mission prevalence to output Track\u002FTrack*\u002FAttend\u002FAct decisions. Use when prioritizing vulnerability scan results (OpenVAS, Nessus, Qualys) for remediation planning beyond raw CVSS scores.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-vulnerabilities-with-ssvc-framework\u002FSKILL.md",[242],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[244,245,246,43,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262],"vulnerabilities","framework","triaging vulnerabilities with ssvc framework","status","planning","CISA","vulnerability-management","risk-management","nessus","qualys","openvas","cvss","remediation","risk","vulnerability","api","prioritization","ssvc","decision-tree",{"skillNo":264,"name":265,"nameZh":6,"description":266,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":267,"categories":268,"keywords":270,"publishedAt":44},"01M6AGD24TTQQM4CXG69E3B9TJ","triaging-security-incident","Performs initial triage of security incidents using the NIST SP 800-61r3 and SANS PICERL frameworks, classifying incident type, assigning priority by business impact, and routing to the appropriate response team. Use when a SIEM\u002FEDR alert needs human classification, concurrent alerts must be prioritized, or a user report or threat-intel IOC match requires initial incident categorization.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-security-incident\u002FSKILL.md",[269],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[145,271,43,272,273,274,275,276,277,278,279,206,280,207,281,282,283,284,285,286],"triaging security incident","siem","file","ioc","soc","NIST-800-61","NIST","severity","edr","execution","analysis","classification","severity-classification","incident-triage","SANS-PICERL","SOC-operations"]