My Pwndbg GDB Init Setup
My Pwndbg GDB Init Setup
This is my current .gdbinit setup for binary
exploitation and reverse engineering. It loads pwndbg,
switches disassembly to Intel syntax, follows child processes after
fork, and automatically opens separate tmux
panes for disassembly, stack, backtrace, registers, and an IPython
scratch pane.
Requirements
Install these first:
gdbpwndbgtmuxipythonoptional, only used for the scratch pane
The config assumes pwndbg is installed at:
1 | /usr/share/pwndbg/gdbinit.py |
If your pwndbg install path is different, change the first line of the config.
Install
Put the following content in ~/.gdbinit:
1 | source /usr/share/pwndbg/gdbinit.py |
Usage
Start a tmux session first:
1 | tmux |
Then run GDB or pwndbg normally:
1 | gdb ./chall |
or:
1 | pwndbg ./chall |
When GDB starts inside tmux, the config creates panes for:
disasm: current instruction contextstack: stack view plus pwndbg legendbacktrace: call stackregs: registers and expressionsipython: scratch Python shell
When GDB exits, the created tmux panes are killed automatically
through the atexit cleanup hook.
If GDB is not running inside tmux, no panes are created and pwndbg falls back to the normal inline context output.
Important Lines
1 | set history save on |
Keeps GDB command history across sessions.
1 | set follow-fork-mode child |
After fork(), GDB follows the child process. This is
useful for fork-based CTF services where the vulnerable logic runs in
the child.
1 | set disassembly-flavor intel |
Uses Intel syntax instead of AT&T syntax.
1 | pwndbg.config.context_disasm_lines.value = 25 |
Controls how much disassembly and stack context pwndbg prints.
Base Address Helpers
These two lines are personal scratch variables:
1 | set $mybase1 = 0x0000555555554000 |
They are not required. I use them as quick base-address anchors while
debugging PIE binaries or shared libraries. You can remove them or
replace them with values from piebase, vmmap,
or a leak.
Example usage:
1 | x/10i $mybase1 + 0x1234 |
Adjusting The Layout
The pane sizes are controlled by
tmux split-window -l:
1 | 'tmux split-window -vb ... -l 75% ...' |
Change these percentages if the panes are too large or too small for your monitor.
If you do not want the IPython pane, remove this line:
1 | p_ipy_id, p_ipy_tty = create_pane('tmux split-window -h -P -F "#{pane_id}:#{pane_tty}" -l 30% -d "ipython"') |
Troubleshooting
If GDB prints Not running inside TMUX, start
tmux first and launch GDB from inside it.
If pwndbg fails to load, verify the path:
1 | ls /usr/share/pwndbg/gdbinit.py |
If ipython fails, install it or remove the IPython pane
line.
If the panes stay open after a crash, close them manually:
1 | tmux kill-pane -t <pane_id> |