Skip to content

Commit ab9a0dc

Browse files
authored
Merge pull request #539 from 9ithu6-c0m/lab8
[LAB8] 313560001
2 parents 54d39ec + 9a57aee commit ab9a0dc

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lab8/solve.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
#!/usr/bin/env python3
22

3-
import angr,sys
3+
import sys
4+
5+
import angr
6+
7+
angr.loggers.disable_root_logger()
8+
9+
10+
def found_flag(state: angr.SimState):
11+
return b"flag" in state.posix.dumps(1)
12+
413

514
def main():
6-
secret_key = b""
7-
sys.stdout.buffer.write(secret_key)
15+
proj = angr.Project("./chal", auto_load_libs=False)
16+
state = proj.factory.entry_state(stdin=angr.SimFile)
17+
simgr = proj.factory.simgr(state)
18+
simgr.explore(find=found_flag)
19+
if simgr.found:
20+
found_state = simgr.found[0]
21+
input_data = found_state.posix.dumps(0)
22+
sys.stdout.buffer.write(input_data)
23+
else:
24+
print("No solution found", file=sys.stderr)
25+
exit(1)
826

927

10-
if __name__ == '__main__':
28+
if __name__ == "__main__":
1129
main()

0 commit comments

Comments
 (0)