Debugging binary with pwntools and radare2
Brief
When using radare2 debugger, How to deal with the user input when debugging? There are two simple method.
- use rarun2 with stdio
- use pwntools with debugger.
use rarun2
- open second terminal, enter
tty
, record the output1
2$ tty
/dev/pts/2 - create a file p.rr2, write
stdio
equal the tty value you get from second termial1
2# p.rr2 content
stdio=/dev/pts/1 - in second terminal, run
sleep 9999999999
to wait for output and input - run
r2 -r p.rr2 -d vuln
in the first terminal and start debugging!
see more: doc
use pwntools
in the pwntool template, add following code
1 | io = start() |
then, run radare2 with r2 -d pid
, using the pid from scripts.