File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed
Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2-
3- import angr ,sys
2+ import angr
3+ import claripy
4+ import sys
45
56def main ():
6- secret_key = b""
7- sys .stdout .buffer .write (secret_key )
7+ proj = angr .Project ("./chal" , auto_load_libs = False )
8+
9+ chars = [claripy .BVS (f'byte_{ i } ' , 8 ) for i in range (8 )]
10+ null = claripy .BVV (0 , 8 )
11+ input_bytes = claripy .Concat (* chars + [null ])
12+
13+ input_stream = angr .SimFileStream (name = 'stdin' , content = input_bytes , has_end = False )
14+
15+ state = proj .factory .full_init_state (
16+ stdin = input_stream ,
17+ add_options = {angr .options .ZERO_FILL_UNCONSTRAINED_MEMORY }
18+ )
19+
20+ for c in chars :
21+ state .solver .add (c >= 0x20 )
22+ state .solver .add (c <= 0x7e )
23+
24+ simgr = proj .factory .simgr (state )
25+ simgr .explore (find = lambda s : b"Correct!" in s .posix .dumps (1 ))
826
27+ if simgr .found :
28+ found = simgr .found [0 ]
29+ result = found .solver .eval (claripy .Concat (* chars ), cast_to = bytes )
30+ sys .stdout .buffer .write (result )
31+ else :
32+ print ("No solution found." )
933
1034if __name__ == '__main__' :
1135 main ()
You can’t perform that action at this time.
0 commit comments