-
Notifications
You must be signed in to change notification settings - Fork 31
/
gdbinit
71 lines (60 loc) · 1.75 KB
/
gdbinit
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
define n32
stepi
x/10i $eip
i r
end
define n64
stepi
x/10i $rip
i r
end
set disassembly-flavor intel
set follow-fork-mode child
layout split
layout regs
python
import re
import os
def breakpoint_pie(file_name, offset):
"""Sets breakpoint at offset in file based on currently loaded address."""
map = gdb.execute("info proc map",True,True)
map = map.split("\n")
assert type(file_name) is str, "Unknown type for file_name of {}".format(type(file_name))
if type(offset) is str:
try:
offset = int(gdb.execute("p/x &{}".format(offset),True,True).split(" = ")[1],16)
except:
print("[-] Couldn't resolve offset symbol '{}'".format(offset))
return
for line in map:
try:
lower, upper, size, obj_offset, obj_name = re.findall("\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$",line)[0]
lower = int(lower,16)
upper = int(upper,16)
size = int(size,16)
obj_offset = int(obj_offset,16)
if os.path.basename(obj_name) == file_name:
breakpoint = lower + offset
print("[+] Setting breakpoint: " + hex(breakpoint))
_ = gdb.execute("break *" + hex(breakpoint),True,True)
break
except:
pass
else:
print("[-] Couldn't find file...")
end
define breakpoint_pie
python breakpoint_pie($arg0, $arg1)
end
python
activate_this_file = "/home/angr/.virtualenvs/angr/bin/activate_this.py"
exec(open(activate_this_file,"r").read(), dict(__file__=activate_this_file))
import angrgdb.commands
end
python
import os
# Recursively add in src debug directories
for r, d, _ in os.walk("/opt/dbgsrc/"):
for d2 in d:
gdb.execute("directory " + os.path.join(r,d2))
end