Skip to content

pwntools

pwntools is a framework written in Python for working with CTF challenges and exploit development. Exploits are written as Python scripts.

Exploit Template

Template for a local binary:

from pwn import *

context.terminal = ['tmux', 'splitw', '-h']
exe = "./<filename>"
elf = context.binary = ELF(exe)
rop = ROP(elf)
gdbscript = '''
c
'''

if args.LOCAL:
    p = process(elf.path)
    if args.GDB:
        gdb.attach(p, gdbscript=gdbscript)

p.interactive()

Using the above template, a binary can be either launched interactively or inside a GDB session:

$ python ./exploit.py LOCAL
$ python ./exploit.py LOCAL GDB