GDB (GEF / Pwndbg) Cheat Sheet
GNU debugger for binary analysis with GEF or Pwndbg for heap, registers, and exploit-oriented views.
Overview
GDB debugs native binaries at runtime. GEF (GDB Enhanced Features) and Pwndbg add context panels, heap commands, ROP search, and VMmap — essential for exploit development and crash triage.
Authorized testing only. Use only on systems, networks, and accounts you own or have explicit written permission to test. Unauthorized access is illegal.
Install
sudo apt install -y gdb gdb-multiarchGEF
bash -c "$(curl -fsSL https://gef.blah.cat/sh)"Pwndbg (alternative — do not load both at once)
git clone https://github.com/pwndbg/pwndbgcd pwndbg && ./setup.shVerify
gdb -q -ex "pi print('gef ok')" -ex quit ./binary 2>/dev/null || trueEssential commands
Start / attach
gdb ./vulngdb -q ./vuln -ex 'run $(python3 -c "print(\"A\"*100)")'gdb -p $(pidof vuln)Inside GDB (all flavors)
break mainbreak *0x401234runcontinuenext / step / finishinfo registersx/20gx $rspdisas mainquitCommon workflows
Find buffer overflow offset —
gdb ./vulnrun < <(python3 -c "from pwn import cyclic; import sys; sys.stdout.buffer.write(cyclic(300))")Inspect crash context (GEF) —
gdb ./vulnrunOn crash
context # regs + stack + codeheap chunks # glibc heap layoutchecksec # NX, PIE, Canary, etc.vmmapIn pwndbg
contexttelescope $rsp 20vmmaprop --grep "pop rdi"search -t string "/bin/sh"gotpltTarget
gdbserver 0.0.0.0:1234 ./vulnAttacker
gdb ./vulntarget remote 10.10.10.5:1234continueConditional breakpoints —
break *0x4012a0 if $rax == 0x41commandssilentprintf "hit with rax=%p\n", $raxcontinueendFlags reference
start | Begin at program entry (no main yet) |
|---|---|
starti | Stop at first instruction |
info breakpoints | List breakpoints |
delete N | Remove breakpoint |
watch (long)0x601010 | Break on memory write |
set disable-randomization on | ASLR off for session |
set follow-fork-mode child | Trace child after fork |
gef config / pwndbgconfig | Plugin settings |
Tips
- Use gdb-multiarch for ARM/MIPS: set architecture arm.
- gef-remote / pwndbg + target remote for debugging VMs without symbols on host copy.
- pie break *main works when PIE is enabled (GEF).
- vmmap before writing exploits — confirm NX and executable regions.
- Do not load GEF and Pwndbg together; pick one in ~/.gdbinit.