The game uses Python’s MT19937 (random) to generate a 32-bit server_seed for each roll, and it prints that seed directly. After collecting 624 outputs, we can reconstruct the MT internal state via untempering, predict all future server_seed values, compute exact rolls from the HMAC formula, and bet the full balance on guaranteed wins until the balance exceeds 10000 to buy the flag.
server_seed = random.getrandbits(32) is revealed every round.(server_seed, client_seed, nonce):
sig = HMAC_SHA256(key=str(server_seed), msg=f"{client_seed}-{nonce}")< 1e6roll = round((lucky % 10000) * 1e-2) (integer 0..99)server_seed values.server_seed values.[2..98], set greed = roll and wager the full balance to win for sure.Temper in Python is:
y ^= (y >> 11)
y ^= (y << 7) & 0x9d2c5680
y ^= (y << 15) & 0xefc60000
y ^= (y >> 18)
Each step is reversible with iterative xor-unshifting, yielding the original state word.
Flag: uoftctf{ez_m3rs3nne_untwisting!!}