Reaper's Cipher a "custom AES" that's secretly one linear map

crypto
flag RxR{f1f0cd0d-ba9e-4b5b-b61e-10788863f675}

Connect and you get a fixed banner with the flag already encrypted, then an that encrypts any 16-byte block under the same secret 128-bit key, up to 300 queries in a 45-second window:

output
enc_flag = f0c2b8ed0482ea09453ac5f05554b1defbac86427950c37948c09dd68b95831862d9fa75500d4c3f8bb6d63d95c628bc
Oracle (up to 300 queries, 45 seconds):
  encrypt <32-hex>   -> Enc_key(your 16-byte block)

Three ciphertext blocks, so the flag is 48 bytes. The cipher is pitched as AES - ten rounds, a real key schedule, the author's own S-box.

Pitfall

My first read was that enc_flag was a constant I could work on offline while poking the oracle separately. It isn't - reconnecting moves the ciphertext (57e56497... then 34325064... then f0c2b8ed...). The key is drawn per connection, so the flag and the oracle only mean anything together, inside one 45-second session. Everything below has to fit in a single connection.

A second constraint bites early too: feeding the oracle a sparse block gets refused - "The Reaper won't stamp such an empty block (needs at least 32 set bits)" - which rules out the clean move of asking for unit vectors and zero to fingerprint a linear map directly.

The S-box is the weakness, not the cover

The whole pitch is a secret S-box. But a secret S-box only hides the map if the map is the thing leaking. Instead of trying to recover the box, I asked the oracle a question about structure: take an anchor a and two differences d1, d2, compare four ciphertexts:

output
E(a) ^ E(a^d1) ^ E(a^d2) ^ E(a^d1^d2)

Insight

For any affine map over GF(2) this is exactly zero, always; for a real S-box it isn't. With a = 0xff...ff and single-bit differences it came back zero every time, including wide differences spanning bit 3 and bit 70. The author's "custom substitution" is a linear map on F_2^8 - SubBytes, ShiftRows, MixColumns, the key schedule, all of it linear, so ten rounds and a "real key schedule" collapse into one affine function of the plaintext:

output
E(x) = A x + b,      A: 128x128 over GF(2),  b = E(0)

There's no key to find and no S-box to invert - there's one matrix.

Recovering it inside the query budget

The sparse-block rule is what makes this a puzzle rather than a two-liner - unit vectors and zero are both rejected. Anchor on the one block guaranteed dense: P0 = 0xff * 16. Every P0 ^ e_i clears a single bit and still has 127 set bits, so the whole basis is legal:

output
E(P0)                        -> column of b
E(P0 ^ e_i) ^ E(P0)          -> column i of A       (i = 0..127)

129 queries, pipelined in one write and read together - comfortably inside the window. Then b = E(P0) ^ A*P0.

Pitfall

I didn't trust the "always zero" result from the four-term probe - six single-bit differences is a thin basis for calling a whole cipher linear. Six more queries on fresh random blocks with a healthy popcount, checked directly against the recovered model: all six matched. That's the gate I'd want to see in someone else's writeup before believing the collapse.

Inverting

With A and b recovered, decryption is one Gauss-Jordan over GF(2): P = A^{-1} (C ^ b), which turns the banner ciphertext back into

output
RxR{f1f0cd0d-ba9e-4b5b-b61e-10788863f675}\x07\x07\x07\x07\x07\x07\x07

PKCS#7 padding, three blocks, nothing else. Ran the full chain on three separate connections before believing it - the key and ciphertext change every time, the plaintext never does.

solve.py runs the whole attack end to end: connect, 129 queries, the six-point model check, invert, print the flag.

Flag

output
RxR{f1f0cd0d-ba9e-4b5b-b61e-10788863f675}