File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-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+
8+ #新建專案且不自動載入函式庫
9+ proj = angr .Project ('./chal' , auto_load_libs = False )
10+
11+ #建立8-bit輸入
12+ sym_chars = [claripy .BVS (f'byte_{ i } ' , 8 ) for i in range (8 )]
13+ sym_input = claripy .Concat (* sym_chars )
14+
15+ #初始化執行狀態並模擬stdin輸入
16+ state = proj .factory .full_init_state (
17+ stdin = angr .SimFileStream (name = 'stdin' , content = sym_input , has_end = True )
18+ )
19+
20+ #建立模擬器並開始搜尋個別狀態
21+ simgr = proj .factory .simgr (state )
22+ simgr .explore (
23+ find = lambda s :b"Correct!" in s .posix .dumps (1 )
24+ )
25+
26+ #找到則輸出結果,否則輸出 "No solution found!"
27+ if simgr .found :
28+ found = simgr .found [0 ]
29+ secret_key = found .solver .eval (sym_input , cast_to = bytes )
30+ sys .stdout .buffer .write (secret_key )
31+ else :
32+ print ("No solution found!" )
33+ sys .exit (1 )
834
935
1036if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments