1. Workflow (do it in this order, every time)

  1. Integrity first: check the hash of the delivered file (md5sum c7-email.zip / sha256sum), compare with the given value, and note it in the report.
  2. Open the raw file in a text editor (never only a mail client). Note the top-level Content-Type.
  3. Overview: From, To, Cc, Reply-To, Return-Path, Subject, Date, Message-ID.
  4. Routing: read Received: headers bottom to top. Per hop write down: FQDN, IP, protocol (with ...), timestamp.
  5. Trust boundary: only headers added by servers you trust (your own provider, topmost block) are reliable. Everything below can be forged.
  6. Authentication: Authentication-Results, Received-SPF, DKIM-Signature, ARC-*. Check alignment of From domain, Return-Path domain and DKIM d=.
  7. Who owns the IPs? WHOIS / AS lookup per hop (country, owner). This is the evidence for “where is the server”.
  8. Encryption: E2E (MIME structure), transit (ESMTPS, TLS version/cipher), at rest (only provider claims, e.g. vendor headers).
  9. Body/attachments: decode, list real URLs, hash attachments, never open outside an isolated VM.
  10. Report: for every claim give header line + source, plus the command/tool used. No “probably” without evidence.

Quick grep set:

grep -n -i -E "^(Received|Authentication-Results|Received-SPF|DKIM-Signature|ARC-|X-|Return-Path|From:|To:|Reply-To|Message-ID|Date:|Content-Type|Content-Transfer)" mail.eml | cut -c1-160

2. EML structure

An .eml is plain text (RFC 5322): headers, one blank line, then the body. Long headers are folded: continuation lines start with a space or tab.

Header-Name: value
Header-Name: value
                          <- blank line = end of headers
body (possibly MIME multipart)

MIME basics

HeaderMeaning
MIME-Version: 1.0MIME is used
Content-TypeType of the (part of the) body, may carry boundary= and charset=
Content-Transfer-Encoding7bit, 8bit, base64, quoted-printable. An encoding, not encryption.
Content-Dispositioninline or attachment; filename=...
Content-IDReferenced from HTML as cid:... (embedded images)

Common MIME types

TypeWhat it means
text/plain, text/htmlReadable body (HTML is where links and tricks live)
multipart/alternativeSame content in several forms (plain + HTML)
multipart/mixedBody + attachments
multipart/relatedHTML + embedded resources (inline images)
multipart/signedSigned only (S/MIME application/pkcs7-signature, PGP application/pgp-signature)
multipart/encryptedPGP/MIME encrypted (application/pgp-encrypted)
application/pkcs7-mime; smime-type=enveloped-dataS/MIME encrypted (.p7m)
application/octet-stream, application/zip, message/rfc822Binary, archive, or an attached email

Decode a base64 part:

base64 -d part.txt > part.html
# or with Python: msg.get_body(preferencelist=("html","plain")).get_content()

Boundary logic: parts are separated by --boundary, the end is --boundary--.


3. Header elements

Address headers (two levels)

LevelFieldsNotes
Envelope (SMTP)Return-Path (MAIL FROM), Received ... for <rcpt>What servers really used; bounces go to Return-Path
DisplayFrom, To, Cc, Reply-To, SenderFreely settable. Bcc never appears.

Mismatch between From, Return-Path, Reply-To and DKIM d= is a classic indicator.

Received: anatomy

Received: from HELO-name (rDNS-name [IP])
        by receiving-server (software) with PROTOCOL id QUEUEID
        for <envelope-rcpt>; Date
  • Each server prepends one. Bottom = first hop, top = last hop.
  • from: sender side. The HELO name is self-declared (forgeable). The IP in [ ] is observed by the receiver.
  • by: the server that wrote this line.
  • Chain check: by of one hop should match from of the hop above it.
  • Check timestamps increase plausibly (time zones differ per server, convert to UTC).

with protocol values

ValueMeaning
SMTPPlain SMTP
ESMTPExtended SMTP (no TLS logged)
ESMTPSESMTP with TLS
ESMTPAESMTP with authentication (submission)
ESMTPSATLS and authentication (typical first hop from a client)
LMTPLocal delivery to a mailbox, usually last internal hop, often not TLS
HTTP / HTTPSSubmitted via webmail/API

ESMTP without S does not prove plaintext, only that no TLS was logged.

Other useful headers

HeaderWhy it matters
Message-IDDomain part should fit the sending infrastructure
X-Originating-IPClient IP (if present, often stripped)
X-Mailer / User-AgentSoftware used. Shows the mailer, not the server location.
X-ReceivedGoogle internal hops, rarely useful for attribution
X-Sieve, X-Sieve-Redirected-FromSieve (Dovecot Pigeonhole) filter ran. The second header indicates a redirect rule forwarded the mail (value is probably the original mailbox). Typical reason for “mail arrived at the wrong recipient”.
Delivered-To, X-Original-ToFinal or original recipient as seen by the MTA
X-Pm-* (Proton)e.g. X-Pm-Content-Encryption: on-delivery (my reading: Proton encrypts at rest on delivery, verify), X-Pm-Transfer-Encryption (TLS info)
X-MS-Exchange-*, X-Microsoft-AntispamMicrosoft 365 internals and spam scoring
X-Spam-*Spam scoring by the receiving side
List-UnsubscribeMass mailing indicator

Only trust vendor headers that sit in the topmost block, written by your own provider.


4. SPF, DKIM, DMARC, ARC and others

Where each acts

Sender client -> sender's outbound server -> internet -> receiver's inbound server -> mailbox
                 signs DKIM                              checks SPF/DKIM/DMARC,
                                                         writes Authentication-Results, ARC-*

SPF (RFC 7208)

  • Question: Is the connecting IP allowed to send for the envelope domain?
  • Checked against Return-Path (MAIL FROM) domain, or HELO.
  • DNS: dig +short TXT domain.tld -> v=spf1 include:... ip4:... -all
  • Results: pass, fail, softfail (~all), neutral, none, temperror, permerror
  • Look for: Received-SPF: or spf=... smtp.mailfrom=... in Authentication-Results.
  • Breaks on forwarding (the forwarder’s IP is not authorised).

DKIM (RFC 6376)

  • Question: Was the message signed by the domain and not altered?
  • Header DKIM-Signature:
TagMeaning
v=1Version
a=Algorithm (rsa-sha256, ed25519-sha256)
d=Signing domain
s=Selector (names the DNS key)
h=Signed headers (should contain From)
bh=Body hash
b=Signature
c=Canonicalization (relaxed/relaxed, simple/simple)
t=Signing time (Unix epoch seconds)
x=Expiry time (epoch seconds, optional)
  • Public key: dig +short TXT <selector>._domainkey.<d>
  • Selector names often hint at the provider (e.g. zmail, google, selector1).
  • Survives forwarding if the message is unmodified. Mailing lists that modify subject/body break it.
  • Full verification: dkimverify < mail.eml (from the dkimpy package, from memory).

DMARC (RFC 7489)

  • Question: Do SPF or DKIM pass and align with the visible From: domain? What should the receiver do if not?
  • DNS: dig +short TXT _dmarc.domain.tld
  • Tags: p= policy (none/quarantine/reject), sp= subdomain policy (inherits p= if absent), rua=/ruf= reports, pct= percentage, adkim=/aspf= (r relaxed, s strict).
  • Pass = (SPF pass and aligned) or (DKIM pass and aligned).
  • A lookalike domain can pass all three. A pass proves authorisation by that domain, not honesty.

ARC (RFC 8617)

  • For forwarders and mailing lists: preserves the original auth results.
  • Three headers per instance i=1,2,...: ARC-Authentication-Results, ARC-Message-Signature, ARC-Seal (with cv=).
  • cv=none at i=1, cv=pass afterwards, cv=fail = broken chain. Instances must be gap-free.
  • Only meaningful if you trust the sealing domains.

Others

StandardWhereNotes
S/MIMEmultipart/signed; protocol="application/pkcs7-signature", smime.p7sCheck signer certificate, chain, and that cert email matches From. openssl cms / openssl smime -verify (check flags for your version)
PGPmultipart/signed; protocol="application/pgp-signature" or -----BEGIN PGP ...-----Check key ID/fingerprint
BIMIBIMI-Selector, BIMI-LocationLogo display, only meaningful with enforced DMARC
MTA-STS / DANE / TLS-RPTDNS onlyForce TLS between domains, not visible in the .eml
AutocryptAutocrypt:Only advertises a public key, does not mean encrypted

Reading Authentication-Results

Authentication-Results: mx.receiver.tld;
  spf=pass smtp.mailfrom=sender.tld;
  dkim=pass header.d=sender.tld header.s=sel1;
  dmarc=pass header.from=sender.tld

Use the topmost one added by your own provider. No auth headers at all = unverified, not clean.


5. Encryption: the three questions

QuestionVisible in the .eml?Where to look
1. End-to-end (sender to receiver)YesTop-level Content-Type: multipart/encrypted or pkcs7-mime enveloped-data = encrypted. Readable text/html + base64 = not E2E. multipart/signed = signed only.
2. In transit between MTAsPartlywith ESMTPS, version=TLSv1.x cipher=... per Received. Name the TLS version and cipher. Hops without S: “not documented”.
3. At rest on each MTANo (only provider claims)Possibly a vendor header on the last hop (e.g. Proton X-Pm-Content-Encryption). All other MTAs: unknown.

Pitfalls:

  • Base64 is not encryption.
  • A client can export an .eml after decrypting, so check that the Received chain is still there.
  • TLS protects only the link, every MTA can read the content.
  • Say “not determinable” instead of “not encrypted” when the file has no evidence.

6. Where is the server? (evidence for “outside Switzerland” type tasks)

  1. Take the IP from the sending hop’s [ ], not the HELO name.
  2. Look up the owner: WHOIS / AS lookup (e.g. whois <ip>, dig +short -x <ip>, or a site such as bgp.he.net, networksdb.io).
  3. Collect corroboration: DKIM d=/s=, ARC sealing domain, SPF include:, MX records of the domain, Message-ID domain.
  4. Mention time: DNS/hosting can change, so state when the evidence applies (e.g. date in the mail vs. today).
  5. Write: IP -> range -> AS number -> owner -> country. No “probably”.

7. Common attacks and disguises

Header level

TrickHow to spot it
Spoofed From:SPF/DKIM/DMARC fail or misaligned, Return-Path/Reply-To differ
Display-name spoofing"CEO Name" <random@freemail.tld>: check the real address
Lookalike domain / homographpaypa1.com, rn vs m, IDN/punycode (xn--...)
Forged Received: linesSit below the trust boundary, rDNS/IP don’t match, by/from chain breaks, impossible timestamps, hop IP owned by an unrelated network
Forged Authentication-Results or vendor headers (X-Spam-Status: No)Appear below your own provider’s headers, or the authserv-id isn’t your provider
Fake X-Sieve-Redirected-From / X-Pm-*Same: outside the topmost trusted block
Wrong clock / date gamesDate years off, hops with inconsistent time zones: re-injection, restored archive, broken NTP, or forged
Reply-To hijackReply goes to the attacker although From looks legit
Thread hijackingReal conversation (In-Reply-To, References) taken over from a compromised mailbox
Open relay / compromised accountPasses SPF/DKIM from a legit server, but content and behaviour are abnormal

Body / HTML level

TrickNotes
Link text != hrefCompare visible text with the real URL in the HTML source
Open redirectTrusted domain https://good.tld/redirect?url=evil as a decoy
URL shorteners / tracking linksHide the target, abused newsletter links
Fragment parameters (#?act=...)Part after # is never sent to the server, read by client-side JS
HTML smugglingJavaScript builds the payload in the browser, no file for the gateway to scan
HTML forms in mail (<form>, <input>, <select>, hidden fields)Data posted to an attacker server. Some clients block it, some don’t. Look at action=.
Hidden text / zero-size, white-on-whitePushes spam filters off, hides filler text (often junk “verification code” text)
Tracking pixel / remote image1x1 image confirms the address is live and leaks IP, user agent, time
cid: / inline imagesText rendered as an image to dodge text filters (QR code phishing)
Look-alike hosting on trusted platformsS3, SharePoint, Google Drive, Dropbox, Cloudflare Workers: domain reputation is high
<base href>, <meta refresh>, JavaScriptRedirects and rewrites links

Attachments

  • Macro Office files, ISO/IMG/ZIP containers (can bypass Mark-of-the-Web), password-protected ZIP (password in the mail body), double extensions (invoice.pdf.exe), .lnk, .html, .svg, .iso.
  • Hash them: sha256sum file, then look up the hash (VirusTotal etc.). Analyse only in an isolated VM.

Social engineering patterns

Urgency/authority (invoice, delivery, locked account), BEC/CEO fraud, thread hijacking, fake “verification code” or “registration confirmation”.

MITRE ATT&CK (recalled, verify IDs in your ATT&CK version)

T1566 (.001 attachment, .002 link, .003 via service), T1598 phishing for information, T1027 obfuscated files (HTML smuggling).


8. Bash: timestamps and UTC

DKIM t= and x= are Unix epoch seconds (UTC).

# GNU date (Linux): epoch -> UTC
date -u -d @1700000000
date -u -d @1700000000 +"%Y-%m-%dT%H:%M:%SZ"

# macOS / BSD date
date -u -r 1700000000

# Extract t= from a DKIM-Signature in a file and convert (GNU grep/date)
t=$(grep -m1 -i -A5 '^DKIM-Signature' mail.eml | grep -o -E '\bt=[0-9]+' | head -1 | cut -d= -f2)
date -u -d @"$t" +"%Y-%m-%d %H:%M:%S UTC"

# Same for expiry x=
x=$(grep -m1 -i -A5 '^DKIM-Signature' mail.eml | grep -o -E '\bx=[0-9]+' | head -1 | cut -d= -f2)
date -u -d @"$x" +"%Y-%m-%d %H:%M:%S UTC"

Received/Date header (with time zone) -> UTC:

date -u -d "Mon, 26 Oct 2026 12:30:00 -0700"
date -u -d "Sat, 24 Oct 2026 16:40:12 +0200" +"%Y-%m-%dT%H:%M:%SZ"

UTC -> epoch (to compare with t=):

date -u -d "2026-10-24 14:40:12" +%s

Difference between DKIM signing time and a Received time (seconds):

echo $(( $(date -u -d "Sat, 24 Oct 2026 16:40:12 +0200" +%s) - 1761316800 ))

Python (works everywhere, standard library):

from datetime import datetime, timezone
from email.utils import parsedate_to_datetime

print(datetime.fromtimestamp(1700000000, tz=timezone.utc))            # DKIM t=
print(parsedate_to_datetime("Sat, 24 Oct 2026 16:40:12 +0200")
      .astimezone(timezone.utc))                                      # Received/Date -> UTC

Sanity checks: t= should be before (or shortly before) the first Received time. A signing time after delivery, or far in the past or future, is suspicious or points to a wrong clock.


9. Handy commands

# Hashes
md5sum file.zip ; sha256sum file.zip
# DNS
dig +short TXT domain.tld                      # SPF
dig +short TXT _dmarc.domain.tld               # DMARC
dig +short TXT <selector>._domainkey.domain.tld  # DKIM key
dig +short MX domain.tld
dig +short -x 203.0.113.25                     # reverse DNS
whois 203.0.113.25                             # IP owner
# Parse headers with Python
python3 -c "import email,email.policy as p;m=email.message_from_binary_file(open('mail.eml','rb'),policy=p.default);[print(' '.join(str(r).split()),'\n') for r in m.get_all('Received',[])]"
# Attachments
ripmime -i mail.eml -d out/        # or munpack
# S/MIME
openssl smime -verify -in mail.eml -noverify

10. Report template (per task)

  1. Claim (one sentence, no hedging)
  2. Evidence (exact header line, line number)
  3. Source / tool (command or URL, date accessed)
  4. Limits (what the file cannot prove)

Before submitting: title matches the task, file hash documented, each hop listed with FQDN + IP + protocol, every “outside country X” claim backed by an IP owner lookup.