dim and dimmer: vbscript specimens that name their own codec

huntress ctf 2026, day 4 · script analysis · all three modes

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

the evidence zip carried the cumulative script set (three powershell samples, nine jscript and nine batch specimens from days 1-3) plus nine new vbscript specimens. 231 fields per set; 159 were inherited, 72 were new vbscript-* fields: role, att&ck id, adapter, campaign, the usual indicators, and three new ones: the material representation, the reversible byte transform, and the control-flow form wrapping the decode.

the key insight: every specimen declares its encoding in a Codec_ constant, and that declaration is the graded label set verbatim. the code is still worth reading, but as a cross-check.

artifact anatomy

Const Material_<id> = "<n>|<n>|<n>|..."
Const Codec_<id> = "decimal_pipe|subtract_modulo_256|<key hex>"

the codec is representation|transform|key hex; the key is empty for identity and reverse_bytes and a comma list of hex bytes for repeating_key_xor. Load_<id> parses the material into a byte array, Decode_<id> applies the transform, and Recover_<id> joins the result into a descriptor of the same family as the batch and jscript days: v=1|steps=...|adapter=...|campaign_id=...|....

representations seen across all modes: decimal_pipe, decimal_dash, decimal_comma, hex_compact, hex_colon, hex_dash, reversed_hex, reversed_decimal, base64_literal, base64_chunks. transforms: identity, subtract_modulo_256, add_modulo_256, reverse_bytes, single_byte_xor, reverse_then_xor, repeating_key_xor, rolling_xor. the label names the encoding direction, so subtract_modulo_256 is undone by adding the key.

extraction method

decode the material with the declared codec and accept it only if it yields a v=1 descriptor with steps and adapter. the day-4 subset of vbscript.load and vbscript.transform:

rep, tr, keyhex = codec.split("|")
key = [int(k, 16) for k in keyhex.split(",") if k]
text = re.sub(r"\s+", "", material)
if rep.startswith("base64"):          # base64_literal, base64_chunks
    vals = list(base64.b64decode(text))
elif rep == "hex_compact":
    vals = list(bytes.fromhex(text))
else:                                 # decimal_* / hex_* / reversed_*
    base = 16 if "hex" in rep else 10
    vals = [int(x, base) for x in re.split(r"[^0-9A-Fa-f]+", text) if x]
if rep.startswith("reversed"):
    vals.reverse()
undo = {
    "identity": lambda v: v,
    "subtract_modulo_256": lambda v: [(x + key[0]) % 256 for x in v],
    "add_modulo_256": lambda v: [(x - key[0]) % 256 for x in v],
    "reverse_bytes": lambda v: v[::-1],
    "single_byte_xor": lambda v: [x ^ key[0] for x in v],
    "reverse_then_xor": lambda v: [x ^ key[0] for x in v[::-1]],
    "repeating_key_xor": lambda v: [x ^ key[i % len(key)] for i, x in enumerate(v)],
}
if tr == "rolling_xor":               # previous cipher byte, seeded with the key
    out, prev = [], key[0]
    for x in vals:
        out.append(x ^ prev)
        prev = x
else:
    out = undo[tr](vals)
desc = dict(kv.split("=", 1) for kv in bytes(out).decode().split("|") if "=" in kv)

if the header does not decode, the solver reads the codec off the code instead: the Split separator and index reversal in Load_, and the arithmetic in Decode_:

if re.search(r"Xor\s+previous", dec): transform = "rolling_xor"
elif re.search(r"Xor\s+keyBytes", dec): transform = "repeating_key_xor"
elif re.search(r"-\s*(\d+)\s*\+\s*256\)\s*Mod\s+256", dec): transform = "add_modulo_256"
elif re.search(r"\+\s*(\d+)\)\s*Mod\s+256", dec): transform = "subtract_modulo_256"

the order of those checks matters: (x - k + 256) Mod 256 also contains + 256) Mod 256.

control is the innermost real block around the Decode_ call inside Recover_, tracked with a small open/close stack: Select Case -> select_case, Do ... Exit Do ... Loop -> do_once, While ... Wend -> while_once, For x = 0 To 0 -> for_once, on error resume next ... err.raise -> error_guard, nothing -> direct. an outer if true then block and one-line If ... Then a Else b statements are decoys and never count.

validation and answer formatting

descriptor fields are verbatim (campaign_id -> campaign, file_path -> file-path). role comes from the ordered step list as on earlier days, and the interpreter roles map to the vbscript sub-technique T1059.005. against every graded set we saved (the race tiers and later practice reruns), the header labels matched the graded representation and transform on every vbscript specimen, and the code-derived codec agreed with the header.

the label fields are free exact_text, not enums: the question only says "identify the exact vbscript material representation", "the exact reversible byte transform" and "the exact vbscript control-flow form". role is an enum (benign_utility, stager, dropper, downloader, uploader, launcher, impact, staged_chain; the enum also offers relay, persistence_descriptor and advanced_syntax, none graded on day 4) and attack takes T####[.###] or the literal none. the graded role to technique pairs: launcher and staged_chain -> T1059.005, stager and downloader -> T1105, dropper -> T1140, uploader -> T1041, impact -> T1486, benign_utility -> none.

failed approaches and pivots

do_loop and while_wend, the names of the syntax, were rejected, as were while_loop, while_guard and while; the labels describe the effective one-pass behavior. on the On Error Resume Next wrapper the grader rejected resume_next, on_error, on_error_resume_next and error_handler before error_guard was found. the single never showed for_once, error_guard, reverse_then_xor or base64_chunks; they first appeared in the timed tiers.

automation across modes

the solver dispatches each field by language prefix and file extension: ps1, js, bat/cmd to the earlier parsers, vbs to the new module. the material/codec path is language-agnostic (it also reads var, $x =, python and object-literal assignments), so a new specimen language should leave only its new labels as work.

lessons

solve times

public scoreboard · day 4 finish: 1st

  • 3:27.7singlefirst blood, +2:37
  • 9:04.6time trialfirst blood, +1:45
  • 11:06.3masteryfirst blood, +17.4 s
  • #1team day finishof 192 teams that cleared it, in 11:06.3
  • #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 3m22s 1 8
time trial 5m36s 8 15
mastery 1m45s 3 26

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 6.0s 1.4s 4.6s
mastery 7.0s 4.1s 2.9s

where we got stuck

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

{generated by a clanker}