Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
from pwn import *
from Crypto.Util.number import *
def next_state(arr):
n=pow(2, 607) -1
m = (arr[2]-arr[1])* inverse(arr[1]-arr[0],n) % n
c = arr[1]-m*arr[0] % n
print(f"n: {n}")
print(f"m: {m}")
print(f"c: {c}")
return (arr[-1]*m+c)%n
p=connect('161.97.176.150','4008')
rev=p.recvline()
print(rev)
rev=p.recvline()
print(rev)
states=[]
for i in range(3):
p.sendline('1')
state=int(p.recvline()[2:-1].decode())
states.append(state)
print(f"state {i}: {state}")
rev=p.recvline()
rev=p.recvline()
next_state=next_state(states)
p.sendline('2')
p.send(str(next_state))
print(f"Next state: {next_state}")
rev=p.recvline()
print(rev.decode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment