Tactical LogHuntress CTF 2026 // team archive

Days / Day 02 / Binary RE / Mangled

DAY 02//LANE: BINARY RE//STATUS: CORRECT x3

Mangled

Binary RE SSTTMM Modes reported CORRECT in this write-up

Challenge

  • Event: Huntress CTF 2026, Day 02
  • Game Master id: day02-single (from the zip comment huntress:day02-single)
  • Category: Malware / reverse engineering - encoded config recovery, with a C vs. C++ name-mangling theme.
  • Flag format: not supplied in the artifact. Day-02 challenges are dynamic: the recovered value is submitted to the Game Master, which validates and returns/auto-completes the real CourseStack flag.
  • Challenge text: not provided to this session (handoff was truncated). Solve derived entirely from the artifact.

Artifacts

FileSizeSHA-256
mangled.zip (challenge artifact, not published)5481(container)
day01-c.elf (challenge artifact, not published)15616a0d3aeddb90dccf579e0262704dc7d7c2828121d8cc988f085de169601737b9b
day02-cpp.elf (challenge artifact, not published)16640e9ca3054b0689f60a9c41a758781fae1406e127e5bfcc866c51f78748fdfd0d7

mangled.zip (challenge artifact, not published) is WinZip AES-256 encrypted (compression method 99, AES extra field 0x9901, AE-2, strength 0x03). Zip comment: huntress:day02-single.

Triage

  • RULE 2 (file type): .zip -> carving/crypto. zipinfo -v showed AES encryption, so a password was needed before anything else.
  • RULE 3 (theme): "Mangled" = C++ name mangling. The two members day01-c.elf (challenge artifact, not published) (C) / day02-cpp.elf (challenge artifact, not published) (C++) make the theme explicit; the C++ binary carries mangled symbols (_ZN15DiscoveryEngine...), the C binary does not.
  • Primary specialist domain: malware_re (solved inline - small, static, deterministic).
  • Hypotheses: (H1) flag hidden in a binary section/string; (H2) flag produced by running with the right input; (H3) recover an encoded malware config and submit a field to the GM. H3 proved correct.

Investigation

  1. Password. unzip refused ("need PK compat v5.1" = AES). Tried a short thematic wordlist with 7z t -p<pw>; infected (the classic malware-zip password) worked:
    7z t -pinfected mangled.zip   # Everything is Ok
    7z x -pinfected -y mangled.zip
  2. Identify. Both are ELF 64-bit LSB executable, x86-64, not stripped.
    • day01-c.elf (challenge artifact, not published): function recover_code (returns 0x1fa4 = 8100), custom section .huntress = BR01-CATALOG-000. A minimal C "catalog" counterpart.
    • day02-cpp.elf (challenge artifact, not published): C++ class DiscoveryEngine with score(const char*) const, family() const; RTTI type-name string 15DiscoveryEngine; a printf emitting a huntress.binary.dynamic_trace.v1 JSON.
  3. Dynamic trace (run). Running day02-cpp.elf (challenge artifact, not published) prints:
    {"schema":"huntress.binary.dynamic_trace.v1","branch":"success","event_count":6,
     "campaign":"BR02-000","family":"system_information_discovery","rtti":"15DiscoveryEngine"}

    main reads env HUNTRESS_HOST_MODEL; DiscoveryEngine::score returns 6 for workstation, 3 for analysis (-> branch decoy), 1 otherwise (-> failure). family = system_information_discovery maps to MITRE ATT&CK T1082. No flag in the trace.

  4. The mangled config (key step). readelf -S revealed a non-standard section .hcfg in day02-cpp.elf (challenge artifact, not published) (the "HCFG" magic also shows in strings). Dumping it showed an encoded blob with 0x13 used as a field separator and repeated sc 01 03 1c... groups - classic single-byte XOR.
    • Header: 48 43 46 47 | 01 | 31 | ... = magic HCFG, version 01, XOR key 0x31 (self-describing, byte offset 5).
    • Confirm by known plaintext: 0x13^0x31 = 0x22 ("), 0x0b^0x31 = 0x3a (:), 73 63 01 03 1c -> "BR02-".
    • XOR the section with 0x31:
    {"campaign":"BR02-000","domain":"node-000.day02.example.invalid","ipv4":"198.51.100.40",
     "url":"https://node-000.day02.example.invalid/api/BR02-000","mutex":"Global\\HuntressBR02_000",
     "windows_path":"C:\\ProgramData\\HuntressLab\\day02\\BR02-000.dat",
     "linux_path":"/var/tmp/huntress-lab/day02/BR02-000.dat","service":"HuntressLab-Day02-000",
     "host_model":"workstation"}

    This is the sample's hidden campaign/IOC config - "mangled" twice over: C++ mangled symbols + an XOR-mangled config section.

  5. Flag search (negative, important). Exhaustive strings/section sweep of both binaries (.rodata, .hcfg, .huntress, .comment, symtab, overlay) found no flag{}/huntress{} token. day01-c.elf (challenge artifact, not published) has no .hcfg. Conclusion: there is no offline flag; the recovered config (or a specific field) is the value to submit to the Game Master - the same dynamic model confirmed on "Half a Turn".

Flag Recovery

  • Source: the .hcfg section of the assigned day02-cpp.elf (challenge artifact, not published).
  • Transform: single-byte XOR; key is header byte 5 (0x31 for this copy) - or, attempt-independently, the unique byte that makes the blob decode to JSON whose first key is campaign.
  • Verification: scripts/solve_mangled.py parses the ELF section table directly (no external tools), brute-forces the XOR key by validating the decoded JSON, and reprints the config. Re-running reproduces xor_key: 0x31 and the config above - deterministic and reproducible.

Per-attempt note: the Game Master serves dynamic bytes, so the numbering (BR02-NNN, node-NNN, the IPv4) will differ from this static copy. The solver is written to be attempt-independent; run it on the downloaded attempt binary and submit the field the GM asks for.

Flag / Live results (2026-10-02)

This is a 3-mode compounding challenge scored by the Game Master inside the Homebase VM (no offline flag{} exists in the artifact). Live outcome:

  • Single Solve (2 pts): CORRECT (accepted before this session). CourseStack completion token: Token0fb4a08ae90803a93c21f451e7e5f42e.
  • Time Trial (3 pts): CORRECT - solved live via GPT-6 Luna in the Homebase VM. CourseStack completion token: Token11eedb570a15da45275f39da25bd2783. Luna independently reconstructed the exact mechanic (AES zip with the attempt's assigned password -> day02-cpp binary -> .hcfg blob = HCFG magic + short header + single-byte-XOR JSON, brute all 256 keys, CRC-validate) and mapped each of the 17 answer_ids to its decoded config field by name, submitting in one deterministic sub-5s run.
  • Mastery Mode (5 pts): CORRECT - landed 2026-10-02 via SSH-direct, token-free (no Luna), using scripts/solve_mangled_mastery_v2.py + scripts/mangled_iter.py on the reusable challenges/_lib/ctf_gm.py client. CourseStack completion token: Token1f0310b59f82d2899ea9f1a2cce3e7c0. The GM returns 34 answer_ids = the full 17-field inventory for EACH of two deliveries. Key discovery: Mastery MIXES a Windows PE and an ELF C++ binary ("cpp-and-PE-orientation"); the PE is MinGW-compiled so it carries the SAME Itanium _Z symbols as the ELF (_ZNK15DiscoveryEngine5scoreEPKc, _ZTV15DiscoveryEngine)
    • NOT MSVC ??..@@. Grader fields are libmagic (file -b) derived (cpp_format short family; c_machine=x86-64), with per-binary c_has_symtab, decimal c_recover_code, and the HCFG single-byte-XOR config. One open item: the PE cpp_format exact string stays UNVALIDATED (pe32+ and pe both returned incorrect on mixed attempts); we won on an all-ELF attempt draw (Mastery needs only one CORRECT attempt), so it is moot but recorded for a PE-only variant.

Score for Mangled: 15 / 15 (Single + Time Trial + Mastery). The day reached 32/32; VM powered OFF after.

SUPERSEDED (confirmed live): the GM does not score a single field - it returns the full field set as named answer_ids (17 for Time Trial, 34 for Mastery across its two binaries), so submit EVERY decoded config field under its same-named answer_id. The ranking below is retained only as the original pre-live hypothesis.

Candidate value(s) to feed the Game Master for day02-single (status GM_INPUT, not a final flag), ranked by likelihood. Discriminator: the dynamic trace already prints campaign/family/rtti for free, so the GM almost certainly asks for a hidden-only config field (one you can only get by defeating the XOR) - that is the "mangled" content the challenge is about:

  1. The full decoded .hcfg JSON of the assigned binary ("recover the config").
  2. A single hidden IOC, most likely in this order: url (https://node-000.day02.example.invalid/api/BR02-000), domain (node-000.day02.example.invalid), ipv4 (198.51.100.40), or mutex (Global\HuntressBR02_000).
  3. Low likelihood (visible from a plain run, no decode needed): campaign BR02-000, family system_information_discovery (MITRE T1082), rtti DiscoveryEngine.

Note: the sibling "evidence-note" heuristic (Day-02 answer = first-16-bytes-hex of the assigned file) does NOT apply here - the first 16 bytes are the generic ELF header, identical across all variants, so they cannot be the per-attempt answer. For Mangled the per-attempt discriminator is the decoded .hcfg content.

Minimal Reproduction

7z x -pinfected -y mangled.zip                 # password: infected
python3 scripts/solve_mangled.py day02-cpp.elf # -> xor_key: 0x31 + decoded JSON config
# (optional) observe the dynamic trace:
./day02-cpp.elf                                # family=system_information_discovery (T1082), rtti=15DiscoveryEngine

Then (in the Homebase VM, via the Game Master): start day02-single -> download the assigned binary -> run the solver on it -> submit the requested field/config under its answer_id.

Lessons Learned

  • What mattered: readelf -S to spot the non-standard .hcfg section; recognizing single-byte XOR from the regular 0x13 separators; and reading the XOR key straight out of the section header instead of guessing.
  • "infected" remains the go-to password for AES-encrypted malware-lab zips.
  • Theme was literal: "Mangled" = both C++ symbol mangling and an XOR-mangled config. The C++ mangled names (DiscoveryEngine, RTTI 15DiscoveryEngine) are thematic signposts, not the flag.
  • What would have wasted time: deep-reversing the C++ vtable/score logic or the runtime boilerplate - the payload was the data section, not the code (2025 heuristic: inspect suspicious data/strings/sections before reversing runtime init).
  • Negative result is a result: confirming no offline flag exists is what establishes this as a GM-submission challenge, so no fabricated flag is printed.
  • Reusable tool: scripts/solve_mangled.py auto-detects the XOR key and parses the ELF without external tools, so it survives per-attempt variants and timed modes.