Skip to content

Instantly share code, notes, and snippets.

@sbrannstrom
Created December 2, 2019 09:53
Show Gist options
  • Save sbrannstrom/5fcdd376d5770395824f0e785d64d119 to your computer and use it in GitHub Desktop.
Save sbrannstrom/5fcdd376d5770395824f0e785d64d119 to your computer and use it in GitHub Desktop.
Script to beat the game on port 1337 of Vulnhub box 'Djinn'. First thing I've written in python so not very pretty...
from pwn import *
import operator
r = remote('172.16.123.208', 1337)
a = r.readline_startswith('(').decode("utf-8")
first = int(a[1])
oper = a[5]
second = int(a[9])
ops = {"+": operator.add, "-": operator.sub,
'*': operator.mul, '/': operator.truediv}
data = ops[oper](first, second)
print(a)
print(ops[oper](first, second))
r.sendline(str(data))
for x in range(0,1000):
a = r.readline_startswith('>').decode("utf-8")
first = int(a[3])
oper = a[7]
second = int(a[11])
ops = {"+": operator.add, "-": operator.sub,
'*': operator.mul, '/': operator.truediv}
data = ops[oper](first, second)
print(a)
print(ops[oper](first, second))
r.sendline(str(data))
print(r.readline())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment