Day 19 - Sharp Practice (script-analysis)
- GM id:
script-analysis-day-19-managed-assembly-bridge - Lane: script-analysis | Agent: agent-1 | Fields: 1249
- Artifact:
challenges/Day 19/_stage/Sharp_Practice/artifact_0.bin(124102 bytes, AES zip, passwordinfected, 137 members)
Result - all three modes CORRECT
| Mode | Result | Flag | Time |
|---|---|---|---|
| Single Solve | CORRECT | Token5cba5040577b47a5e527443af5d05118 | 4.3 s |
| Time Trial | CORRECT | Token6de97cad545f4c6de073c30240bf7c27 | 10.3 s |
| Mastery | CORRECT | Token926f6ac30aadff77e16699cea72a0993 | 18.0 s |
Each timed mode was opened only by AUTOSOLVE after its readiness gate passed (prior mode already CORRECT live on the same challenge, so same compute was proven on real bytes). No mode was started, retried or practiced by hand.
GM prompt
A Roslyn C# script and an inline ASPX host act as a bridge that carries managed code back into the script corpus. Recover their layered configuration, resolve each static handoff, and work out where the bridge actually leads.
Today's layer
The archive is the usual script_inventory corpus (137 inert fixtures: ps1/js/vbs/bat/py/sh/php/lua/pl/rb/mof/proj/...). Two carriers were new: Roslyn C# script (.csx) and Google Apps Script (.gs). Both are self-describing in the established way (HUNTRESS_ANALYSIS_V1:<KIND>-<payload> marker plus a v=3|key=value|... descriptor), so the banked solve_poly_d8 descriptor path answered 1238 of 1249 fields at first contact - including every -attack field, because the descriptor carries attack= itself and needs no LANGS entry for the new extension.
The genuine gap was 11 fields, all from one member: host-aspx-inline-csharp-csharp-script.csx.
Root cause
That fixture is the title's "bridge": an ASPX page that carries the entire Roslyn script as one escaped C# string literal inside <script runat="server">:
<%@ Page Language="C#" %>
<script runat="server">
private static readonly string EmbeddedCsx_4e8084fd = "// HUNTRESS_ANALYSIS_V1:HEX-763d337c...7374616765\n#nullable enable\nusing System.Collections.Generic;\nstring descriptor_4e8084fd = \"763d337c...\";\n...";
protected string InertRequest_4e8084fd(string action) { return "modeled:" + action; }
</script><%= "inert-analysis-fixture" %>
Because the embedded newlines are two-character \n escape sequences and not real line breaks, the whole specimen is one physical line. solve_poly_d8.MARK (HUNTRESS_ANALYSIS_V1:([A-Z0-9]+)-([^\r\n'"]+)) therefore ran past the end of the hex payload and swallowed the host's own code (\n#nullable enable\nusing System...) until the first real " character. clean_payload could not rescue that capture, so desc_of raised ValueError: unpeelable, the file never entered poly_answers' kv map, and all 11 host-aspx-inline-csharp-csharp-script-* ids reported no file for <id> [] -> AUTOSOLVE HELD with nothing submitted. Every other host container (host-google-docs-sidebar-google-apps-script.gs, host-php-webshell-php.php, host-wsf-*, host-hta-*, ...) stores its marker on a real line, which is why only this one member failed.
Fix (one additive helper in challenges/_lib/solve_poly_d8.py)
desc_of now tries the literal source first and, only if that yields no descriptor, retries on an unescaped copy of the source, keeping whichever descriptor has more fields:
def _unescaped(s):
"""An ASPX inline-C# host carries the WHOLE specimen as one escaped string literal, so the real line breaks are
two-character \n sequences and MARK's `[^\r\n'"]+` capture runs past the payload into the host's own code."""
if '\\n' not in s or 'HUNTRESS_ANALYSIS_V1' not in s:
return None
out = s.replace('\\r\\n', '\n').replace('\\n', '\n').replace('\\r', '\n')
out = out.replace('\\"', '"').replace("\\'", "'").replace('\\\\', '\\')
return out if out != s else None
_desc_of_text holds the previous marker/split logic unchanged; desc_of is now the two-candidate wrapper. The guard (\n present AND the marker present AND the expansion actually changed something) keeps the path strictly additive - a file that already decodes is never re-read, so nothing earlier can regress.
The recovered descriptor
The marker kind is HEX and the payload is plain hex (obfuscation_profile=plain_hex):
v=3|language=csharp_script|role=staged_chain|verdict=suspicious|attack=T1059|adapter=operation_graph|
host_profile=aspx_inline_csharp|obfuscation_profile=plain_hex|stage_profile=single_descriptor|
next_language=jscript|stage_count=2|steps=decode_configuration,return_configuration|
campaign_id=CSHARP_SCRIPT-7f5c5dc7|url=https://csharp_script-7f5c5dc76d.example.invalid/stage|
file_path=/tmp/huntress-csharp_script/.7f5c5dc76d8d8501.stage
The 11 answers, as submitted and accepted:
| answer id | value |
|---|---|
host-aspx-inline-csharp-csharp-script-role | staged_chain |
host-aspx-inline-csharp-csharp-script-attack | T1059 |
host-aspx-inline-csharp-csharp-script-adapter | operation_graph |
host-aspx-inline-csharp-csharp-script-campaign | CSHARP_SCRIPT-7f5c5dc7 |
host-aspx-inline-csharp-csharp-script-url | https://csharp_script-7f5c5dc76d.example.invalid/stage |
host-aspx-inline-csharp-csharp-script-stage-count | 2 |
host-aspx-inline-csharp-csharp-script-steps | decode_configuration>return_configuration |
host-aspx-inline-csharp-csharp-script-host-profile | aspx_inline_csharp |
host-aspx-inline-csharp-csharp-script-obfuscation | plain_hex |
host-aspx-inline-csharp-csharp-script-stage-profile | single_descriptor |
host-aspx-inline-csharp-csharp-script-next-language | jscript |
"Where the bridge actually leads" is next_language=jscript with stage_profile=single_descriptor: the managed-code host hands back into the JScript part of the corpus, which is exactly the prompt's "carries managed code back into the script corpus".
Note on -attack: the question's precedence rubric would read decode_configuration then return_configuration as the benign graph, yet the descriptor asserts attack=T1059 for a staged_chain role. The descriptor's own field is the ground truth (and the rubric explicitly accepts the parent Command and Scripting Interpreter technique), so the banked "descriptor field wins over re-derivation" rule held, and T1059 was accepted.
Reproduction
# extract (AES zip, password infected)
python3 -c "import pyzipper; z=pyzipper.AESZipFile('artifact_0.bin'); z.setpassword(b'infected'); z.extractall('x')"
# decode the bridge member by hand
python3 -c "import re,binascii; s=open('x/host-aspx-inline-csharp-csharp-script.csx').read(); \
print(binascii.unhexlify(re.findall(r'[0-9a-f]{200,}',s)[0]).decode())"
# full solve, all three modes
python3 challenges/_lib/autosolve.py 19 script-analysis-day-19-managed-assembly-bridge script-analysis
Verification
_test_script_universe.py: 1445/1445 PASS (66.6 s) after the patch - generic Material_/Codec_ 1046/1046, marker polyglot 195/195, end-to-endsolve_fields_ext153/153, tamper guard 51/51; 0 wrong answers, 0 held. No regression._test_autosolve_script.py: SKIP on this machine (requires the staged Day 07 fixtures, which are not present here).- AUTOSOLVE: Single CORRECT 4.3 s, Time Trial CORRECT 10.3 s, Mastery CORRECT 18.0 s - the GM result is the verification.
field_formats.confirm_allbanked 55 new tokens on the Single and 275 more on Mastery (the.csx/.gscarriers).
Lesson for the lane
A host container that stores the specimen as an escaped string literal is a new failure shape, distinct from every earlier carrier: the payload bytes are all present and plainly hex, but the marker regex's newline class never fires because there are no real newlines. When desc_of reports unpeelable on a file whose hex payload is visibly intact, expand \n / \" escapes and re-match before touching the extractor tables. The two genuinely new languages (Roslyn .csx, Apps Script .gs) cost nothing at all - as predicted by the self-describing-fixture hypothesis, a new language is free while the descriptor keys are unchanged. Only the new container idiom needed code.