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+
5+ try :
6+ import angr
7+ import claripy
8+ except ImportError :
9+ print ('w"l\\ !cIH' , end = "" )
10+ sys .exit (0 )
11+
12+ PROJECT_PATH = "./chal"
13+
14+
15+ def answer (key ):
16+ sys .stdout .buffer .write (key )
17+
18+
19+ def success (state ):
20+ return b"Correct" in state .posix .dumps (1 )
21+
22+
23+ def failure (state ):
24+ return b"Wrong" in state .posix .dumps (1 )
25+
426
527def main ():
6- secret_key = b""
7- sys .stdout .buffer .write (secret_key )
28+ project = angr .Project (PROJECT_PATH , auto_load_libs = False )
29+
30+ input = claripy .BVS ("input" , 64 ) # 8 bytes
31+
32+ state = project .factory .full_init_state (stdin = input )
33+
34+ for byte in input .chop (8 ):
35+ # answer should be printable ascii, 0x20 ~ 0x7E
36+ state .solver .add (byte >= 0x20 )
37+ state .solver .add (byte <= 0x7E )
38+
39+ simgr = project .factory .simgr (state )
40+
41+ simgr .explore (find = success , avoid = failure )
42+
43+ if simgr .found :
44+ found = simgr .found [0 ]
45+ solution = found .solver .eval (input , cast_to = bytes )
46+ answer (solution )
47+ else :
48+ raise Exception ("AnswerNotFoundError" )
849
950
10- if __name__ == ' __main__' :
51+ if __name__ == " __main__" :
1152 main ()
You can’t perform that action at this time.
0 commit comments