Skip to content

Instantly share code, notes, and snippets.

@volpino
Created October 13, 2014 10:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save volpino/7fc2fac39217624c0b60 to your computer and use it in GitHub Desktop.
import socket
s = socket.socket()
s.connect(("asis-ctf.ir", 12445))
s.recv(2048)
s.send("Paillier\n")
s.recv(2048)
lo = 10 ** 307
hi = 11 ** 307
while True:
n = (lo + hi) / 2
s.recv(2048)
print "Sending N={}".format(n)
s.sendall("E\n")
s.recv(2048)
s.sendall("{}\n".format(n))
result = s.recv(2048)
print result
if "None" in result:
print "GOT N: ", n+1
exit(0)
elif "Your secret is" in result:
print "TOO LOW!"
lo = n
else:
print "TOO HIGH!"
hi = n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment