Read the headers and decide whether the sender is real
Task
Construct two email messages — one that authenticates correctly and one that does not — and learn to read the header fields that settle whether a message really came from the domain it claims.
Steps
- Write
/tmp/good.eml: a plain message withReturn-Path,From,Receivedand anAuthentication-Resultsheader showingspf=pass dkim=pass dmarc=passwith the domain inheader.frommatching the SPF domain. - Write
/tmp/spoof.eml: the same message, but with aFromdisplay name of a real-looking colleague, aFromaddress at a lookalike domain, andAuthentication-Resultsshowingspf=passfor the LOOKALIKE domain withdmarc=failfor the displayed one. - Write
/tmp/parse.sh: a script that takes an.emlfile and prints theFromdomain, theReturn-Pathdomain, and each of the spf, dkim and dmarc results. - Run it against both files and note which single field distinguishes them.
- Add to the script a verdict line: it must print
SUSPECTwhen dmarc does not pass or when theFromandReturn-Pathdomains differ. - Record in
/tmp/headers.mdwhyspf=passalone is not evidence the message is from who it appears to be from.
Verify
bash /tmp/parse.sh /tmp/good.eml | grep -ci "suspect"
bash /tmp/parse.sh /tmp/spoof.eml | grep -ci "suspect"
grep -icE "envelope|return-path|alignment|header.from" /tmp/headers.md
The first must be 0 and the second must be at least 1 — the script passes the legitimate message and flags the spoof. A script that flags both is not discriminating, and one that flags neither has not implemented the verdict. The third confirms you wrote down the reason: SPF validates the envelope sender, and only DMARC requires alignment with the From: address the recipient actually sees.
Notes
This is the single most useful five minutes of analysis in a phishing triage, and it is why the Domain 4 lesson makes so much of DMARC alignment. A message can pass SPF perfectly and still be from an attacker, because it passed for their domain.
This is an independent study companion for CompTIA Security+ SY0-701 and is not produced by or endorsed by CompTIA.