isc • 1000 points (Dynamic Decay) • Insane
DYNAMIC SCORING Current: 1000 pts Range: 1000 pts → 200 pts • Solves: 0 The seal is stored encoded, but the encoding changes depending on what you give it. Target: https://cyber-arena-2026.s3.ap-south-1.amazonaws.com/scs/binary/chall7/alpha Launch Target Submit Flag* CTF{...}
The binary is a static stripped x86-64 ELF that prompts seal> and prints accepted/rejected. Ghidra found the main logic in FUN_00401660. Let me verify the details against the assembly before writing an inverter.
The assembly confirms the algorithm in FUN_00401660. Let me extract the target string and the byte at 0x47c01d, then build an exact forward model.
0x47c01d is "\r\n" (input terminator strip). Target is 56 chars. Now I'll write a bit-exact forward model (verified against the binary) and then invert it.
No result — my model may diverge from the binary somewhere. Let me validate it directly by using gdb as an oracle: break right before the final strcmp and read the actual encoded string the binary produces for known inputs.
gdb works as an oracle. Now let me check my forward model against these ground-truth pairs.
My model produces the correct digits as a suffix but with extra leading digits — the transformed buffer differs. Let me dump the binary's intermediate state (shuffled alphabet + transformed buffer) with gdb to find the divergence.
Alphabet shuffle matches exactly. Now compare the transformed buffer:
The transform and alphabet match gdb exactly, yet the encoded strings differ. Let me trace the base-52 encode loop in gdb pass-by-pass to see what number it actually encodes.
The trace shows 6 digits — my earlier oracle printed $rdi before LEA RDI,[RSP+0x140] executed (stale pointer), so "cND" was stale stack data. Let me redo the oracle correctly, breaking at the strcmp call itself.
The model is now verified exact against the binary. Let me instrument the solver to see where inversion fails per candidate length.
The full pipeline is verified, yet no length inverts. Let me double-check the comparison target string directly in memory via gdb:
The model matches, but inversion fails. Let me test the inverse directly on a known plaintext/ciphertext pair from the binary (ABCD → fab5f2b8):
The inverse fails on a known pair — let me trace the true intermediate values for ABCD to see where the backward chain breaks:
Found it — the output block stores hi.b1 first, so reconstructing hi3 needs (o0<<8)|o1, not the swap I wrote. Fixing dec_block:
Found it — len=40 yields clean ASCII: CACTF{b4s3_f1fty_tw0_sh4k3n_n0t_st1rr3d}. Let me confirm against the binary itself:
accepted ✅ — solved.
Flag
CACTF{b4s3_f1fty_tw0_sh4k3n_n0t_st1rr3d}
How it works
alpha is a static, stripped x86-64 ELF. All the logic lives in FUN_00401660 (Ghidra), verified instruction-by-instruction against the assembly:
- Read a line via
fgets(max 127 bytes), strip at\r\n, takestrlen. - Length-keyed alphabet — Fisher–Yates shuffles
ABC…Zabc…zusing an LCG (seed = len*0x9e37,seed = seed*0x343fd + 0x269ec3, digit =(seed>>16) % (i+1)), i from 51 down to 1 — this is the "encoding changes depending on what you give it" part. - 4-round block cipher over each 4-byte block (LCG seed
0x5c5b7persists across blocks):hi' = ((hi*0x9e37) & 0xffff) + (lcg>>16) ^ (hi>>5) ^ lo, Feistel-style(hi,lo) → (new, hi); output bytes are[hi₃.b1, hi₃.b0, hi₄.b1, hi₄.b0]. The 16-bit add can carry into bit 16 and propagate, so the inverse had to enumerate those upper carry bits. - Base-52 encoding of the transformed buffer using the shuffled alphabet, compared to
QgfCyGedKTyZUYrXTRHtJaZNRWHwFkWQXWygDtuZjsvfLTBkpJaTyqVe(56 chars).
Solution approach (solve.py in the workspace): since every step is invertible, I brute-forced the input length (the only unknown keying the alphabet), decoded the target back through base-52, and inverted each cipher block analytically — solving hi₂/hi₁/hi₀/lo₀ backward from the two leaked 16-bit words, with hi₀ < 0x10000 / lo₀ < 0x10000 as the pinning constraints — then re-encoded the candidate forward as a self-check.
Two verification steps along the way: I used gdb as an oracle (breaking at the strcmp at 0x4018e2) to confirm my Python model reproduced the binary's encoded output byte-for-byte (after fixing two bugs: reading $rdi before the LEA at the first breakpoint, and reconstructing hi low-words as (o0<<8)|o1 instead of the swapped order). With the corrected inverse, length 40 was the only candidate yielding printable ASCII:
$ echo 'CACTF{b4s3_f1fty_tw0_sh4k3n_n0t_st1rr3d}' | ./alpha
seal> accepted
