bridge troll: a managed module at the p/invoke crossing

huntress ctf 2026, day 22 · binary · all three modes

tools used: binary analysis and timed-attempt pipeline.

"managed code on one side, native code on the other, and a bridge of p/invoke and ffi in between. pay the troll: trace every crossing and map what goes over." the day's new tag (d22) is a .net module; the prompt describes its bridge into native code, and the questions ask the module's identity and the configuration it carries, beside the earlier days' tags.

the key insight: a managed pe is still a pe. its format and its runtime version come from two small structures the pe points at: the cli header (data directory 14) and the metadata root, whose version string is the runtime the module was built against.

challenge shape

single        264 fields   22 tags x 12 fields: member sha-256s, then
                           each tag's analysis fields
time trial    264 fields   the same, fresh bytes
mastery      1584 fields   the same over six sets

the d22 fields: three member hashes, format, machine, metadata_version, the configuration block's campaign, domain, mutex, url and crc32_hex, and hcfg_version.

artifact anatomy

the evidence zip's d22 members are a managed dll (d22--sample.dll, a pe with a cli header, written in f#), its runtime configuration file (d22--sample.runtimeconfig.json) and the f# core library it references (d22--FSharp.Core.dll); the earlier tags' members sit beside them, and the zip is password-protected like every binary bundle. the managed module's metadata root starts with the BSJB signature, then a length-prefixed version string. the configuration block is the same HCFG structure the lane has read since its first days.

cli_rva, _ = data_directories[14]           # IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR
meta_rva = struct.unpack_from("<I", pe, rva_to_off(cli_rva) + 8)[0]
root = rva_to_off(meta_rva)
assert pe[root:root + 4] == b"BSJB"
n = struct.unpack_from("<I", pe, root + 12)[0]
version = pe[root + 16:root + 16 + n].rstrip(b"\0").decode()

extraction method

every analysis question names its member the same way: "use the unique d22-- primary managed assembly whose basename starts d22-- and ends .dll; .runtimeconfig.json and dependency dll members are delivery support only." two members end in .dll, so the primary one is the sample, not the f# core library it depends on.

the binary analysis producers read each tag's fields from its own format: the pe's file header gives the machine (0x14c, graded as i386), the cli header makes the format the managed pe label (pe_cli, from the enum elf, pe, pe_cli, jar, wasm, neko_bytecode), the metadata root gives the version, and the configuration block is located by its magic in the sample dll. the version question spells the read: "read the clr metadata-root version string at bsjb + 16 using its declared length, remove trailing nul bytes, and submit the exact text"; it graded v4.0.30319, the clr 4 metadata version, in every set.

validation and answer formatting

hashes are taken over the exact member bytes in central-directory order and written as "exactly 64 lowercase hexadecimal characters; no prefix"; labels come from the question's enum; the configuration's fields are answered as the block stores them, the crc32 as 0x plus eight lowercase hex digits and the hcfg version as a base-10 integer.

failed approaches and pivots

none on day 22: the new tag was read by producers that already existed.

automation across modes

the same producers answer every field of every set.

lessons

solve times

public scoreboard · day 22 finish: below top 10

  • 0:09.0singlefirst blood, +6.5 s
  • 0:15.7time trialfirst blood, +11.3 s
  • 0:25.3masteryfirst blood, +32.0 s
  • #26team day finishof 145 teams that cleared it, in 10:39.5
  • #5single orderof the day's 7, 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 the mode's first start on the game master to its correct submit.

mode work to flag attempts wrong submits
single 7.2s 1 0
time trial 5.0s 1 0
mastery 7.7s 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 5.0s 75.0s
mastery 400.0s 7.7s 392.3s

where we got stuck

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

{generated by a clanker}