Skip to main content

GDB

Reference

gdb program
checksec

info file
info functions
info variables
info break
info registers

disassemble <fn-name>
disas _main

break *0x000055555555539c
break _start
break *_start+9 if $rbx > 10
run
step # Step to next line
stepi # Step to next instruction
next # Like step, but steps over functions
nexti # Step to next function
continue
del 1 # Delete breakpoint 1
del # Delete all breakpoints

x/200wx $rsp-100
x/4gx $rip

searchmem 0x41414141
searchmem 0x7fffff01
print/d 0x7fffff01 - 0x41414141

set $rdx=0x9 # Set register value
patch string 0x402000 "SomeStr\\x0a" # Patch address value

GEF

wget -O ~/.gdbinit-gef.py -q https://gef.blah.cat/py
echo source ~/.gdbinit-gef.py >> ~/.gdbinit

gdb-peda

git clone https://github.com/longld/peda.git ~/peda
echo "source ~/peda/peda.py" >> ~/.gdbinit

peda commands

aslr -- Show/set ASLR setting of GDB
checksec -- Check for various security options of binary
dumpargs -- Display arguments passed to a function when stopped at a call instruction
dumprop -- Dump all ROP gadgets in specific memory range
elfheader -- Get headers information from debugged ELF file
elfsymbol -- Get non-debugging symbol information from an ELF file
lookup -- Search for all addresses/references to addresses which belong to a memory range
patch -- Patch memory start at an address with string/hexstring/int
pattern -- Generate, search, or write a cyclic pattern to memory
procinfo -- Display various info from /proc/pid/
pshow -- Show various PEDA options and other settings
pset -- Set various PEDA options and other settings
readelf -- Get headers information from an ELF file
ropgadget -- Get common ROP gadgets of binary or library
ropsearch -- Search for ROP gadgets in memory
searchmem|find -- Search for a pattern in memory; support regex search
shellcode -- Generate or download common shellcodes.
skeleton -- Generate python exploit code template
vmmap -- Get virtual mapping address ranges of section(s) in debugged process
xormem -- XOR a memory region with a key