looks can be deceiving: magic bytes over file extensions

huntress ctf 2026, day 2 · metadata forensics · all three modes

tools used: archive and metadata toolkit and timed-attempt pipeline.

the task asked for the first 16 bytes of a named archive member as lowercase hexadecimal. the file extension was intentionally untrustworthy.

the key insight: names are claims, magic bytes are evidence. read the delivered member's bytes, never its label and never the containing zip.

challenge shape

one field per member, <stem>-magic-prefix-hex-16. the stem and the archive layout could rotate between attempts; questions sometimes named the member as archive.zip -> member.ext.

artifact anatomy

the single-solve member began with sixteen printable ascii bytes rather than a known magic number, which is exactly why its extension could not be trusted.

extraction method

xxd -p -l 16 <member>
def magic_hex(data: bytes, length: int = 16) -> str:
    return data[:length].hex()

member resolution, in order:

  1. the exact basename named by the question;
  2. the exact member stem parsed from the answer id;
  3. a constrained fallback only when one member can satisfy the field.

validation and answer formatting

exactly 32 lowercase hex characters, no 0x, no spaces or separators. bytes.hex() already produces that form. the question asked "what are the first sixteen bytes as lowercase hexadecimal?" with the syntax "exact 32 hexadecimal characters representing the first 16 bytes; use no 0x prefix or spaces". its normalization was trim, where day 1's digests were case_insensitive, so the lowercase in the question is binding.

failed approaches and pivots

most failures were member selection, not hex. a mastery retry returned new answer ids alongside the previous assignment's question objects; trusting the question text would have read the wrong members. answer ids became authoritative, questions only a hint.

automation across modes

the property is parsed from the field (magic-prefix-hex-N, any N) and goes through the same dispatch as day 1's filename, size and digests. longest-suffix matching keeps stems that contain words such as text or sha from being split in the wrong place. mastery arrived either as per-set downloads or as one bundle whose member names carried set markers; set splitting handled both before the parser ran.

lessons

solve times

public scoreboard · day 2 finish: top 3

  • 9:06.2single#30 of 386 solvers
  • 10:43.4time trial#27 of 358 solvers
  • 14:37.3mastery#33 of 352 solvers
  • #2team day finishof 264 teams that cleared it, in 18:47.6
  • #2single orderof the day's 5, by our flag time

from the public scoreboard: 09:00 et release to our flag; the table below counts from our attempt's start.

from our first start of the mode to its flag; earlier preparation was not recorded.

mode work to flag attempts wrong submits
single 57s 1 -
time trial 5s on the clock (prep not logged) 1 -
mastery 29s on the clock (prep not logged) 1 -

the clock

server timer of the winning attempt; used is attempt start to flag, left is what remained on the clock. \* timer length from our notes; the attempt's deadline was not recorded. day 1-2 deadlines were not logged per attempt.

mode time available time used time left
time trial 30.0s* 5.0s 25.0s*
mastery not recorded 29.1s not recorded

where we got stuck

flags: single, time trial, and mastery [redacted].

{generated by a clanker}