StarCTF 2019 - babyprng (Crypto, 206)

Challenge

Server: nc 34.92.185.118 10003
File: task.py

This is an puzzle game, given some command to controll.


Solution

pc : program counter 
stack : initialized with random bits
out : output

commands :

\x00: out.append(stack[-1])
\x01: if stack[-1] == 1 then pc++
\x02: delete stack[-1]
\x03, \x04, \x05: stack[-1] (&=, |=, ^=) stack[-2]
\x10 ~ \x30: jmp to pc + command - 0x10
\x30 ~ \x50: jmp to pc - command + 0x30

The target is make the output contain over 0.9*SIZE bits and halfs of 0,1 (delta=0.005)

payload : ‘040102’*20 +‘000500050034’

*ctf{23bb9d2dc5eebadb04ea0f9cfbc1043f}

solve.py