Skip to content

Lesson 10 of 14 · 22m

Dissecting a Phishing EML

Safe analysis of a suspicious message: extract From vs display name, Reply-To, lookalike domains, URLs, and attachment hashes from the raw .eml without ever rendering it.

What Actually Happens

A suspicious message lands. The wrong move — the one everyone makes first — is opening it in a mail client. Remote images phone home (confirming the address is live), links are one slip from clicked, attachments are a habit away from executed. The right move: get the raw .eml — "Show Original" in Gmail, "Download" in most clients — and dissect it as text. Python's email module parses it without rendering anything; emlAnalyzer and mailparser do the same with nicer output.

from email import policy
from email.parser import BytesParser
msg = BytesParser(policy=policy.default).parse(open('phish.eml','rb'))
print(msg['From'], '|', msg['Reply-To'], '|', msg['Return-Path'])

The Field Order

From. Parse the addr-spec, not the display name. From: "IT Helpdesk" <helpdesk@sud0security.com> — the name says one thing, the address another. Then inspect the domain itself: homoglyphs (sud0security, sudosecurty, sudosecuity), subdomain wrapping (sudosecurity.org.evil.co — the registered domain is evil.co), and punycode. xn--80ak6aa92e.com decodes to аррӏе.com rendered with Cyrillic homoglyphs — Xudong Zheng's April 2017 Apple IDN demonstration is still the reference for how cleanly this renders in browsers and mail clients alike. Mobile clients make it worse: they crop the address and show only the display name, so the field-level check has to happen in the raw source, not the rendered UI.

Reply-To. If present and pointing somewhere else — a freemail address under a corporate display name — the message is telling you the replies go to the attacker. BEC runs on this: From: "CEO" <ceo@yourcompany.example> with Reply-To: ceo@yourcompany.example.evil.net. Your client replies to Reply-To; the From header never mattered.

Return-Path / Received. Covered in the previous lesson: envelope domain vs From:, and the boundary Received: for the true origin IP. Check the origin IP against blocklists and the envelope's SPF.

URLs. Extract every href (a quick re.findall(r'href="([^"]+)"', eml_text) gets most of them), then defang before pasting anywhere: hxxp://, [.] for dots. Don't resolve them from your analysis box through a resolver you care about — check the registered domain (rightmost two labels, watch for co.uk-style public suffixes), then decide. QR-code phishing ("quishing") routes around URL extractors entirely — the image is the payload and it only resolves on your phone's camera, which is precisely why it works: your URL scanner never sees it and your personal phone has no corporate protection.

Attachments. Never open. sha256sum the file, query the hash against VirusTotal/any.run. .html attachments are credential-harvesters that open locally — no URL to scan, no remote fetch; .iso/.zip chains are loader delivery. Message-ID: host part is worth a glance — it often names the sending platform, and @mailgun.com on a message claiming to be from your bank is a complete answer.

Evidence

The FBI's IC3 puts BEC at $2.9 billion in reported losses for 2023, $55 billion cumulative since 2013. The modal BEC is not malware — it is a reply-thread hijack or a lookalike-domain invoice asking for a wire change, which is exactly why the field-by-field routine above catches it: every one of those messages fails at Reply-To, domain, or envelope alignment. The thread hijack deserves naming specifically: an attacker inside a vendor's mailbox replies to a real ongoing thread with new payment details, so the headers, the history, and the participants are all genuine — only the account numbers are new. Field checks catch spoofs; the only defense against a hijacked thread is out-of-band verification of payment changes, which is a policy, not a parser.

Correct Practice

Pull the .eml, parse don't render, work the fields in order, defang every URL, hash every attachment. When it's confirmed phish: report to the sending provider's abuse@ (RFC 2142 requires the address to exist), submit to Google's phishing report or M365's report path, then delete. Never click "to verify," never reply "to test."

Keep reading

Related articles from the SudoSecurity blog.