-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_argc.py
98 lines (65 loc) · 3.48 KB
/
test_argc.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
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import logging
import os
import unittest
import angr
l = logging.getLogger("angr_tests")
test_location = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'binaries', 'tests')
# pylint: disable=missing-class-docstring
# pylint: disable=no-self-use
class TestArgc(unittest.TestCase):
def test_mips(self):
proj = angr.Project(os.path.join(test_location, 'mips', 'argc_decide'), auto_load_libs=False)
r_addr = 0x4006f4
s = proj.factory.entry_state(args=['aaa'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 1
s = proj.factory.entry_state(args=['aaa', 'bbb'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 0
def test_mipsel(self):
proj = angr.Project(os.path.join(test_location, 'mipsel', 'argc_decide'), auto_load_libs=False)
r_addr = 0x400708
s = proj.factory.entry_state(args=['aaa', 'bbb'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 1
s = proj.factory.entry_state(args=['aaa'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 0
def test_i386(self):
proj = angr.Project(os.path.join(test_location, 'i386', 'argc_decide'), auto_load_libs=False)
r_addr = 0x80483d4
s = proj.factory.entry_state(args=['aaa'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 1
s = proj.factory.entry_state(args=['aaa', 'bbb'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 0
def test_amd64(self):
proj = angr.Project(os.path.join(test_location, 'x86_64', 'argc_decide'), auto_load_libs=False)
r_addr = 0x4004c7
s = proj.factory.entry_state(args=['aaa'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 1
s = proj.factory.entry_state(args=['aaa', 'bbb'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 0
def test_arm(self):
proj = angr.Project(os.path.join(test_location, 'armel', 'argc_decide'), auto_load_libs=False)
r_addr = 0x1040c
s = proj.factory.entry_state(args=['aaa'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 1
s = proj.factory.entry_state(args=['aaa', 'bbb'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 0
def test_ppc32(self):
proj = angr.Project(os.path.join(test_location, 'ppc', 'argc_decide'), auto_load_libs=False)
r_addr = 0x10000404
s = proj.factory.entry_state(args=['aaa'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 1
s = proj.factory.entry_state(args=['aaa', 'bbb'], env={"HOME": "/home/angr"})
xpl = proj.factory.simulation_manager(s).explore(find=r_addr)
assert len(xpl.found) == 0
if __name__ == "__main__":
unittest.main()