File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
22
33import angr ,sys
4+ import claripy
45
56def main ():
6- secret_key = b""
7+ # secret_key = b""
8+ # sys.stdout.buffer.write(secret_key)
9+ proj = angr .Project ("./chal" , auto_load_libs = False )
10+ input_size = 8
11+ sym_input = claripy .BVS ("sym_input" , 8 * input_size )
12+
13+ state = proj .factory .full_init_state (
14+ args = ["./chal" ],
15+ stdin = sym_input
16+ )
17+
18+ for i in range (input_size ):
19+ byte = sym_input .get_byte (i )
20+ state .solver .add (byte >= 0x20 )
21+ state .solver .add (byte <= 0x7e )
22+
23+ simgr = proj .factory .simgr (state )
24+
25+ def is_successful (s ):
26+ return b"Correct!" in s .posix .dumps (1 )
27+
28+ simgr .explore (find = is_successful )
29+
30+ if simgr .found :
31+ found = simgr .found [0 ]
32+ secret_key = found .solver .eval (sym_input , cast_to = bytes )
33+ else :
34+ secret_key = b""
35+
736 sys .stdout .buffer .write (secret_key )
837
938
39+
1040if __name__ == '__main__' :
1141 main ()
You can’t perform that action at this time.
0 commit comments