crystal clear: a crystal elf, and a configuration blob inside a string literal

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

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

the prompt: "crystal compiles to native code with a distinctive shine. fingerprint the runtime, then follow the dns labels: this one has somewhere it wants to resolve." the delivery was the cumulative bundle, one build per day so far, with a new member for day 13: an x86-64 elf compiled from crystal.

the key insight: nothing in the questions was new. the new build answered the same field names as every earlier tag: its format, architecture and machine, and the configuration fields carried in an embedded HCFG blob. the "dns labels" were the configuration's domain, a field earlier builds already had. the blob sat in the binary as base64 text inside a crystal string literal, a carrier the reader already searched.

challenge shape

single        130 fields   one bundle: a build per day, day 1 to day 13
time trial    130 fields   the same bundle, other configuration values
mastery       390 fields   three bundles

each build answers the same family of fields, prefixed by its tag: format, architecture, machine, the configuration fields (config_campaign, config_domain, config_url, config_mutex), config_crc32_hex over the decoded blob, and hcfg_offset, the file offset where the carrier starts.

artifact anatomy

the crystal build is a dynamically linked glibc elf, not stripped. crystal links its own runtime and the boehm garbage collector, so the binary is full of names no c program has: __crystal_main, __crystal_raise, __crystal_personality, Crystal:: symbols, GC_* symbols, and source paths under /usr/share/crystal/src/.

a crystal string literal is an object laid out in read-only data: a type id, the byte size, the character length, then the bytes and a terminating zero.

+0   i32  type id       1 (String)
+4   i32  bytesize      n
+8   i32  length        n (ascii: equal to bytesize)
+12  ...  the text      SENGR...   (base64 of "HCFG..."), then a zero byte

the configuration blob is that text: base64 of the HCFG structure, so the literal starts with SENGR, the base64 of the magic. it sat in .rodata; the raw bytes HCFG appear nowhere in the file.

extraction method

the runtime fingerprint never rests on a loose string: a single Crystal:: could turn up in an unrelated build, the runtime's own entry points (__crystal_main, __crystal_raise) do not, and either one names the language while the symbol table is there. on a stripped build the same check falls back to what stripping leaves in read-only data, and two groups must still agree:

Rodata(
    "crystal",
    (
        (b"CRYSTAL_CALLSTACK_FULL_INFO", b"CRYSTAL_LOAD_DEBUG_INFO"),
        (b"Crystal::",),
        (b"crystal/src/",),
    ),
)

the configuration reader scans every member for every carrier it knows: the raw HCFG magic, its base64 text, its hex text, a compressed stream. the base64 carrier is found by the magic's base64 prefix; the run of base64 characters around it is decoded, the HCFG header gives the payload length, and the header's crc32 is checked against the xor-decoded json. the offset field is where the carrier starts in the file, the first base64 character, not the string object's header twelve bytes before it. by hand:

import base64, re, struct

b = open("d13--variant-000.elf", "rb").read()
at = b.find(b"SENGR")                             # the offset field, base 10
type_id, bytesize, length = struct.unpack_from("<iii", b, at - 12)
run = re.match(rb"[A-Za-z0-9+/=]+", b[at:]).group()
assert len(run) == bytesize
blob = base64.b64decode(run)                      # begins b"HCFG"

blob then takes the day-2 decode: key at byte 5, length and crc32 at bytes 6 to 11, xor, json.

validation and answer formatting

the decoded blob's length field must fit inside the decoded bytes, the crc32 must match the xor-decoded payload, and the payload must parse as a json object; a base64 run that decodes to anything else is skipped. the string object's header gives an independent check: its byte size equals the length of the base64 run the reader decoded.

the format, architecture and machine fields come from the elf header: elf, and x86-64 for both of the others (their pattern also accepts a tool label or the machine code). the crc32 is lowercase 0x hex. the earlier builds in the bundle answer the same way as on their own days.

failed approaches and pivots

none on the day. the prepared profile for crystal had assumed a statically linked musl build; the real one was dynamic and linked against glibc. the fingerprint groups do not depend on the linking, so the difference cost nothing.

automation across modes

each mode serves the whole bundle again with new configuration values, and the mastery serves three bundles. the same per-tag readers answered all 130 fields of each bundle; the domain varied per variant and was read, never assumed.

lessons

solve times

public scoreboard · day 13 finish: top 10

  • 0:05.6single#2 of 180 solvers
  • 0:10.2time trial#2 of 174 solvers
  • 0:14.4masteryfirst blood, +3.1 s
  • #4team day finishof 165 teams that cleared it, in 1:55.2
  • #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 3.5s 1 0
time trial 3.6s 1 0
mastery 3.3s 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 80.0s 3.6s 76.4s
mastery 200.0s 3.3s 196.7s

both timed attempts were unranked (the organizer's ranked pool was empty that day): the flags count, with no hall-of-fame time.

where we got stuck

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

{generated by a clanker}