$ cat writeup.md…
$ cat writeup.md…
sunshinectf2026
Task: networked glibc 2.39 key-value store behind a custom SBOX+counter stream cipher; a LINK/DELETE refcount-confusion bug yields UAF and double-free. Solution: reverse the cipher and KDF to build a client, leak PIE via a .data echo, heap via safe-linked tcache fd, libc via unsorted bin, then tcache-poison the .data function pointer to system and trigger the EXEC opcode for a shell.
$ cat /etc/rate-limit
Rate limit reached (20 reads/hour per IP). Showing preview only — full content returns at the next hour roll-over.
CodeBreaker: enterprise-grade encrypted key-value storage. All traffic is encrypted with our proprietary cipher.
Files: code_breaker (x86-64 PIE, stripped; Canary, NX, PIE, Partial RELRO, FORTIFY, IBT/SHSTK), libc.so.6 (glibc 2.39-0ubuntu8.3), ld, plus a remote nc service. Goal: get code execution and read the flag. All traffic is wrapped in a custom stream cipher, so the first task is to reproduce the protocol before any heap work.
.rodata (binary offset 0x2040).ks[i] = SBOX[(counter + i + KEY[i & 0xf]) & 0xff], and ciphertext = plaintext XOR ks. Send and receive each have their own counter; each counter advances by the message length and both reset to 0 immediately after the handshake. KEY is the 16-byte session key.Server sends an unencrypted frame [0x01 || nonce(16 from /dev/urandom)].
Client replies unencrypted [0x02 || C(16, client-chosen)].
Both sides derive KEY[16] from buf32 = nonce || C with a 4-round mix:
key init 0
for r in 0..3:
for j in 0..15:
t = buf32[(8*r + j) & 0x1f]
t ^= key[j]
t = SBOX[t]
t ^= buf32[(3*r + j) & 0x1f]
t = rol8(t, 3)
key[j] = t
Counters reset to 0.
Client sends encrypted proof [0x03 || V(16)] where V[i] = SBOX[key[i]] ^ key[(i+5) & 0xf].
Server replies encrypted [0x04 0x00] on success.
Because the server nonce is sent in cleartext and the client chooses C itself, the client can reproduce the same key and speak the protocol. This is a deterministic KDF, not real crypto.
...
$ grep --similar