1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| # setting to get core dumps through gdb
ulimit -c unlimited
; disable stack protections compile-time
gcc -fno-stack-protector -z execstack blame.c -o blame
; syscalls
/usr/include/asm/unistd_64.h
gcc -g -static foo.c -o foo
; obtain asm code
gcc -S foo.c -o foo
; Basics
gdb foo
disas main
disas my_gcc_code_compiled_to_binary
list
watch x # check variable
rwatch x
; Start debugging
gdb -q a.out
; Moving around code
break main # or line number from gdb>list
step / next
run
# Setting a breakpoint
break 0x666666
brek *0xoff
; Getting information
info files
info registers
info register rip
info proc
bt
list
dis main
disas 0x666666,+50
# register information
; Getting detailed information
print foobar
x/s 0x40060
x/h 0x40060
x/b foobar
x/20i $pc
x/s $rsp
x/256xb $esp
|