Stack Tongue Reverse Engineering • 350 points (Dynamic Decay) • Hard
DYNAMIC SCORING Current: 350 pts Range: 500 pts → 350 pts • Solves: 44 The gate controller does not check seals itself. It runs a small program that does. Challenge Artifacts: program.bin tongue Submit Flag*
The binary prompts for a "seal" and runs program.bin. Let me decompile the interpreter.
The VM is clear. Now let me decode program.bin (STK1 magic, XOR with key stream k = 0xc3, k = k*5+0x3b) and disassemble it.
37-byte seal, one constraint chain per position. Inverting each (XOR → ADD → ROL → [SUB] → target):
All 37 constraints invert cleanly. Verifying against the real binary:
Flag: CACTF{st4ck_t0ngu3_sp34ks_1n_r1ddl3s} — the binary prints accepted (exit 0).
How it worked
tongue (statically linked, stripped) is a tiny stack-VM interpreter, main at 0x401690:
- Loads
program.bin(max 0x2000 bytes), requires magicSTK1 - Decrypts bytes 4..N-1 with a keystream:
k₀=0xc3,kₙ₊₁ = kₙ*5 + 0x3b(mod 256) - Prompts
seal>, reads 0x80 bytes viafgets, strips\n - Interprets the program with a 256-byte stack at
0x4ac300, sp at0x4ac2e0
Opcode set (failures set a flag but execution continues — 0xf0 prints accepted/rejected):
| op | meaning |
|---|---|
0x17 c | push constant |
0x2c i | push seal[i & 0x7f] |
0x63 r | rotate top 8-bit left by r & 7 |
0x41 / 0x5e / 0x7a | XOR / ADD / SUB (mod 256) |
0x88 c | pop, compare with constant (sets fail flag on mismatch) |
0x9d n | compare strlen(seal) == n |
0xf0 | END |
program.dec (496 → 492 payload bytes) is a flat sequence of 37 independent constraint chains: CHECK len == 37, then per position push seal[i], xor c1, add c2, rol c3, optional sub c4, check == target — each index 0..36 appears exactly once.
Since each chain is invertible, I reversed every one: y = ror(target, c3), undo SUB, undo ADD, undo XOR — giving all 37 bytes in one pass, then verified every forward constraint and confirmed against the real binary.
niceee
Glad it landed! 🎉
Quick recap for the writeup if you want it:
- VM spec: 8 opcodes, 256-byte stack, keystream-decrypted bytecode (
STK1header) - Crack: 37 independent invertible chains → solved in one Python pass, no brute force needed
The full disassembly of program.dec is in the transcript above if you want to archive it. Ping me for the next challenge.
