pwntools-r2 enables seamless launching and debugging of radare2 sessions from pwntools within tmux for efficient exploit development.
Launch radare2 like a boss from pwntools in tmux
This tool is designed for penetration testers and exploit developers who want to integrate radare2 debugging directly into their pwntools-based exploit scripts, leveraging tmux for terminal multiplexing. It simplifies the workflow of launching radare2 with custom scripts and interacting with the debugged process in an automated and interactive manner.
pwntools-r2 currently supports only Python 2 versions of pwntools and is tested primarily with tmux; other terminal setups may not work reliably. Users should ensure they use Python 2.7 and configure context.terminal appropriately. Radare2 commands must be prefixed with '#' to be recognized. The Python 3 fork support is planned but not yet available.
Create a new pipenv environment with Python 2.7: pipenv --python 2.7
Install pwntools-r2 inside the pipenv: pipenv install pwntools-r2
Enter the virtual environment shell: pipenv shell
context.terminal = ['tmux', 'splitw', '-v']
Sets the terminal emulator to tmux with vertical split for launching radare2.
p = r2dbg('./a', r2script=r2script)
Starts radare2 debugging session on binary './a' with specified radare2 commands.
p.interactive()
Enters interactive mode to interact with the radare2 debugging session.
#r2.cmd('ood `!cat /tmp/payload`')
Example radare2 command to pass argv values by reading payload from a temporary file.
context.log_level = 'DEBUG'
Enables detailed debug logging within pwntools scripts for troubleshooting.