Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save captain-woof/0795eec3e26c05edf1db807d013673f3 to your computer and use it in GitHub Desktop.

Select an option

Save captain-woof/0795eec3e26c05edf1db807d013673f3 to your computer and use it in GitHub Desktop.
#!/usr/bin/python3
from pwn import *
import sys
if len(sys.argv) != 2:
warn("Usage: {} binary_filename".format(sys.argv[0]))
exit(0)
filename = sys.argv[1]
elf = ELF(filename)
class Guesser:
def __init__(self):
self.found = None
self.proc = elf.process()
def start(self):
self.proc.recvlines(3)
for guess in range(-4097,4097):
self.proc.recvline()
info("Guessing {}...".format(guess))
self.proc.sendline(str(guess))
resp = self.proc.recvline().decode().strip()
self.proc.recvline()
if "Congrats" in resp:
self.found = guess
break
return self.found
# DRIVER
guesser = Guesser()
guess = guesser.start()
info("CORRECTLY GUESSED VALUE -> {}".format(guess))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment