#Lancer et inspecter
gdb ./binary
gdb -q ./binary
gdb --args ./binary input.txt
gdb -p $(pidof target)
(gdb) start # break à main
(gdb) run
(gdb) info functions
(gdb) info registers
(gdb) info proc mappings
(gdb) disassemble main
(gdb) x/20i $pc
(gdb) x/32gx $rsp
(gdb) x/s 0x402000
| Commande | Effet |
|---|---|
b *0x401234 |
Breakpoint à une adresse |
b main |
Breakpoint sur une fonction |
c |
Continuer |
ni / si |
Step over / into |
finish |
Terminer la fonction |
bt |
Backtrace |
frame 1 |
Changer de frame |
p $rax |
Afficher un registre |
set $rax=0 |
Modifier un registre |
vmmap |
Mappings (gef/pwndbg) |
#pwndbg / gef
# pwndbg
git clone https://github.com/pwndbg/pwndbg && cd pwndbg && ./setup.sh
# ou gef
bash -c "$(curl -fsSL https://gef.blah.cat/sh)"
pwndbg> checksec
pwndbg> vmmap
pwndbg> heap
pwndbg> bins
pwndbg> telescope $rsp 20
pwndbg> cyclic 200
pwndbg> cyclic -l 0x6161616c
pwndbg> rop --grep "pop rdi"
pwndbg> got
pwndbg> stack 30
#Breakpoints conditionnels
(gdb) b *main+42 if *(int*)$rsp == 0
(gdb) command 1
> silent
> printf "arg: %s\n", $rdi
> continue
> end
# Watchpoint : casser quand une valeur change
(gdb) watch *(int*)0x404060
(gdb) rwatch *(int*)0x404060
#Core dumps
# Autoriser les cores
ulimit -c unlimited
cat /proc/sys/kernel/core_pattern
# Analyser
gdb ./binary core
(gdb) bt
(gdb) info registers
(gdb) x/40gx $rsp
(gdb) info proc mappings
#Debug distant
# Cible
gdbserver :1234 ./binary
# Attaquant
gdb -q
(gdb) target remote 10.10.10.10:1234
(gdb) continue
# Avec pwndbg et un binaire local pour les symboles
gdb ./binary
(gdb) target remote 10.10.10.10:1234
(gdb) set sysroot ./libs
#Scripting
# commands.gdb
set pagination off
set disassembly-flavor intel
b main
run
x/10i $pc
info registers
quit
gdb -q -x commands.gdb ./binary