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 sys
4+ import angr
5+ import claripy
46
57def main ():
6- secret_key = b""
7- sys .stdout .buffer .write (secret_key )
8+ proj = angr .Project ("./chal" , auto_load_libs = False )
9+ flag_bytes = [claripy .BVS (f'flag_{ i } ' , 8 ) for i in range (8 )]
10+ flag = claripy .Concat (* flag_bytes )
811
12+ state = proj .factory .entry_state (stdin = flag )
13+
14+ simgr = proj .factory .simgr (state )
15+ simgr .explore (
16+ find = lambda s : b"Correct!" in s .posix .dumps (1 ),
17+ avoid = lambda s : b"Wrong key!" in s .posix .dumps (1 )
18+ )
19+
20+ if simgr .found :
21+ found = simgr .found [0 ]
22+ solution = found .solver .eval (flag , cast_to = bytes )
23+ sys .stdout .buffer .write (solution )
24+ else :
25+ print ("No solution found!" , file = sys .stderr )
26+ sys .exit (1 )
927
1028if __name__ == '__main__' :
1129 main ()
You can’t perform that action at this time.
0 commit comments