#!/usr/bin/env python3 """CodeShell.kr — Relay (Misc, 50p) solver. The .eml body is empty; the payload is the 2-letter `with SMTP id` of each Received header. Received headers are listed newest-first, so reading them oldest-first spells the answer. Usage: uv run python solvers/relay.py """
import email import re from pathlib import Path
EML = "assets/challenge-files/misc-relay.eml"
defmain(): msg = email.message_from_bytes(Path(EML).read_bytes()) ids = [re.search(r"with SMTP id ([A-Za-z0-9]+)", v).group(1) for v in msg.get_all("Received", [])] print("received top-down", ids) print("oldest-first ", "".join(reversed(ids)))