seven-zip, no relation: the entry count a zip claims, read from its end record
huntress ctf 2026, day 7 · metadata forensics · all three modes
tools used: archive and metadata toolkit and timed-attempt pipeline.
files arrived "inside and beside a collection of zip archives". the prompt talked about counting what the archives claim, telling empty space from evidence, and a census that does not add up. the graded question was narrower: one field per artifact, the total-entries count that a nested zip's end of central directory record declares.
the key insight: the answer is a raw header field, not a listing. a zip's end of central directory (eocd) record states how many entries the archive holds, and that claim can disagree with what the central directory actually contains. the field id names the record and the field the way the question does (zip.eocd_total_entries), which made this a family of answers our tooling could learn to read without hand-written code.
challenge shape
field ids d07-zip-NNN-zip-eocd-total-entries: the stem d07-zip-NNN points at the nested archive evidence-drop-NNN.zip inside the delivered bundle, and the property is the eocd total-entries field. the single asked one field, the time trial one, the mastery one per set across two sets.
artifact anatomy
the end of central directory record sits at the end of every zip, after the central directory, and is found by its signature PK\x05\x06 (searched from the end, since an archive comment may follow it):
offset size field
0 4 signature 50 4b 05 06
4 2 number of this disk
6 2 disk where the central directory starts
8 2 entries on this disk
10 2 total entries
12 4 central directory size
16 4 central directory offset
20 2 comment length
all integers are little-endian. "total entries" is what the archive claims; the real census is the count of PK\x01\x02 central directory records, and the local headers (PK\x03\x04) are a third, independent count.
extraction method
two steps had to change on day 7.
member resolution: the member named by the field is a zip inside the bundle, and earlier days only ever resolved leaf files. the resolver now matches the question's own artifact text (evidence.zip -> evidence-drop-001.zip) against every delivered name, archives included.
the property itself: the eocd field is read straight from the bytes. our reader is one generic getter per eocd field (zip-eocd-<field> over a table of offsets); for total entries it reduces to:
def eocd_total_entries(data: bytes, name: str) -> str:
i = data.rfind(b"PK\x05\x06")
if i < 0:
raise ValueError(f"no zip eocd in {name}")
return str(int.from_bytes(data[i + 10 : i + 12], "little"))
from a shell, zipinfo -h evidence-drop-NNN.zip prints the same claim in its header line ("number of entries"). python's zipfile is the wrong tool for the claim: namelist() is built by walking the central directory records, so it gives the census, not the number the eocd states.
on day 7 we also generalized this: a header-field registry parses the raw headers of gzip, tar, bmp, gif, png, riff (wav/webp), sqlite, id3, zip and pdf into fields named <struct>.<field>, and an unknown property is matched to a parsed field by its words. zip-eocd-total-entries shares eocd, total and entries with eocd.total_entries and nothing else. a test replays the day 5, 6 and 7 fixtures with their hand-written readers removed: all of them solve from the header fields alone. details in the archive and metadata toolkit.
validation and answer formatting
the question read "determine zip.eocd_total_entries for evidence-drop-nnn.zip.", answer kind integer, syntax "base-10 integer with no units, separators, or explanatory text". the signature search takes the last PK\x05\x06, and a member without an eocd raises instead of answering zero.
failed approaches and pivots
- the property was new and has no exiftool tag, so the generic fallback had nothing to match; a reader had to be written while the clock ran. the header-field registry exists so the next new header field does not need one.
- the mastery bundle holds two sets, each with its own nested zips. the delivery layout split the sets and flattened their archives into their contents, so the nested zip the field named was gone and a text file was read instead. each set now keeps every nested zip's own bytes alongside its members.
automation across modes
the same function answered the single, the time trial and both mastery sets; only the stem number changed. the layout fix lets a set refer to an archive by name even when its contents are unpacked next to it.
lessons
- read the field id as structure:
<format>-<record>-<field>maps onto a parsed header. - a question about a container can mean the container's own bytes; keep nested archives addressable, not only their contents.
- "claimed" and "held" are different counts in a zip. the census fields (eocd counts, central directory records, local headers, empty versus non-empty entries, and a mismatch flag) are now readers too.
solve times
public scoreboard · day 7 finish: top 3
- 1:05.7single#8 of 227 solvers
- 1:08.2time trial#5 of 215 solvers
- 2:13.5mastery#10 of 214 solvers
- #3team day finishof 179 teams that cleared it, in 4:44.3
- #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 | 1m02s | 5 | 0 |
| time trial | 3s | 1 | 0 |
| mastery | 1m05s | 3 | 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 | 7.0s | 1.2s | 5.8s |
| mastery | 7.0s | 1.7s | 5.3s |
where we got stuck
- single: the new property crashed the solver (no reader, no exiftool tag) and the nested zip was never chosen as the member. writing both took about a minute.
- mastery: two attempts crashed on the flattened nested archives before the delivery layout kept them; the third attempt won.
flags: single, time trial, and mastery [redacted].
{generated by a clanker}