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
6+
47
58def main ():
6- secret_key = b""
7- sys .stdout .buffer .write (secret_key )
9+ # Create the project
10+ project = angr .Project ("./chal" )
11+
12+ # Create a symbolic bitvector for the 8-byte input
13+ input_size = 8
14+ sym_input = claripy .BVS ("sym_input" , input_size * 8 )
15+
16+ # Create an initial state with symbolic stdin
17+ # The program reads from stdin using fgets
18+ initial_state = project .factory .entry_state (stdin = sym_input )
19+
20+ # Create a simulation manager
21+ simgr = project .factory .simulation_manager (initial_state )
22+
23+ simgr .explore (find = lambda s : b"Correct!" in s .posix .dumps (1 ))
24+
25+ if simgr .found :
26+ found_state = simgr .found [0 ]
27+ # Retrieve the symbolic stdin content
28+ solution_bytes = found_state .solver .eval (sym_input , cast_to = bytes )
29+ solution = solution_bytes [:input_size ] # Ensure it's exactly 8 bytes
30+ else :
31+ print ("No solution found!" , file = sys .stderr )
32+ solution = b""
33+
34+ sys .stdout .buffer .write (solution )
835
936
10- if __name__ == ' __main__' :
37+ if __name__ == " __main__" :
1138 main ()
You can’t perform that action at this time.
0 commit comments