zig zag: one zig program in an elf and a pe, and a field answered by the section table
huntress ctf 2026, day 10 · binary reverse engineering · all three modes
tools used: binary-analysis toolkit and timed-attempt pipeline.
the prompt: "zig promises one binary for every platform. compare the elf and pe service descriptors side by side and prove they're the same program wearing different uniforms." the new tag, d10, was a stripped zig build: an elf in most deliveries and a pe in one mastery set, each carrying the lane's familiar hcfg configuration blob.
the key insight: 99 of the 100 fields were questions the solver already answered for any native build. the one new field, d10_analysis_has_hcfg_section, asks about the section table, not about the configuration: whether the build keeps its blob in a section of its own. both zig builds did, in a section named .hcfg.
challenge shape
the single asked 100 fields, ten per tag for d01 to d10, over one evidence zip; the time trial asked the same 100 of a fresh zip, the mastery 300 over three. the ten d10 fields:
d10_artifact_sha256_1 exact text sha-256 of the delivered member
d10_analysis_architecture exact text
d10_analysis_format exact text elf or pe
d10_analysis_machine integer
d10_analysis_config_campaign exact text } from the hcfg blob
d10_analysis_config_domain exact text }
d10_analysis_config_mutex exact text }
d10_analysis_config_url exact text }
d10_analysis_config_crc32_hex pattern }
d10_analysis_has_hcfg_section enum true | false
the d10 member was an elf in the single, the time trial and mastery sets 1 and 3, and a pe in mastery set 2. every set had its own configuration values; the "same program" was the same code and the same blob layout, not the same data.
artifact anatomy
both builds are stripped: the elf has no symbol table. each keeps the hcfg blob (the HCFG magic, a version, a one-byte xor key, the length, a crc32 of the plaintext and the xor-encoded json, as described in the toolkit article) in a section of its own:
elf: section header 23 of the table name ".hcfg" type PROGBITS
pe: section 6 of 9 name ".hcfg"
the elf reader finds section names through the section-header string table (e_shstrndx), the pe reader in the eight-byte name field of each IMAGE_SECTION_HEADER. by hand, readelf -SW d10--variant-NNN.elf and objdump -h d10--variant-NNN.exe both list it.
the integer machine answers from each format's own header: e_machine in the elf, the coff Machine in the pe, written in decimal. the architecture label is the same for both, x86-64, the label the lane's grader has accepted before.
extraction method
the solver dispatches on the tag and then on the member's format, as on every day since day 3. the sha-256, format, architecture, machine and the five config fields came out of the day-9 code as they were: the carrier search found the hcfg blob in both formats, and the header readers gave the rest.
has_hcfg_section had no producer, so the solver raised on it. the new producer is not specific to hcfg: any field shaped has_<x>_section asks whether a section named x exists, over every section table the member has.
SECTION_FIELD = re.compile(r"has_(\w+)_section")
def has_section(token: str) -> Callable[[bytes], str]:
field = f"has_{token}_section"
def get(b: bytes) -> str:
names = [n for table in _section_tables(b, field) for n in table]
return "true" if any(token in _section_stems(n) for n in names) else "false"
return get
_section_tables returns the elf section names, the pe section names, one list per slice of a mach-o (fat or thin) and the section names of a webassembly module, and raises for a member with no section table at all (a jar, a dex, an elf whose section headers were removed), so an absent table is never read as an absent section. _section_stems maps a section name to the field token it answers to: a leading . (elf, pe) or __ (mach-o) is removed, case is folded, and a dotted or dashed name becomes snake case (.gnu.hash answers gnu_hash). whole names only: .hcfg_backup does not answer hcfg.
validation and answer formatting
the answer is one of the two values the question's enum lists, true or false, as lowercase text. the config fields are validated as on earlier days: the hcfg blob's crc32 must match before any record is read, and the crc32 field is that value in the question's hex form.
failed approaches and pivots
the field name invited the wrong reading. "has hcfg" sounds like a question about the blob, and every tag's binary carries one; answering from the carrier search would say true wherever the blob sits, in a section of its own or inside read-only data. the name's last word is section, and the section table is the only structure that can answer it. the generic producer above reads that table and nothing else.
a second, quieter miss was in our preparation: the language reader, built for a question that has not been asked yet, read both zig builds as c. our zig markers were symbol names (__zig_probe_stack, std.start.posixCallMainAndExit), and a stripped static build keeps none of them. what it keeps is the standard library's panic and debug strings in read-only data. on day 10 the native reader learned them, with a guard against the sanitizer strings that clang puts into c builds:
ZIG_RODATA = (
b"attempt to unwrap error",
b"sentinel mismatch: expected ",
b"integer cast truncated bits",
b"reached unreachable code",
b"aborting due to recursive panic",
b"Unable to dump stack trace: ",
)
def _zig_rodata(b: bytes) -> bool:
return sum(m in b for m in ZIG_RODATA) >= 2
automation across modes
once the producer existed, the same solver answered every d10 member in all three modes, elf and pe alike, and the cumulative d01 to d09 tags answered as on day 9. the producer is chosen by the field's name pattern, so a later has_<x>_section field for another section needs no new code.
lessons
- read the last word of a field name first:
has_hcfg_sectionis a question about a section, not about hcfg. - an absent table and an absent entry are different answers. a reader asked about sections should raise for a format without a section table, not answer
false. - symbol markers do not survive
strip; runtime strings in read-only data do. require two of them, because toolchains share some strings.
solve times
public scoreboard · day 10 finish: top 3
- 1:02.7single#4 of 193 solvers
- 1:05.8time trialfirst blood, +10.2 s
- 1:10.7masteryfirst blood, +13.2 s
- #2team day finishof 173 teams that cleared it, in 1:40.9
- #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 | 59s | 1 | 0 |
| time trial | 2.9s | 1 | 0 |
| mastery | 7.7s | 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 | 16.0s | 1.7s | 14.3s |
| mastery | 28.0s | 3.5s | 24.5s |
where we got stuck
- single: 99 fields were answered within seconds; the one new field took the rest of the minute. we had the cause (a section named
.hcfgin both formats) within about 35 seconds; confirming the reading and writing the producer into the solver took the rest. after that the time trial and the mastery each took one attempt.
flags: single, time trial, and mastery [redacted].
{generated by a clanker}