[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ER4P78TPJPR1MY1XG603P1":3,"skill-same:01M6ER4P78TPJPR1MY1XG603P1":91},{"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":23,"publishedAt":44,"linkOnly":45,"markdownContent":46,"markdownBody":47,"frontMatter":48,"refName":52,"commitSha":53,"skillDirectory":54,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6ER4P78TPJPR1MY1XG603P1","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.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fanalyzing-email-headers-for-phishing-investigation\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000005","邮件与沟通","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43],"email","phishing","investigation","analyzing email headers for phishing investigation","analyzing","origin","cybersecurity","emails","trace","analyze","verify","analysis","digital-forensics","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, verify sender authenticity, and identify spoofing through SPF, DKIM, and DMARC validation.\ndomain: cybersecurity\nsubdomain: digital-forensics\ntags: [forensics, email-analysis, phishing, spf, dkim, dmarc, header-analysis]\nversion: \"1.0\"\nauthor: mahipal\nlicense: Apache-2.0\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":30,"license":15,"version":51,"subdomain":36,"description":7},[42,41,25,40,39,38,37],"mahipal","1.0","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fanalyzing-email-headers-for-phishing-investigation",2,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill analyzing-email-headers-for-phishing-investigation",{"tool":66,"command":67},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill analyzing-email-headers-for-phishing-investigation",{"tool":69,"command":70},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill analyzing-email-headers-for-phishing-investigation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fanalyzing-email-headers-for-phishing-investigation\u002FSKILL.md",true,[74,79,85],{"path":75,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":78},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fanalyzing-email-headers-for-phishing-investigation\u002FLICENSE",{"path":80,"resourceType":81,"resourceTypeDesc":82,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Fapi-reference.md","REFERENCE","参考文档",2772,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fanalyzing-email-headers-for-phishing-investigation\u002Freferences\u002Fapi-reference.md",{"path":86,"resourceType":87,"resourceTypeDesc":88,"sizeBytes":89,"sourceHtmlUrl":90},"scripts\u002Fagent.py","SCRIPT","脚本",8576,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fanalyzing-email-headers-for-phishing-investigation\u002Fscripts\u002Fagent.py",[92,120,137,165,194,231],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":96,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":44},"01M6F2SKTE208174C7S7JJCZC7","write-contracts","Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.","MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119],"write","contracts","write contracts","storage","secure","create","generate","collection","model","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":96,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":44},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[127,128,129,130,131,132,133,134,135,136],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":96,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":146,"publishedAt":44},"01M6F2K968G1FZEZFPW2E6B222","solo-build","Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says \"build it\", \"start building\", \"execute plan\", \"implement tasks\", \"ship it\", or references a track ID. Do NOT use for planning (use \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[143],{"categoryNo":144,"categoryName":145,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[147,148,149,150,151,152,153,154,128,155,156,157,100,158,159,160,161,162,163,164],"build","solo","solo build","MCP","workflow","commit","tasks","code","Bash","plan","read","auto","references","context7","query","scaffolding","ship it","project",{"skillNo":166,"name":167,"nameZh":6,"description":168,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":96,"licenseFileUrl":6,"sourceHtmlUrl":169,"categories":170,"keywords":175,"publishedAt":44},"01M6F2GKN39SGHSPWYB3662YC8","react-email","Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[171,172],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":173,"categoryName":174,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[176,24,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,31,192,193],"react","react email","github","editor","components","react components","component","welcome","https","notifications","password","node","use","html","resend","visual","rendering","with",{"skillNo":195,"name":196,"nameZh":6,"description":197,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":96,"licenseFileUrl":6,"sourceHtmlUrl":198,"categories":199,"keywords":212,"publishedAt":44},"01M6F2FBVGVDFSG8SSFJGXA40C","APITester Agent-Driven API Testing","Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[200,203,206,207],{"categoryNo":201,"categoryName":202,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":204,"categoryName":205,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":144,"categoryName":145,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":208,"categoryName":209,"taxonomyType":210,"taxonomyTypeDesc":211},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230],"testing","api","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","endpoints","document","get","define","tests","english","api-tester",{"skillNo":232,"name":233,"nameZh":6,"description":234,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":96,"licenseFileUrl":6,"sourceHtmlUrl":235,"categories":236,"keywords":237,"publishedAt":44},"01M6F273Y3NGAPVJZ608BC0G9G","hubspot-implementation-plan","Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[156,238,239,240,241,242,243,106,244,245,246,247,248,188,249,250,193,251],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]