Install
pip install pwntoolsUsage
python3 ./exploit.py DEBUG # REMOTEScript
#!/usr/bin/env python3# -*- coding: utf-8 -*-from pwn import *
BINARY = "./vuln"REMOTE = "yuto0226.com:1337"
# Set up pwntools for the correct architectureelf = context.binary = ELF(BINARY, checksec=False)
context.log_level = "info" # info, debugcontext.terminal = ["tmux", "splitw", "-h"]context.delete_corefiles = True
def start(argv=[], *a, **kw): """Start the exploit against the target.""" if args.DEBUG: return gdb.debug([BINARY] + argv, gdbscript=gdbscript, *a, **kw) elif args.REMOTE: host, port = REMOTE.split(":") return remote(host, int(port)) else: return process([BINARY] + argv, *a, **kw)
gdbscript = """init-pwndbgb mainc""".format(**locals())
# ===========================================================# EXPLOIT GOES HERE# ===========================================================
io = start()
flag = io.recvline()success(f"flag: {flag.decode()}")
io.close()