Overview
Prompt: “Can you activate the Dormancy?”
loader.dsk is a custom container holding a marshalled Python stub and an XOR-encrypted payload. The payload only defines a VM and its data; it never calls run_vm, so the solver must re-implement the VM decryption in reverse.
Prerequisites / Setup
- Python 3 (
marshal,hashlib) xdis(pip install xdis) — optional, for disassembling the 3.13 bytecodeloader.dskin the working directory
Recon
Step 1 — Triage
Goal: Identify the container format.
file loader.dsk
# loader.dsk: data
file has no signature for it, so the hexdump is the next stop. The first bytes are 44 53 4b 31, ASCII DSK1, and the file ends with the plain-text trailer END-DSK-ARCHIVE\x00. This is a custom format with a magic and an end marker.
Running strings or reading the ASCII column of the dump shows Python-looking names in the middle of the file: hashlib, marshal, int, from_bytes, sha256, digest, bytes, enumerate, loads, <stub>, <genexpr>. Together with the bytes e3 00 00 00 at offset 0x4c, this points to a marshalled Python code object (0xe3 is TYPE_CODE | FLAG_REF, the usual first byte of marshal.dumps(code)).
Exploitation
Step 2 — Reverse the container format
Goal: Determine the DSK1 layout from the hexdump and header sizes.
| Offset | Size | Field | Value / notes |
|---|---|---|---|
0x00 |
4 | magic | DSK1 |
0x04 |
4 | stub_len (big-endian) | 0x00000464 = 1124 |
0x08 |
4 | blob_len (big-endian) | 0x0000086b = 2155 |
0x0c |
32 | block A | 8ed1b9674a85f25c...5d9e8b48 |
0x2c |
32 | block B | identical to block A |
0x4c |
1124 | stub | marshalled code object |
0x4b0 |
2155 | encrypted blob | looks like random bytes |
0xd1b |
16 | trailer | END-DSK-ARCHIVE\x00 |
The offsets add up: 0x4c + 1124 = 0x4b0, and 0x4b0 + 2155 = 0xd1b, which is exactly where the trailer starts. That confirms the field meanings.
The names inside the stub (magic, stub_len, blob_len, sig, blob_start, encrypted, decrypted, payload_code, keys) read like a description of the loader’s logic:
def unpack(raw):
magic = raw[:4]
stub_len = int.from_bytes(raw[4:8], 'big')
blob_len = int.from_bytes(raw[8:12], 'big')
sig = raw[12:...]
blob_start = ...
encrypted = raw[blob_start:blob_start+blob_len]
keys = hashlib.sha256(...).digest()
decrypted = bytes(b ^ keys[i % len(keys)] for i, b in enumerate(encrypted))
payload_code = marshal.loads(decrypted)
That is a reconstruction from names and constants, not a full decompile. The stub bytecode is Python 3.13, so a Python 3.12 dis mangles it. The first thing to learn here is that the marshal format is readable across versions, but the bytecode inside is not. marshal.loads succeeded, but the disassembly was garbage because of the opcode mismatch.
Step 3 — Find the layer-1 key
Goal: Determine the SHA-256 input that produces the XOR key.
We have a 2155-byte blob, a SHA-256 / XOR hint, and a 32-byte candidate repeating key. Two observations narrow it down.
Observation 1: the key length is 32. Looking at the encrypted blob, long stretches repeat with a period of 32 bytes. A repeating-key XOR over zero-padded plaintext (marshal headers contain runs of 0x00) leaks the key like this. The key length matches a SHA-256 digest.
Observation 2: known plaintext. The decrypted blob should begin with 0xe3, the marshal code-object type byte. The first encrypted byte is 0x78, so key[0] must be 0x78 ^ 0xe3 = 0x9b.
So the task is to find an input to SHA-256 whose first digest byte is 0x9b. The obvious candidates (the signature block, the stub, the whole header, the magic, the blob) were tried. The only SHA-256 hit that was also structurally sensible was:
key = sha256(raw[12:76]) # both 32-byte blocks, 64 bytes in total
= 9b0e0266e854dbe44ce898ba3123ed5527472dcd8b55c7900426e7adbca206bc
One matching byte alone is only weak evidence (1 in 256 per candidate), so I verified it by decrypting the whole blob and checking that marshal.loads accepts it:
key = hashlib.sha256(raw[12:76]).digest()
dec = bytes(b ^ key[i % 32] for i, b in enumerate(blob))
marshal.loads(dec) # <code object <module> at 0x..., file "<loader>", line 1>
It loads cleanly. The filename inside the code object is <loader>, which is the payload that the stub would normally exec.
Step 4 — Analyse the payload
Goal: Disassemble the payload code object and recover the VM program and config.
The payload is Python 3.13 bytecode. I installed xdis (pip install xdis), wrapped the code object in a fake .pyc using the 3.13 magic number, and disassembled it with pydisasm:
import marshal
from xdis.magics import by_version
open('payload.pyc', 'wb').write(by_version['3.13'] + b'\x00' * 12 + decrypted)
# then: python3 -m xdis.bin.pydisasm payload.pyc
Module level
The module only assigns names and returns. It never calls run_vm. This is the dormancy:
OP_XOR_KEY, OP_ADD_CONST, OP_SUB_CONST, OP_ROL, OP_ROR, OP_HALT = 1, 2, 3, 4, 5, 255
def _rol8(b, n): ...
def _ror8(b, n): ...
def run_vm(data, program, key): ...
VM_PROGRAM = b'\x01\x00\x02\x11\x04\x03\x01\x00\x03\x07\x05\x05\x01\x00\x2)\x04\x01\xff\x00'
VM_CONFIG = b"\xcd\xc4\xff\x82...\xc5D" # 67 bytes
The helper functions
def _rol8(b, n):
n %= 8
if n == 0: return b
return ((b << n) | (b >> (8 - n))) & 0xFF
def _ror8(b, n):
n %= 8
if n == 0: return b
return ((b >> n) | (b << (8 - n))) & 0xFF
These are standard 8-bit rotations.
run_vm
From the disassembly:
def run_vm(data, program, key):
steps = []
i = 0
while i < len(program):
op, operand = program[i], program[i+1]
if op == OP_HALT: break
steps.append((op, operand))
i += 2
buf = list(data)
for op, operand in reversed(steps): # reversed!
if op == OP_XOR_KEY:
for j in range(len(buf)): buf[j] ^= key[j % len(key)]
elif op == OP_ADD_CONST:
for j in range(len(buf)): buf[j] = (buf[j] - operand) % 256 # note: subtract
elif op == OP_SUB_CONST:
for j in range(len(buf)): buf[j] = (buf[j] + operand) % 256 # note: add
elif op == OP_ROL:
for j in range(len(buf)): buf[j] = _ror8(buf[j], operand) # note: ror
elif op == OP_ROR:
for j in range(len(buf)): buf[j] = _rol8(buf[j], operand) # note: rol
return bytes(buf)
Three details matter:
- The steps are iterated with
reversed(...). - Each operation is replaced by its inverse: ADD becomes subtract, SUB becomes add, ROL becomes ROR and ROR becomes ROL. XOR is self-inverse.
OP_XOR_KEY’s operand is ignored. The key comes from thekeyargument. The payload never defines or supplies it, so it has to come from outside.
Decoding VM_PROGRAM
The program is 20 bytes, read as (opcode, operand) pairs:
01 00 | 02 11 | 04 03 | 01 00 | 03 07 | 05 05 | 01 00 | 02 29 | 04 01 | ff 00
| # | Instruction | Meaning in the encryption direction | Inverse applied by run_vm (decryption) |
|---|---|---|---|
| 1 | XOR_KEY |
b ^= key[i % len] |
XOR with key |
| 2 | ADD_CONST 0x11 |
b = b + 0x11 |
b - 0x11 |
| 3 | ROL 3 |
rol8(b, 3) |
ror8(b, 3) |
| 4 | XOR_KEY |
XOR with key | XOR with key |
| 5 | SUB_CONST 7 |
b = b - 7 |
b + 7 |
| 6 | ROR 5 |
ror8(b, 5) |
rol8(b, 5) |
| 7 | XOR_KEY |
XOR with key | XOR with key |
| 8 | ADD_CONST 0x29 |
b = b + 0x29 |
b - 0x29 |
| 9 | ROL 1 |
rol8(b, 1) |
ror8(b, 1) |
| 10 | HALT |
stop | stop |
Decryption therefore runs steps 9 to 1: ROR 1, SUB 0x29, XOR, ROL 5, ADD 7, XOR, ROR 3, SUB 0x11, XOR. The three XOR passes use the same key, but they are separated by non-linear byte operations, so they do not collapse into a single XOR and you cannot crack them with a simple known-plaintext XOR trick. You need the real key.
Step 5 — Find the VM key
Goal: Determine the key used to decrypt VM_CONFIG.
The payload offers no key. The challenge’s name suggests a seed, and the container already holds exactly one derived secret: the layer-1 key. Reusing it is the natural guess, and it works:
run_vm(VM_CONFIG, VM_PROGRAM, hashlib.sha256(raw[12:76]).digest())
# b'beacon[.]lordsudo[.]com|OPFALCON-7|r00t{REDACTED}\n'
An alternative to guessing is to check printable-byte counts. I tried about ten candidate keys (the raw signature, the stub hash, the blob hash, the magic and so on). Only the correct key produced a fully printable, structured 67-byte result (67 of 67 printable bytes). The others produced 18 to 29 printable bytes, which is roughly what random data gives.
The plaintext is a pipe-delimited record:
| Field | Value | Interpretation |
|---|---|---|
| 1 | beacon[.]lordsudo[.]com |
fake C2 beacon host |
| 2 | OPFALCON-7 |
fake operation name |
| 3 | `r00t{REDACTED} | flag |
The first two fields are flavour text: the sample is dressed up as a dormant implant carrying its “beacon config”, which matches the malware category.
Step 6 — Solve script
Goal: Automate the full chain statically.
The attached solve.py does the whole chain statically:
- Parse the
DSK1header and check the magic and the trailer. - Compute
key = sha256(raw[12:76]). - XOR-decrypt the blob and
marshal.loadsit. This builds a code object but does not execute it. - Read the two
bytesconstants (VM_PROGRAM,VM_CONFIG) fromco_consts. - Re-implement
run_vmin plain Python and decryptVM_CONFIG.
python3 solve.py loader.dsk
[+] magic=DSK1 stub_len=1124 blob_len=2155
[+] stub @ 0x4c, blob @ 0x4b0
[+] layer-1 key = sha256(raw[12:76]) = 9b0e0266e854dbe44ce898ba3123ed5527472dcd8b55c7900426e7adbca206bc
[+] payload code object: '<module>', file='<loader>'
[+] VM_PROGRAM (20B): 010002110403010003070505010002290401ff00
[+] VM_CONFIG (67B): cdc4ff82d52b4a2c...
[+] decrypted VM_CONFIG: beacon[.]lordsudo[.]com|OPFALCON-7|r00t{REDACTED}
C2 host : beacon[.]lordsudo[.]com
Operation : OPFALCON-7
FLAG : r00t{REDACTED}
It runs on Python 3.12 even though the payload is 3.13 bytecode, because marshal.loads can load a 3.13 code object into a 3.12 interpreter. We only read its constants and never execute the bytecode.
Flag
r00t{REDACTED}
From the decrypted VM_CONFIG pipe-delimited record.
Lessons / Takeaways
- Two layers, one secret. The container is protected by
sha256(header)XOR, and the inner VM config by a reversible byte VM keyed by the same digest. Once you have found the key for layer 1, layer 2 falls to the same key. - Dormancy. The payload only defines the VM and its data. Because nothing calls
run_vm, simplyexec-ing the payload yields no output. A solver who runs the payload and sees nothing has to realise the activation step is missing. That is the meaning of “activate the Dormancy” in the prompt. - Seed. The “seed” is the 64-byte header region (two identical 32-byte blocks) that is hashed to produce the key. The flag text, “seed never sprouts, stays static”, plays on this: a seed that is never activated stays inert, and the key material sits in plain sight in the header the whole time.
- Known-plaintext leverage. Marshal output is highly structured (zero padding, a fixed first byte
0xe3), which makes XOR with a short repeating key very weak. The period-32 pattern in the blob exposed the key length, and0xe3gave a check on the first key byte.
Mitigations
- Never
execan unpacked payload to “see what it does”. Parse it, disassemble it, and re-implement the decryption routine instead. - Bytecode version mismatches produce plausible-looking but wrong disassembly. If the output looks like nonsense (
COPY_FREE_VARS,SETUP_ANNOTATIONSin odd places), try another interpreter version or a version-aware disassembler such asxdis. - For real samples, the same patterns are worth detecting: custom container formats with a magic and an end marker, Python
marshalblobs inside non-Python files, and key material derived from the file’s own header. These make for good YARA rules (theDSK1andEND-DSK-ARCHIVEstrings, plus\xe3\x00\x00\x00at a fixed offset) and also make the sample self-decrypting for analysts.
Techniques
- Reverse Engineering
- XOR & Repeating-Key Ciphers
- Custom VM Reversing

