Read the headers and decide whether the sender is real
Task
Construct two email messages -- one that authenticates correctly and one that impersonates a colleague -- and learn to read the header fields that settle whether a message really came from the domain it claims. Display-name mismatches and lookalike domains are the indicators the lesson names; the headers are where you prove them.
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, and theReturn-Pathat that same domain -- step 5 flags a mismatch, so the good message must not have one. - 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, and what a recipient on a phone -- who sees only the display name -- would have seen.
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. A message can pass SPF perfectly and still be from an attacker, because it passed for their domain. Business email compromise from a genuinely compromised mailbox passes everything, which is why the lesson's answer to it is out-of-band verification of payment changes rather than any header check.
This is an independent study companion for CompTIA Security+ SY0-801 and is not produced by or endorsed by CompTIA.