elf aware: headers, symbols, sections, and a return constant

huntress ctf 2026, day 1 · binary reverse engineering · all three modes

tools used: binary-analysis toolkit and timed-attempt pipeline.

the archive held a small, unstripped c elf and asked for nine properties. this was less about decompilation than about knowing which layer owns each fact: identification bytes, the main header, section and symbol tables, a custom section, and two instructions of disassembly.

the key insight: most fields are fixed offsets in the header, and the hard part is the exact vocabulary each field expects.

artifact anatomy

the single sample was elf64, little-endian, x86-64, ET_EXEC, with an entry point (0x401030). a .symtab section existed, a custom .huntress string section held a marker (BR01-SYMBOL-ORIENTATION), and one custom global function (recover_code) was the exported symbol the questions asked about.

e_ident offset 4 is the class and offset 5 the byte order. e_type and e_machine are 16-bit values at offsets 16 and 18; e_entry is a 64-bit value at offset 24 for elf64.

extraction method

readelf -hW symbol-orientation.elf
readelf -SW symbol-orientation.elf
readelf -sW symbol-orientation.elf
readelf -p .huntress symbol-orientation.elf
objdump -d symbol-orientation.elf

the parser reads the header itself, using the declared endianness rather than assuming x86:

little = blob[5] == 1
endian = "<" if little else ">"
e_type = struct.unpack_from(endian + "H", blob, 16)[0]
e_machine = struct.unpack_from(endian + "H", blob, 18)[0]
e_entry = struct.unpack_from(endian + "Q", blob, 24)[0]

the exported symbol is a defined global FUNC after removing compiler and runtime names such as _start, main and initialization helpers, which is more robust than the first symbol in nm output. its body disassembles to a move-immediate and ret; the solver scopes its regex to that function and extracts the immediate.

validation and answer formatting

the nine ids were elf_class, endianness, machine, elf_type, marker, has_symtab, exported_symbol, the return-constant field (named after the function whose constant it asks for) and entry_point. most were exact_text ("exact artifact-derived value only ... use the literal none only when the requested field is absent"); has_symtab was an enum of true and false, entry_point a pattern ("lowercase hexadecimal with a 0x prefix"), and the return constant an integer ("base-10 integer with no units, separators, or explanatory text") on the single.

each field follows its own convention: ELF64 (readelf's spelling), x86-64 (the file command's), little, ET_EXEC (the spec constant name), lowercase true/false, the entry point as lowercase 0x hex, and the return value as a decimal string even though objdump prints the immediate in hex. a missing symbol answers none.

failed approaches and pivots

extraction was quick; vocabulary was not. the time trial did not land at first because the return constant's text form was unresolved between hex, decimal and none: in the timed sets that field came either as an integer or as exact_text with the none rule, set by set. the 0x hex form was rejected; decimal was right under both kinds, and none only when the binary has no function of the name the question gives. per-field probes on the untimed specimen settled every convention, and the solver encoded them so timed variants needed no guessing.

automation across modes

mastery rotated its layout on every start: sets times slots (slotM_ field prefixes against slot-M.elf members) times nine fields. the same per-binary function ran for every slot, and one start per attempt kept the material stable.

lessons

solve times

public scoreboard · day 1 finish: below top 10

  • 2h43msingle#63 of 434 solvers
  • 3h03mtime trial#62 of 392 solvers
  • 3h04mmastery#58 of 383 solvers
  • #54team day finishof 358 teams that cleared it, in 3h04m
  • #3single 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 14m36s 1 -
time trial 2s on the clock (prep not logged) 1 logged (earlier tries not recorded) not logged
mastery not recorded 1 -

the clock

server timer of the winning attempt; used is attempt start to flag, left is what remained on the clock. day 1-2 deadlines were not logged per attempt.

mode time available time used time left
time trial not recorded 1.6s not recorded
mastery not recorded not recorded not recorded

where we got stuck

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

{generated by a clanker}