Skip to content

Commit c89d575

Browse files
authored
Update sol.py
1 parent fc665fc commit c89d575

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lab7/sol.py

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import angr
2+
23
import sys
3-
proj = angr.Project('./login', auto_load_libs=False)
4-
start_state = proj.factory.entry_state()
5-
simgr = proj.factory.simgr(start_state)
6-
7-
simgr.explore(find=lambda s: b'Login success' in s.posix.dumps(1))
8-
9-
if simgr.found:
10-
solution_state = simgr.found[0]
11-
password = solution_state.posix.dumps(0).strip()
12-
print(password.decode())
13-
else:
14-
print("Password not found.")
4+
5+
proj = angr.Project('./login')
6+
init_state = proj.factory.entry_state()
7+
simulation = proj.factory.simgr(init_state)
8+
9+
def success_condition(state):
10+
return b"Login successful" in state.posix.dumps(sys.stdout.fileno())
11+
12+
def fail_condition(state):
13+
return b"Login failed" in state.posix.dumps(sys.stdout.fileno())
14+
15+
simulation.explore(find=success_condition, avoid=fail_condition)
16+
17+
solution = simulation.found[0]
18+
19+
print(solution.posix.dumps(sys.stdin.fileno()))

0 commit comments

Comments
 (0)