nimble: a nim elf, a config in a string literal, and two copies of the magic that were not it

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

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

the prompt: "nim compiles down to c, but the generated names give it away. learn to spot nim's runtime fingerprints hiding inside c-shaped clothing." the bundle was the cumulative one (c, c++, .net, go, rust, two jars, day 8's swift elf) plus d09, a 60 kb nim program for x86-64 linux: 90 answer fields.

the key insight: 89 fields were already answered by existing producers. the new one, hcfg_offset, asks where the configuration blob sits. the bytes HCFG occur twice in the nim binary and neither is the blob: both come from the one line of nim that checks the magic. the blob is a base64 string literal, and the answer is that literal's position.

challenge shape

d09_ fields: artifact_sha256_1, analysis_format, analysis_architecture, analysis_machine (an integer), the hcfg configuration (config_campaign, _domain, _mutex, _url, _crc32_hex) and one new name, analysis_hcfg_offset, also an integer. the other 80 fields covered d01 to d08 under known names. no field is about nim itself: the fingerprints are how you read the binary, not what you submit.

artifact anatomy

nim 2 compiles each module to c and hands it to gcc, so the elf has the usual crt startup and glibc imports. the names give it away; this build is not stripped, and 133 of its 333 symbols are nim-mangled:

a stripped build still keeps fatal.nim, defect names such as IndexDefect, and the signal messages in .rodata.

a nim 2 string is two words, a length and a pointer to a payload. a literal's payload in .rodata is a 64-bit capacity word with bit 62 set (the literal flag), then the characters and a nul. on a little-endian 64-bit target that flag is the byte 0x40 just before the text, which is why strings prints nim literals with a leading @. the proc that hands out the configuration is two instructions and a ret: the length into eax, the payload's address into rdx.

the blob is the hcfg layout from day 2: magic, version, xor key, a 16-bit length, the crc32 of the plaintext, xor'd json. the main module checks the decoded magic with an assertion, roughly:

doAssert blob[0 .. 3] == "HCFG"     # illustrative

that line puts HCFG into .rodata twice: nim keeps an asserted expression's source text, with file, line and column, as a literal to print on failure, and the comparison reads a four-byte literal. the base64 literal with the real blob is the next string after them.

extraction method

by hand, the names lead to the carrier: the accessor that returns the encoded configuration and the decoder that calls the standard base64 module keep their source names. the accessor's literal starts with SENGR, base64 of a blob that begins HCFG (day 8). gnu strings finds all three candidates with their decimal offsets:

strings -a -t d d09--variant-NNN.elf | grep -E 'HCFG|SENGR'

it prints the assertion text, a short @HCFG and the @SENGR... literal, each with nim's flag byte @ in front, so the offset it shows for the literal is one less than the answer. decode that literal as in day 8, check the blob, and submit the offset of the S as a plain decimal integer.

the solver does not disassemble. one carrier search runs over every member of a tag, zip entries included, cheapest form first:

# cheap first; a later form is tried only when no earlier one found a blob
FLAT_STAGES = (_raw, _b64, _hex, _wide, _xor)
STAGES = (*FLAT_STAGES, _compressed, _any_b64)    # day 9; later days add more

for stage in STAGES:
    found = [Carrier(view.readings(at) + extra, blob)
             for view in views                  # members, entry by entry
             for at, extra, blob in stage(view.data)]
    if found:
        break

here the raw stage rejects both hits and the base64 stage, anchored on the encoded magic, decodes the literal and validates the blob at its start.

validation and answer formatting

every candidate passes the same validator: bounds, crc32 over the plaintext, and a payload that parses as a json object.

candidate what follows HCFG rejected by
assertion message the rest of the quoted source line crc32
four-byte literal its nul, then zero padding json
base64 literal a full blob after decoding accepted

in the second row version, key, length and crc all read as zero, and the crc32 of an empty payload is 0, so bounds and checksum pass; only the json requirement rejects it.

hcfg_offset is the file offset of the literal's first base64 character in the elf as extracted: not the capacity word 8 bytes earlier, not a position in the delivered zip (encrypted and deflated, so the literal never appears there), and not a raw HCFG. the crc32 is lowercase hex with 0x, as the question's syntax says; the values are hcfg_offset = 30696 and config_crc32_hex = 0x9614e1a8 for the single. the offset was 30696 in the time trial and all five mastery sets too, and each crc32 followed its own configuration (0xa10eee2b for the time trial).

failed approaches and pivots

the raw-blob reader reported no valid blob, which first read as "no configuration here", while the two raw hits offered two plausible offsets. validating them ruled both out before anything was submitted.

the first producer was narrow: a raw blob's offset, else its base64 literal's. on day 9 it became the carrier search above, and asking every producer for every field of every day 9 tag found well-formed wrong answers no question had asked for yet (0x0 as a jar's architecture, zero function counts, the swift build read as rust). those now raise, naming the member kind.

automation across modes

the time trial delivered one evidence set (90 fields), the mastery five (450 fields), each with a 67 mb swift elf and a 5 mb kotlin jar. the winning mastery attempt spent 2.1s solving; on day 9 we cut that bundle's solve from 1.7s to 0.7s:

lessons

solve times

public scoreboard · day 9 finish: top 10

  • 1:03.0singlefirst blood, +9.0 s
  • 1:34.7time trial#3 of 189 solvers
  • 1:41.3mastery#3 of 188 solvers
  • #7team day finishof 173 teams that cleared it, in 4:18.7
  • #5single 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 30s 1 0
mastery 10s 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 10.0s 1.5s 8.5s
mastery 20.0s 5.3s 14.7s

where we got stuck

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

{generated by a clanker}