built different: the coff machine field, then every header field by name

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

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

the prompt: "a software drop contains executables for several architectures, plus decoys wearing executable extensions. determine what can actually run where." the bundle was day 8's (an evidence note, a jpeg, a png, a pdf and a nested zip) plus a windows executable, and one property was new: pe-coff-machine-u16-hex.

the key insight: "what can run where" is one header field. a pe image names the cpu it was built for in the coff file header's Machine field, and the loader refuses an image built for an instruction set the host cannot execute. that header sits where the file says it does, so the field is read by following a pointer, never at a fixed offset and never by trusting the extension.

challenge shape

thirteen fields of the form <member stem>-<property>. twelve repeated earlier days: the evidence note's filename, size, md5, sha-1, sha-256, first sixteen bytes and utf-8 bom flag, the jpeg start-of-frame and png IHDR dimensions, the pdf header version, and the nested zip's eocd entry count and central-directory names. the thirteenth, d09-pe-NNN-pe-coff-machine-u16-hex, asked "determine pe.coff_machine_u16_hex" for the executable, with the syntax "lowercase hexadecimal with a 0x prefix and no explanatory text". the time trial asked the same thirteen fields of a fresh bundle, and the mastery asked them of five bundles under one timer, 65 fields in all.

artifact anatomy

a pe file starts with a dos header. its last field, e_lfanew at 0x3c, is the file offset of the nt headers: the four-byte signature PE\0\0, the 20-byte coff file header, then the optional header.

offset          size  field
0x00            2     e_magic "MZ"
0x3c            4     e_lfanew: file offset of the nt headers
e_lfanew        4     signature "PE\0\0"
e_lfanew + 4    2     Machine
e_lfanew + 6    2     NumberOfSections
e_lfanew + 8    4     TimeDateStamp
e_lfanew + 20   2     SizeOfOptionalHeader
e_lfanew + 22   2     Characteristics
e_lfanew + 24   ...   optional header (magic 0x10b pe32, 0x20b pe32+)

every field is little-endian. Machine is a 16-bit constant from the pe/coff specification's IMAGE_FILE_MACHINE_* table, one value per instruction set. the dos stub (and, from microsoft linkers, the rich header) sits between the dos header and the nt headers, so the gap differs by toolchain: a reader that expects PE\0\0 at a fixed position misreads the next compiler's output.

the property name is a specification in its own right: family, struct, field, width and output form, here the coff Machine field as an unsigned 16-bit value written in hex.

extraction method

the read follows the chain and checks both signatures, so a file that only wears the extension fails instead of producing a number:

def coff_machine(data: bytes) -> int:
    if not data.startswith(b"MZ"):
        raise ValueError("not a pe: no MZ")
    at = int.from_bytes(data[0x3C:0x40], "little")
    if data[at : at + 4] != b"PE\x00\x00":
        raise ValueError("not a pe: no PE signature at e_lfanew")
    return int.from_bytes(data[at + 4 : at + 6], "little")

that was the whole reader at first. on day 9 we replaced it with a resolver that parses any <family>-<struct>-<field>-<width>-<format> name against tables of 23 header structs (pe, elf, mach-o, gzip, png, jpeg, zip, pdf, bmp, gif, wav). family, struct and field must each be a name the tables know, and the width must be the field's own; the toolkit article has the details.

validation and answer formatting

the two signature checks are the validation: MZ at offset zero and PE\0\0 where e_lfanew points. the declared width is a second check. u16 matches the coff Machine field; a name asking for u32 would describe a different field or a misread one, and the resolver raises instead of reading four bytes.

the syntax fixes the prefix and the case. the padding comes from the width: a u16 in hex is four digits, so the value is zero-padded to two digits per byte rather than printed with hex(), which drops leading zeros:

value, size = values.pop()          # the field's value and its width in bytes
if ref.fmt == "hex":
    return f"0x{value:0{2 * size}x}"

our answer was 0x014c in every mode: the single, the time trial and all five mastery bundles.

failed approaches and pivots

the property had no registry entry, and both fallbacks refused it, which was the right outcome.

the solver stopped with an error naming the property. the tail u16-hex is a type signature to check against the bytes, not vocabulary to match against tag names; that is the idea behind the resolver.

automation across modes

the hand-read rule became the property's reader in the solver, so the time trial and every mastery set read their own executable from their own bytes; each bundle carried a different build. the time trial solved its thirteen fields in 3ms, the mastery its 65 in 20ms.

the prompt promised several architectures and decoys, and the resolver covers that shape without new code: elf-header-e-machine-u16-hex reads elf e_machine in the byte order e_ident declares, mach-o-header-cputype-u32-hex reads the mach-o cpu type, and a gzip renamed to .exe fails the MZ check with an error instead of yielding a machine. none of our bundles held a decoy.

lessons

solve times

public scoreboard · day 9 finish: top 10

  • 0:26.7single#2 of 213 solvers
  • 1:02.9time trial#3 of 204 solvers
  • 1:04.9mastery#2 of 202 solvers
  • #7team day finishof 173 teams that cleared it, in 4:18.7
  • #4single 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 when we started working on the mode to its flag.

mode work to flag attempts wrong submits
single 23s 1 0
time trial 28s 1 0
mastery 30s 1 0

the clock

server timer of the winning attempt; used is attempt start to flag, left is what remained on the clock.

mode time available time used time left
time trial 6.0s 0.5s 5.5s
mastery 7.0s 0.7s 6.3s

where we got stuck

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

{generated by a clanker}