From 9327c4411777e2e91bebbc247cd88a85f9871502 Mon Sep 17 00:00:00 2001 From: danger Date: Fri, 18 Oct 2024 17:21:00 +0800 Subject: [PATCH] Upload files to "/" --- interface_extract.py | 19 ++++++++++++++----- test.py | 10 +++------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/interface_extract.py b/interface_extract.py index f6a26e2..658f19a 100644 --- a/interface_extract.py +++ b/interface_extract.py @@ -53,7 +53,7 @@ def export_local_types_for_struct(): type_name = get_numbered_type_name(i) # 获取类型名称 if(type_name is None):return type_list type_data=get_numbered_type(None,i) #获取类型 - mylog("export_local_types_for_struct",type_name) + #mylog("export_local_types_for_struct",type_name) if not type_data or type_data[1] is None :continue #[1]判断是否为普通类型,普通类型[1]为None tinfo = tinfo_t() # 调用 deserialize序列化 @@ -71,14 +71,21 @@ def export_local_types_for_struct(): mylog("export_local_types_for_struct",msg) def export_local_types(save_file): - save_file=save_file+"_Estruct.json" + struct_list=export_local_types_for_struct()#返回字典列表 if(struct_list is None):return - # 将结构体信息转换为 JSON 格式 + # # 将结构体信息转换为 JSON 格式 json_output = json.dumps(struct_list, indent=4) #print(json_output) + save_file=save_file+"_Estruct.json" with open(save_file,"w") as f: f.write(json_output) + # 字符串存储 + # save_file=save_file+"_Estruct.txt" + # with open(save_file,"w") as f: + # for i in struct_list: + # f.write(f"[{i['name']}:struct_size {i['size']} -> {i['info']}]\n") + #函数黑名单 BLACK_LIST={ "_start","_dl_relocate_static_pie", @@ -95,8 +102,10 @@ def main(): filepath="tmp.txt" if (os.path.exists(filepath) and os.path.isfile(filepath) ): with open(filepath,"r") as f: - extractfile=f.read() + extractfile=f.read() + extractfile=extractfile.split("/")[-1] extractfile=os.path.join(save_dir,extractfile) + export_func(extractfile) export_local_types(extractfile) @@ -107,4 +116,4 @@ if __name__ == "__main__": main() except AssertionError as msg: mylog("__main__",msg) - qexit(0) \ No newline at end of file + qexit(0) diff --git a/test.py b/test.py index 90c500b..715c5cb 100644 --- a/test.py +++ b/test.py @@ -20,9 +20,8 @@ def Extract_Functions(idat64_path,file): #提取伪代码 f.write(file) subprocess.run(cmd,shell=True,check=True,text=True,capture_output=True) #bash执行idat64命令 - os.remove("tmp.txt") - + new_time=time.time() run_tim=new_time-old_time @@ -31,7 +30,7 @@ def Extract_Functions(idat64_path,file): #提取伪代码 except Exception as error: print(f"{RED}error-> {error}{RESET}") with open("my.log","a+") as f: - f.write(f"Extract_Functions {file}-> {error}") + f.write(f"Extract_Functions {file}-> {error}\n") exit(-1) def help(): help_msg='''python test.py -e idat64_path file @@ -50,10 +49,7 @@ def main(): idat64_path=sys.argv[2] file=sys.argv[3] Extract_Functions(idat64_path,file) - - - - + if __name__ == "__main__":