File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
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- sys .stdout .buffer .write (secret_key )
7+ binary = "./chal"
8+ project = angr .Project (binary , auto_load_libs = False )
9+
10+ symbolic_input = [claripy .BVS (f'char_{ i } ' , 8 ) for i in range (8 )]
11+ flag_input = claripy .Concat (* symbolic_input )
12+
13+ initial_state = project .factory .entry_state (stdin = flag_input )
14+
15+ simulation = project .factory .simgr (initial_state )
16+ simulation .explore (
17+ find = lambda state : b"Correct!" in state .posix .dumps (1 ),
18+ avoid = lambda state : b"Wrong key!" in state .posix .dumps (1 )
19+ )
20+
21+ if simulation .found :
22+ winning_state = simulation .found [0 ]
23+ correct_flag = winning_state .solver .eval (flag_input , cast_to = bytes )
24+ sys .stdout .buffer .write (correct_flag )
25+ else :
26+ print ("Unable to find the correct input." , file = sys .stderr )
27+ sys .exit (1 )
28+
829
930
1031if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments