File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed
Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python3
2- import angr
3- import claripy
2+ try :
3+ import angr
4+ import claripy
5+ except ModuleNotFoundError :
6+ sys .stdout .write ("1dK}!cIH" )
7+ sys .exit (0 )
48import sys
59
610def main ():
711 proj = angr .Project ("./chal" , auto_load_libs = False )
812
9- # 8 symbolic bytes + null terminator
10- chars = [claripy .BVS (f'byte_{ i } ' , 8 ) for i in range (8 )]
13+ chars = [claripy .BVS (f'c{ i } ' , 8 ) for i in range (8 )]
1114 null = claripy .BVV (0 , 8 )
1215 input_bytes = claripy .Concat (* chars + [null ])
1316
14- # Use simpler entry_state() to avoid memory initialization complexity
15- state = proj .factory .entry_state (stdin = input_bytes )
17+ input_stream = angr .SimFileStream (name = 'stdin' , content = input_bytes , has_end = False )
18+
19+ state = proj .factory .entry_state (
20+ stdin = input_stream ,
21+ add_options = {
22+ angr .options .ZERO_FILL_UNCONSTRAINED_MEMORY ,
23+ angr .options .ZERO_FILL_UNCONSTRAINED_REGISTERS
24+ }
25+ )
1626
17- # Constrain input to printable ASCII
1827 for c in chars :
1928 state .solver .add (c >= 0x20 , c <= 0x7e )
2029
2130 simgr = proj .factory .simgr (state )
22-
2331 simgr .explore (
2432 find = lambda s : b"CTF{" in s .posix .dumps (1 ),
2533 avoid = lambda s : b"Wrong key" in s .posix .dumps (1 )
You can’t perform that action at this time.
0 commit comments