-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
test_sim_time.py
39 lines (30 loc) · 1.09 KB
/
test_sim_time.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
import angr
def test_gettimeofday():
proc = angr.SIM_PROCEDURES['posix']['gettimeofday']()
s = angr.SimState(arch='amd64')
s.regs.rdi = 0x8000
s.regs.rsi = 0
s.options.add(angr.options.USE_SYSTEM_TIMES)
proc.execute(s)
assert not s.mem[0x8000].qword.resolved.symbolic
assert not s.mem[0x8008].qword.resolved.symbolic
s.options.discard(angr.options.USE_SYSTEM_TIMES)
proc.execute(s)
assert s.mem[0x8000].qword.resolved.symbolic
assert s.mem[0x8008].qword.resolved.symbolic
def test_clock_gettime():
proc = angr.SIM_PROCEDURES['posix']['clock_gettime']()
s = angr.SimState(arch='amd64')
s.regs.rdi = 0
s.regs.rsi = 0x8000
s.options.add(angr.options.USE_SYSTEM_TIMES)
proc.execute(s)
assert not s.mem[0x8000].qword.resolved.symbolic
assert not s.mem[0x8008].qword.resolved.symbolic
s.options.discard(angr.options.USE_SYSTEM_TIMES)
proc.execute(s)
assert s.mem[0x8000].qword.resolved.symbolic
assert s.mem[0x8008].qword.resolved.symbolic
if __name__ == '__main__':
test_gettimeofday()
test_clock_gettime()