Day 19 - Jack in the Box (binary-reverse-engineering)
- GM id:
binary-reverse-engineering-day-19-static-unpacking - Lane: binary-reverse-engineering | Agent: agent-2 | Date: 2026-10-19
- Prompt: "There's a payload hiding inside this binary, and a little decoder stub wound up to pop it out. Find the stub, watch it work, and catch what's inside - statically."
Result - all three modes CORRECT
| Mode | Fields | Result | Time | Flag |
|---|---|---|---|---|
| Single Solve | 228 | CORRECT | 137.2 s | Token508c337ce227bc34d36ce6931acb377f |
| Time Trial | 228 | CORRECT | 7.1 s | Token6bf12b4873775f60d3422c9f6d577d86 |
| Mastery | 1140 (5 sets) | CORRECT, hall_of_fame_eligible | 28.4 s | Tokendf7f927e86882b37dd1948db6b9723cf |
Solved by the team solver. Mastery ran as a RANKED attempt inside a 324 s server window (deadline 2026-10-19T13:27:34.585Z) and answered 1140 fields in 15.3 s with 0 probes and 0 unknowns.
Artifact
artifact_0.bin (challenge artifact, not published) - a 32,838,781-byte AES ZIP (password infected), the lane's cumulative evidence bundle: 22 members, d01--variant-000.elf (challenge artifact, not published) through d19--variant-000.elf (challenge artifact, not published) (16 ELF, 2 JAR, 2 WASM, 1 .NET DLL, 1 runtimeconfig.json). 216 of the 228 answer ids are the inventory questions Days 1-18 already established; the 12 new ones are the d19_* slots.
Today's deliverable: d19--variant-000.elf (challenge artifact, not published), 11,232 bytes, ET_EXEC x86-64 ELF64, SHA-256 cf82c07ef9325c0a7012dd43e49182664513d57fa46eac312d26e98dc2231fbe.
The new layer: a packed overlay, not a section
Every earlier day hid the HCFG config record inside the file - raw in .hcfg, base64 in .rodata, a C const array, a wasm data segment. Day 19 does not: grep -c HCFG on the member is 0, and the section-header table ends at file offset 0x2378 while the member is 11,232 bytes long. The record lives in an overlay appended after the end of the real ELF, which is exactly what "a payload hiding inside this binary, and a little decoder stub wound up to pop it out" means, and why the questions ask for an overlay offset and size for the first time (d19_analysis_overlay_offset, d19_analysis_overlay_size - two brand-new question keys).
The GM states the stub layout in the question text, so nothing had to be hand-traced out of the .text disassembly. At the final occurrence of the magic (PK19 for Day 19, and the question names RS20 for Day 20 - so the magic is data, not a constant):
+0 magic 'PK19' (4 bytes)
+5 k1 u8
+6 k2 u8
+8 packed_len u32 little-endian
+12 sha256 32 bytes - SHA-256 of the UNPACKED bytes
+44 packed bytes packed_len bytes, running to EOF
Unpack transform, per packed byte:
plain = ror8(packed ^ k2, 3) ^ k1 ror8(x,3) = ((x >> 3) | (x << 5)) & 0xFF
The unpacked buffer then carries the familiar HCFG record at offset 0: 'HCFG' | version u8 | xor_key u8 | payload_len u16le | crc32 u32le | payload, payload XORed with the one-byte key and parsed as UTF-8 JSON.
Measured on the real member
member length : 11232
overlay_offset : 10808 (single occurrence of 'PK19')
overlay_size : 424 = 11232 - 10808 = 44 header + 380 packed
k1, k2 : 0x21, 0xa4
packed_len : 380
SHA-256 of unpacked bytes verified : True
HCFG version : 1
HCFG xor key : 0x91
HCFG crc32 : 0xd02e2211 verified : True
Both integrity checks pass - the overlay's embedded SHA-256 and the HCFG CRC32 - so the extraction is proved, not guessed.
Recovered config (decoded HCFG JSON)
{
"campaign": "BR19-000",
"domain": "node-000.day19.example.invalid",
"host_model": "workstation",
"ipv4": "198.51.100.110",
"linux_path": "/var/tmp/huntress-lab/day19/BR19-000.dat",
"mutex": "Global\\HuntressBR19_000",
"service": "HuntressLab-Day19-000",
"url": "https://node-000.day19.example.invalid/api/BR19-000",
"windows_path": "C:\\ProgramData\\HuntressLab\\day19\\BR19-000.dat"
}
The 12 d19 answers (Single Solve)
| answer id | value |
|---|---|
d19_artifact_sha256_1 | cf82c07ef9325c0a7012dd43e49182664513d57fa46eac312d26e98dc2231fbe |
d19_analysis_format | elf |
d19_analysis_architecture | x86-64 |
d19_analysis_machine | x86-64 |
d19_analysis_overlay_offset | 10808 |
d19_analysis_overlay_size | 424 |
d19_analysis_hcfg_version | 1 |
d19_analysis_config_crc32_hex | 0xd02e2211 |
d19_analysis_config_campaign | BR19-000 |
d19_analysis_config_domain | node-000.day19.example.invalid |
d19_analysis_config_mutex | Global\HuntressBR19_000 |
d19_analysis_config_url | https://node-000.day19.example.invalid/api/BR19-000 |
What was built
challenges/_lib/autosolve_binary.py (the lane spine was not rebuilt - only the new layer added):
_ror8,_overlay_unpack,_overlay- find the final 4-byte[A-Z]{2}[0-9]{2}magic whose declared length ends exactly at EOF and whose embedded SHA-256 verifies, and return the unpacked bytes. The magic is read from the member, so Day 20'sRS20needs no code change.config()- after collecting the container's blobs, each blob's verified overlay is unpacked and appended as one more HCFG carrier. The existing_pick_hcfguniqueness rule still applies, so a second distinct carrier would Hold rather than guess. The d19 member has exactly one.answer()-analysis_overlay_offset/analysis_overlay_sizeresolve from_overlayand Hold (never guess) when no SHA-256-verified stub exists.
Supporting files in this folder:
scripts/pk19_overlay.py- standalone, self-documenting unpacker (python3 pk19_overlay.py <member> [MAGIC]).scripts/local_check.py- offline resolver for everyd19_*id throughautosolve_binary.answer(), no GM call. Printed 12/12 OK before any submit; a full sweep resolved all 228 fields SURE, 0 probes.challenges/_lib/_test_binary_overlay.py- new lane catalog test, 16 checks,RESULT: PASS: independentstruct-based parse vs the adapter on the real member; a re-packedRS20overlay with different keys; a corrupted SHA-256 and an overlay-less member yielding nothing; and a scan-cost guard. Existing lane tests re-run clean: container catalog 19/19, universe 45 shapes / 1372 answers, unseen slots, hdr_struct 10/10 - allRESULT: PASS.
The one real mistake, and the cost
The first implementation sliced the declared payload before bounds-checking its length. Any 4-byte LLDD text in a member looked like a candidate magic, and the 67 MB d08 member matches that pattern about 65,000 times - each match slicing up to 67 MB. The overlay scan took 133.7 s on d08 alone. The Single Solve still graded CORRECT (137.2 s, untimed), but the same run then spent ~10 minutes of CPU on the Time Trial's variant and had to be killed.
Checked before doing anything else: a free op=status on both timed entries returned 409 start_required, i.e. no timed window had been opened and no variant was spent - the stall happened in the pre-start compute. The fix was to test off + 44 + ln == len(data) before touching the payload (the stub runs to EOF by definition) and to search backwards from the last MiB, returning the first verified hit. d08's scan went from 133.7 s to 0.00 s, and all 228 fields now resolve in 1.5 s. The rerun took the Time Trial in 7.1 s and the Mastery in 28.4 s.
Lesson for the lane: a byte-scanning extractor must bounds-check a length field read from untrusted bytes before slicing, and any new scan belongs on the clock-cost guard in the catalog test - a slow extractor is a lost timed window even when every answer it produces is right.
Reproduce
RUN="wsl --cd [local path] python3"
# unzip the evidence bundle (password 'infected') and unpack the Day 19 stub
$RUN "challenges/Day 19/scripts/local_check.py" # 12/12 d19 ids, no GM call
$RUN challenges/_lib/_test_binary_overlay.py # RESULT: PASS (16 checks)
$RUN challenges/_lib/autosolve.py 19 binary-reverse-engineering-day-19-static-unpacking binary-reverse-engineering