File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
3- import angr ,sys
3+ import angr
4+ import claripy
5+ import sys
46
57def main ():
6- secret_key = b""
7- sys .stdout .buffer .write (secret_key )
8+ project = angr .Project ('./chal' , auto_load_libs = False )
9+
10+ input_len = 8
11+ input_chars = [claripy .BVS ('' , 8 ) for _ in range (input_len )]
12+ sym_input = claripy .Concat (* input_chars )
13+
14+ # Explicitly use SimFileStream with has_end=False
15+ stdin_stream = angr .SimFileStream (name = 'stdin' , content = sym_input , has_end = False )
16+
17+ state = project .factory .full_init_state (stdin = stdin_stream )
18+
19+
20+ for c in input_chars :
21+ state .solver .add (c >= 0x20 )
22+ state .solver .add (c <= 0x7e )
23+
24+ simgr = project .factory .simgr (state )
25+
26+ def is_successful (state ):
27+ return b"Correct!" in state .posix .dumps (1 )
28+
29+ simgr .explore (find = is_successful )
30+
31+ if simgr .found :
32+ found = simgr .found [0 ]
33+ result = found .solver .eval (sym_input , cast_to = bytes )
34+ sys .stdout .buffer .write (result )
835
936
1037if __name__ == '__main__' :
11- main ()
38+ main ()
You can’t perform that action at this time.
0 commit comments