[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ESKJBF96N1FGSBYJTY0K3T":3,"skill-same:01M6ESKJBF96N1FGSBYJTY0K3T":130},{"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":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":67,"commitSha":68,"skillDirectory":69,"forksCount":14,"repositoryHtmlUrl":70,"repositoryHomepageUrl":71,"ownerHtmlUrl":72,"ownerBlogUrl":6,"ownerDescription":73,"updatedAt":74,"install":75,"resources":88},"01M6ESKJBF96N1FGSBYJTY0K3T","analyzing-email-headers-for-phishing-investigation",null,"Parse and analyze email headers to trace the origin of phishing emails, verify sender authenticity, and identify spoofing through SPF, DKIM, and DMARC validation.","henriquescastilho\u002Fmy-claude","henriquescastilho","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F153296945?v=4","01M6ESH7EXPXTH9CVQ4K16SRG8","Henrique Scheer","01M6ESH7JHEK2PTNNH4HEH787Z",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\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,44,45,46],"email","phishing","investigation","analyzing email headers for phishing investigation","analyzing","de","cybersecurity","emails","aml","analyze","verify","analysis","t1566","header-analysis","dmarc","dkim","spf","email-analysis","forensics","validation","2026-11-10 10:12:30",false,"---\nname: analyzing-email-headers-for-phishing-investigation\ndescription: Parse and analyze email headers to trace the origin of phishing emails,\n  verify sender authenticity, and identify spoofing through SPF, DKIM, and DMARC validation.\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-01\n- RS.AN-03\n- DE.AE-02\n- RS.MA-01\nmitre_attack:\n- T1566.001\n- T1566.002\n- T1598.003\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":52,"author":53,"domain":33,"license":15,"version":54,"nist_csf":55,"subdomain":60,"description":7,"mitre_attack":61,"atlas_techniques":65},[45,44,28,43,42,41,40],"mahipal","1.0",[56,57,58,59],"RS.AN-01","RS.AN-03","DE.AE-02","RS.MA-01","digital-forensics",[62,63,64],"T1566.001","T1566.002","T1598.003",[66],"AML.T0052","main","7925716f065257435fdb12e97f7e52842147d5ad",".claude\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude","https:\u002F\u002Fclaude.com\u002Fclaude-code","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho","Software · Applied AI · Quantitative Modeling · Building with Claude.","2026-06-10 12:24:46",{"source":8,"skillName":5,"commands":76,"prompt":86,"zipAvailable":87},[77,80,83],{"tool":78,"command":79},"npx","npx skills add henriquescastilho\u002Fmy-claude --skill analyzing-email-headers-for-phishing-investigation",{"tool":81,"command":82},"bunx","bunx skills add henriquescastilho\u002Fmy-claude --skill analyzing-email-headers-for-phishing-investigation",{"tool":84,"command":85},"pnpm","pnpm dlx skills add henriquescastilho\u002Fmy-claude --skill analyzing-email-headers-for-phishing-investigation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002FSKILL.md",true,[89,94,100,104,108,112,116,120,124],{"path":90,"resourceType":90,"resourceTypeDesc":91,"sizeBytes":92,"sourceHtmlUrl":93},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002FLICENSE",{"path":95,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":98,"sourceHtmlUrl":99},"references\u002Fapi-reference.md","REFERENCE","参考文档",2772,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002Freferences\u002Fapi-reference.md",{"path":101,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":102,"sourceHtmlUrl":103},"references\u002Fcompiler-diagnostics-abi-linker-checklist.md",41154,"https:\u002F\u002Fgithub.com\u002F0disoft\u002Fmustflow\u002Fblob\u002Fmain\u002Ftemplates\u002Fdefault\u002Flocales\u002Fen\u002F.mustflow\u002Fskills\u002Fcompiler-engineering-review\u002Freferences\u002Fcompiler-diagnostics-abi-linker-checklist.md",{"path":105,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":106,"sourceHtmlUrl":107},"references\u002Fcompiler-generators-properties-checklist.md",23620,"https:\u002F\u002Fgithub.com\u002F0disoft\u002Fmustflow\u002Fblob\u002Fmain\u002Ftemplates\u002Fdefault\u002Flocales\u002Fen\u002F.mustflow\u002Fskills\u002Fcompiler-engineering-review\u002Freferences\u002Fcompiler-generators-properties-checklist.md",{"path":109,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":110,"sourceHtmlUrl":111},"references\u002Fcompiler-test-strategy-differential-checklist.md",22955,"https:\u002F\u002Fgithub.com\u002F0disoft\u002Fmustflow\u002Fblob\u002Fmain\u002Ftemplates\u002Fdefault\u002Flocales\u002Fen\u002F.mustflow\u002Fskills\u002Fcompiler-engineering-review\u002Freferences\u002Fcompiler-test-strategy-differential-checklist.md",{"path":113,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":114,"sourceHtmlUrl":115},"references\u002Fdebug-symbol-symbolication-checklist.md",21732,"https:\u002F\u002Fgithub.com\u002F0disoft\u002Fmustflow\u002Fblob\u002Fmain\u002Ftemplates\u002Fdefault\u002Flocales\u002Fen\u002F.mustflow\u002Fskills\u002Fcompiler-engineering-review\u002Freferences\u002Fdebug-symbol-symbolication-checklist.md",{"path":117,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":118,"sourceHtmlUrl":119},"references\u002Fir-design-ssa-pass-pipeline-checklist.md",37353,"https:\u002F\u002Fgithub.com\u002F0disoft\u002Fmustflow\u002Fblob\u002Fmain\u002Ftemplates\u002Fdefault\u002Flocales\u002Fen\u002F.mustflow\u002Fskills\u002Fcompiler-engineering-review\u002Freferences\u002Fir-design-ssa-pass-pipeline-checklist.md",{"path":121,"resourceType":96,"resourceTypeDesc":97,"sizeBytes":122,"sourceHtmlUrl":123},"references\u002Fmiscompile-reduction-ir-checklist.md",19599,"https:\u002F\u002Fgithub.com\u002F0disoft\u002Fmustflow\u002Fblob\u002Fmain\u002Ftemplates\u002Fdefault\u002Flocales\u002Fen\u002F.mustflow\u002Fskills\u002Fcompiler-engineering-review\u002Freferences\u002Fmiscompile-reduction-ir-checklist.md",{"path":125,"resourceType":126,"resourceTypeDesc":127,"sizeBytes":128,"sourceHtmlUrl":129},"scripts\u002Fagent.py","SCRIPT","脚本",8576,"https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fanalyzing-email-headers-for-phishing-investigation\u002Fscripts\u002Fagent.py",[131,172,181,190,212,237],{"skillNo":132,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":135,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":152,"publishedAt":47},"01M6F0B6XPQ65AX2X0DWK8KT3E","markitdown","Convert files and office documents to Markdown. Supports PDF, DOCX, PPTX, XLSX, images (with OCR), audio (with transcription), HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs and more.","MIT","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[138,141,144,147],{"categoryNo":139,"categoryName":140,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理",{"categoryNo":142,"categoryName":143,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000003","演示文稿",{"categoryNo":145,"categoryName":146,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000004","电子表格",{"categoryNo":148,"categoryName":149,"taxonomyType":150,"taxonomyTypeDesc":151},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[133,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171],"docx","PDF","pptx","xlsx","documents","csv","ocr","Audio","Bash","markdown","convert","read","write","edit","html","images","files","youtube","with",{"skillNo":173,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":135,"licenseFileUrl":6,"sourceHtmlUrl":174,"categories":175,"keywords":180,"publishedAt":47},"01M6F06SBHR9F0SDWE282Y8075","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002Fscientific_writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[176,177,178,179],{"categoryNo":139,"categoryName":140,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":142,"categoryName":143,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":145,"categoryName":146,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":148,"categoryName":149,"taxonomyType":150,"taxonomyTypeDesc":151},[133,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171],{"skillNo":182,"name":133,"nameZh":6,"description":134,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":135,"licenseFileUrl":6,"sourceHtmlUrl":183,"categories":184,"keywords":189,"publishedAt":47},"01M6F02D4R14EJAPBWVDF9J9VQ","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-writer\u002F.claude\u002Fskills\u002Fmarkitdown\u002FSKILL.md",[185,186,187,188],{"categoryNo":139,"categoryName":140,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":142,"categoryName":143,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":145,"categoryName":146,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":148,"categoryName":149,"taxonomyType":150,"taxonomyTypeDesc":151},[133,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171],{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":135,"licenseFileUrl":6,"sourceHtmlUrl":194,"categories":195,"keywords":196,"publishedAt":47},"01M6F000KS6YB4MKS774G4R8ND","zarr-python","Chunked N-D arrays for cloud storage. Compressed arrays, parallel I\u002FO, S3\u002FGCS integration, NumPy\u002FDask\u002FXarray compatible, for large-scale scientific computing pipelines.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fzarr-python\u002FSKILL.md",[],[197,198,199,200,201,202,203,204,205,206,207,208,209,210,211],"python","zarr python","storage","integration","s3","gcs","cloud","dask","parallel","pipelines","arrays","numpy","scientific computing","scale","scientific",{"skillNo":213,"name":214,"nameZh":6,"description":215,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":135,"licenseFileUrl":6,"sourceHtmlUrl":216,"categories":217,"keywords":219,"publishedAt":47},"01M6EZZJWFXM1GR78KTW6J0DN8","what-if-oracle","Run structured What-If scenario analysis with multi-branch possibility exploration. Use this skill when the user asks speculative questions like \"what if...\", \"what would happen if...\", \"what are the possibilities\", \"explore scenarios\", \"scenario analysis\", \"possibility space\", \"what could go wrong\", \"best case \u002F worst case\", \"risk analysis\", \"contingency planning\", \"strategic options\", or any question about uncertain futures. Also trigger when the user faces a fork-in-the-road decision, wants to stress-test an idea, or needs to think through consequences before committing.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fwhat-if-oracle\u002FSKILL.md",[218],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[220,221,222,223,224,225,38,226,227,228,229,164,165,230,231,232,233,234,235,236],"oracle","what if oracle","go","run","ux","futures","explore","decision","branch","question","idea","exploration","options","stress-test","strategies","scenario","stress",{"skillNo":238,"name":239,"nameZh":6,"description":240,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":135,"licenseFileUrl":6,"sourceHtmlUrl":241,"categories":242,"keywords":253,"publishedAt":47},"01M6EZZCXAEB49RXGQCJX5E8GB","venue-templates","Access comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.","https:\u002F\u002Fgithub.com\u002Fhenriquescastilho\u002Fmy-claude\u002Fblob\u002Fmain\u002F.codex\u002Fvendor_imports\u002Fclaude\u002Fmarketplaces\u002Fclaude-scientific-skills\u002Fscientific-skills\u002Fvenue-templates\u002FSKILL.md",[243,246,249,250],{"categoryNo":244,"categoryName":245,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":247,"categoryName":248,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000021","资料检索与研究",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":251,"categoryName":252,"taxonomyType":150,"taxonomyTypeDesc":151},"01JBSEEDCAT000000000000036","内容创作者",[254,255,256,257,258,259,260,261,161,262,164,165,166,263,264,265,266,267,211,268],"templates","venue templates","research","guidelines","NeurIPS","ICML","LaTeX","science","access","proposals","Academic","requirements","formatting","journal","chi"]