← all posts

· 2 min read · by Eav Puthcambo

The broken birthday oracle that leaks its own seed

A PRNG seeded with the flag answers questions mod 12, 7 and 5. Those "lossy" answers aren't lossy at all, and the update step runs backwards straight into the seed.

Consistently Static PRNG, BroncoCTF 2026 (crypto)

The setup is a joke that's also the whole challenge:

I made a birthday oracle recently, but I can't get it to work at all. It only gets the day of the week right 14% of the time! Here are my results…

You get the oracle code and a log of its (wrong) outputs. The PRNG is seeded with the flag bytes, and each guess prints three numbers:

month = guess % 12
day   = guess % 7
area  = guess % 5

Three ideas combine to peel the flag straight back out.

1. Those small mods aren't lossy

lcm(12, 7, 5) = 420, which is bigger than 256. So by the Chinese Remainder Theorem, knowing a byte mod 12, mod 7 and mod 5 pins it down uniquely in 0–255. Every "wrong" oracle line, far from being lossy, actually leaks one exact PRNG output byte.

2. The update step runs backwards

Here's the generator:

def next(self):
    a = sum(self.state) % 256
    self.state[self.schedule[self.nextrep % len(self.schedule)]] = a
    self.nextrep += 1
    return a

It outputs a = sum(state), then overwrites one slot with a. That's completely linear and reversible. After the overwrite:

sum(state_after) = 2·a_i − old_value   (mod 256)

which rearranges to:

old_value = (2·a_i − a_{i+1})   (mod 256)

And during the first pass over the schedule, the slot being overwritten still holds an original flag byte. So consecutive output pairs hand me flag bytes directly, just scrambled by the schedule's order.

3. Brute the schedule

The schedule is range(N) rotated by an unknown amount and maybe reversed, which is only about 2N possibilities. I try each one, reassemble the recovered bytes, and look for the one that reads as printable bronco{...}:

$ python solve.py
recovered 101 PRNG output bytes
flag: bronco{crypt0_1n5ecur3_4_c3rt4in}

Seeding a PRNG with your secret and then publishing its outputs, even reduced mod tiny numbers, is fatal when the update is linear and invertible. old = 2·a_i − a_{i+1} walks right back to the seed. Crypto insecure, for certain.

📂 Full writeup and the stdlib-only solver: ctf-writeups/crypto/…/consistently static pseudo random number generator

Thanks for reading! Questions or corrections? Ping me on GitHub.

Read more

3 min read

Two strings, one MD5

A command interpreter that authenticates commands by MD5 hash. Two traps, a little binary arithmetic, and a real HashClash collision that acts as a wildcard command.

all posts →