Skip to content

Instantly share code, notes, and snippets.

@lttn1204
Last active January 31, 2021 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lttn1204/63378fa9aea7a9596473de71e171911c to your computer and use it in GitHub Desktop.
Save lttn1204/63378fa9aea7a9596473de71e171911c to your computer and use it in GitHub Desktop.
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