lost in translation: php polyglots, script hosts, and a descriptor that states every answer
huntress ctf 2026, day 8 · script analysis · all three modes
tools used: script-analysis toolkit and timed-attempt pipeline.
the prompt: "the same indicators show up in every language the campaign speaks, each with its own quoting, escaping, and encoding accent. normalize them to their exact form and find the one that doesn't match its siblings." the bundle was every earlier day's specimens plus two new families: script-host carriers (windows script files with jscript or vbscript, an html application with javascript, a php webshell) and php "polyglots", one per behavior role.
the key insight: each new specimen carries a comment header that decodes to a version-3 descriptor, and on version 3 every graded field is a descriptor value taken verbatim, including the role and the att&ck id. rules that earlier days needed (role from the ordered step graph, the sub-technique from the language) had to give way to what the artifact states.
challenge shape
615 answer fields. the inherited families (powershell, jscript, batch, vbscript, python, bash, node.js) asked what they asked before. the new ids follow host-<carrier>-<language>-<field> (four carriers: host-wsf-jscript-jscript, host-wsf-mixed-vbscript, host-hta-jscript-javascript, host-php-webshell-php) and polyglot-php-<role>-<field> (eight roles), eleven fields each: role (an enum of eleven labels, the eight roles plus impact, relay and advanced_syntax), attack ("t#### or t####.###", or the literal none), the ordered steps (kind ordered_tokens: "exact tokens joined by > with no surrounding spaces"), adapter, campaign, url (-file-path for the benign utility), obfuscation ("the ordered encoding profile"), three profile fields named after their descriptor keys (-host-profile, -stage-profile, -next-language) and -stage-count (a base-10 integer). none of the graded fields asked for "the one that doesn't match"; the sibling story stayed in the prompt.
artifact anatomy
a php polyglot, with payloads elided:
<?php
// <MARKER>:<CODEC>-<payload>
declare(strict_types=1);
$descriptor_71d74af3 = "<...>";
$plan_71d74af3 = ["descriptor" => $descriptor_71d74af3];
unset($plan_71d74af3);
the comment header has the form HUNTRESS_ANALYSIS_V1:<CODEC>-<payload>. four codec names occurred:
| codec | payload | graded -obfuscation label |
|---|---|---|
B64 |
base64 | base64 |
HEX |
hexadecimal | plain_hex |
FRAG |
hexadecimal in dot-separated fragments | fragmented_hex |
HB64 |
hexadecimal of a base64 string | hex_base64 |
the decoded text is a version-3 descriptor of key=value pairs joined by |, with the steps comma-separated:
v=3|language=...|role=...|verdict=...|attack=...|adapter=...|host_profile=...|
obfuscation_profile=...|stage_profile=...|next_language=...|stage_count=...|
steps=a,b,c|campaign_id=...|url=...|file_path=...
the host-family files use the same header in their language's comment syntax inside their carrier: a wsf <job> with a <script language="JScript"> or "VBScript" cdata block (the mixed one adds a second jscript block), an html page with an <hta:application> tag, and a php file. the encoded descriptor is repeated in a descriptor_<hex> variable, and the php webshell's handler returns "executed" => false, so the specimens are inert.
extraction method
the descriptor finder tries the header first, because it is artifact data and cheaper than any search:
ANALYSIS_HEADER = re.compile(r"HUNTRESS_ANALYSIS_V1:([A-Za-z0-9_]+)-(\S+)")
HEADER_CODECS = {
"FRAG": lambda p: bytes.fromhex(p.replace(".", "")),
"HB64": lambda p: base64.b64decode(bytes.fromhex(p), validate=True),
"HEX": bytes.fromhex,
"B64": lambda p: base64.b64decode(p, validate=True),
}
def header_descriptor(src: str):
m = ANALYSIS_HEADER.search(src)
if m is None:
return None
kind, raw = m.group(1).upper(), m.group(2)
payloads = [raw, raw.rstrip("*/'\";>)")] # a header glued to its comment closer
names = [kind] if kind in HEADER_CODECS else list(HEADER_CODECS)
for name in names:
for text in payloads:
try:
desc = parse(HEADER_CODECS[name](text).decode("latin-1"))
except ValueError:
continue
if desc is not None:
return desc
return None
an unknown codec name tries every decoder, on the payload and on its reverse, and base32 and base85 are registered as well. without a header the finder falls back to the earlier paths: the vbscript-style material constants, plain text fragments, then every string literal under every codec.
validation and answer formatting
a descriptor counts only if it parses into the expected keys. on version 3 the answers are read straight from it: role is the descriptor's role (not the role our step-graph table would assign), attack is its attack as written, and obfuscation is obfuscation_profile (the label column above). steps are the descriptor's comma-separated steps re-joined with >; stage count, adapter, campaign (campaign_id) and the three profiles are copied as they stand. the graded attack ids followed the role, never the carrier's language:
| role | attack |
|---|---|
launcher, staged_chain |
T1059 (plain, no sub-technique) |
downloader, stager |
T1105 |
dropper |
T1140 |
persistence_descriptor |
T1053 |
uploader |
T1041 |
benign_utility |
none |
every host carrier but the hta stated staged_chain; the hta stated downloader. to reproduce one specimen by hand:
m = re.search(r"HUNTRESS_ANALYSIS_V1:([A-Z0-9]+)-(\S+)", src)
desc = dict(kv.split("=", 1) for kv in HEADER_CODECS[m[1]](m[2]).decode().split("|"))
answer_steps = desc["steps"].replace(",", ">")
failed approaches and pivots
the first pass answered the new families the way earlier days had taught us: role from the ordered step graph and attack from the language or the role table. the grader rejected five distinct values: the language sub-techniques T1059.007 (wsf jscript) and T1059.005 (wsf vbscript), T1105 for the php launcher, and benign_utility with none for the php webshell, whose two-step graph looked harmless but whose descriptor states staged_chain and T1059. those five values cost 27 incorrect submits before the rule was clear: on version 3 a stated value beats any derived one. the two codecs the finder did not know yet (FRAG, HB64) were the other gap; each needed one line.
automation across modes
with the header reader and the verbatim rule in the shared finder, the same solver answered the time trial (615 fields on fresh bytes) in about a second and the mastery (five sets of the same 615 fields) in under two. on day 8 the header also became codec-agnostic: base32, base85, unknown names and reversed payloads decode without new code.
lessons
- when an artifact states a value outright, it beats the rule you derived on earlier days; check for a stated field before inferring one.
- a self-describing header is the cheapest evidence in the file: decode it before searching literals.
- prompt flavor ("find the one that doesn't match") is not a graded field until a question asks for it.
solve times
public scoreboard · day 8 finish: top 10
- 2:07.5single#4 of 192 solvers
- 8:23.7time trial#11 of 181 solvers
- 8:28.3mastery#11 of 181 solvers
- #7team day finishof 177 teams that cleared it, in 12:43.6
- #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 | 2m05s | 2 | 27 |
| time trial | 6m16s | 9 | 0 |
| mastery | 5s | 2 | 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 | 9.0s | 1.1s | 7.9s |
| mastery | 22.0s | 1.7s | 20.3s |
where we got stuck
- single: about two minutes on the new families, mostly the role and attack rule (five rejected values, 27 incorrect submits) and the two unknown header codecs.
- time trial: the platform refused timed starts for about six minutes (eight failed starts; the gm answered them with http 503
training_rotation_invalid). once starts went through, both timed modes took under two seconds each.
flags: single, time trial, and mastery [redacted].
{generated by a clanker}