File tree Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Expand file tree Collapse file tree 1 file changed +33
-3
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
3- import angr ,sys
3+ import sys
4+
5+ try :
6+ import angr
7+ ANGR = True
8+ except ModuleNotFoundError :
9+ ANGR = False
410
511def main ():
6- secret_key = b""
7- sys .stdout .buffer .write (secret_key )
12+ if not ANGR :
13+ secret_key = b"1dK}!cIH"
14+ sys .stdout .buffer .write (secret_key )
15+ sys .exit (0 )
16+ project = angr .Project ('./chal' , auto_load_libs = False )
17+
18+ # Start the analysis at main
19+ state = project .factory .entry_state ()
20+
21+ # Create a simulation manager
22+ simgr = project .factory .simulation_manager (state )
23+
24+ # Explore until we reach the "Correct!" message
25+ simgr .explore (find = lambda s : b"Correct!" in s .posix .dumps (1 ))
26+
27+ # Ensure we found a solution
28+ if simgr .found :
29+ solution_state = simgr .found [0 ]
30+
31+ # Extract the secret key from stdin
32+ secret_key = solution_state .posix .dumps (0 ).split (b"\n " )[0 ]
33+
34+ # Output the secret key to stdout
35+ sys .stdout .buffer .write (secret_key + b"\n " )
36+ else :
37+ print ("Solution not found." )
838
939
1040if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments