Created
January 22, 2021 08:33
-
-
Save captain-woof/0795eec3e26c05edf1db807d013673f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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