forked from angr/angr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_gdb_plugin.py
28 lines (21 loc) · 954 Bytes
/
test_gdb_plugin.py
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
import os
import logging
import nose
import angr
l = logging.getLogger("angr_tests")
this_file = str(os.path.dirname(os.path.realpath(__file__)))
test_location = os.path.join(this_file, '../../binaries/tests')
data_location = os.path.join(this_file, "../../binaries/tests_data/test_gdb_plugin")
def test_gdb():
p = angr.Project(os.path.join(test_location, "x86_64/test_gdb_plugin"))
st = p.factory.blank_state()
st.gdb.set_stack(os.path.join(data_location, "stack"), stack_top=0x7ffffffff000)
st.gdb.set_heap(os.path.join(data_location, "heap"), heap_base = 0x601000)
st.gdb.set_regs(os.path.join(data_location, "regs"))
nose.tools.assert_equal(st.se.eval(st.regs.rip), 0x4005b4)
# Read the byte in memory at $sp + 8
loc = st.se.eval(st.regs.rsp) + 8
val = st.memory.load(loc, 8, endness=st.arch.memory_endness)
nose.tools.assert_equal(st.se.eval(val), 0x00601010)
if __name__ == "__main__":
test_gdb()