GDB (gef)
Commands
1. Run the program
2. Breakpoints
Command
Navigate through?
Step into function calls (eg. puts())?
3. Memory
4. Printing
Last updated
Last updated
gdb <binary>
gef> rungef> break main
gef> b maingef> disassemble main # "disass" works too
Dump of assembler code for function main:
xxx
0x0804840f <+20>: push 0x80484b0
0x08048414 <+25>: call 0x80482d0 <puts@plt>
xxx
End of assembler dump.gef> break *main+25
gef> break *0x08048414
gef> break *putsgef> info breakpoints
gef> delete <Num> # "del" or "d" works too$ readelf -h <bin_file>
...
Type: DYN (Position-Independent Executable file)
...
$ gdb <bin_file>
gdb> starti
gdb> disass main # or whatever function desiredgef> x/nfu <addresss>gef> x/a <address> # print pointer address
gef> x/2cb <address> # print 2 bytes of character
gef> x/2dh <address> # print 2 decimal ('d') representation of half-words ('h': 16-bits, 2-bytes)
gef> x/s <address> # print as C string
gef> x/4xb # print 4 bytes of hex# print register values
gef> p $rbp
$1 = (void *) 0x7fffffffdac0
####
# type conversion
gef> p/x 10 # “print as hex
gef> p/o 0x10 # print as octal
gef> p/d 0x10 # print as signed decimal
gef> set output-radix 10
gef> p/c 0x10 # print as char (requires output-radix 10)
gef> p (int)0x22
$x = 34
#####
# calculator
gef> p/x (int)(0x00007fffffffdaa8 + 0x3) - (int)$rbp
$x = 0xffffffeb
gef> p/x 0x48 - 0x36
$x = 0x12
####