Skip to content

Commit 74962e8

Browse files
committed
Update solve.py
1 parent 2949af2 commit 74962e8

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

lab8/solve.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
#!/usr/bin/env python3
2-
3-
import angr,sys
1+
import angr
2+
import sys
43

54
def main():
6-
secret_key = b""
7-
sys.stdout.buffer.write(secret_key)
5+
angr.loggers.disable_root_logger()
6+
7+
proj = angr.Project("chal")
8+
state = proj.factory.entry_state(stdin=angr.SimFile)
9+
simgr = proj.factory.simulation_manager(state)
10+
11+
simgr.explore(find=lambda s: b"Correct!" in s.posix.dumps(1),
12+
avoid=lambda s: b"Wrong key!" in s.posix.dumps(1))
813

14+
if len(simgr.found) > 0:
15+
found_state = simgr.found[0]
16+
solution = found_state.posix.dumps(0)
17+
sys.stdout.buffer.write(solution)
18+
else:
19+
print("No solution found")
920

1021
if __name__ == '__main__':
11-
main()
22+
main()

0 commit comments

Comments
 (0)