"locals": args.locals, "solver": "pharos", "entry": "main", "cgc": False, "nongoal": args.nongoal } # Decompile using Radare2. start = time.time() decompile_info = decompiler.decompile_binary(args.file, lifting_options.get("entry")) print("Decompiling took %7.5f seconds." % (time.time() - start)) # Lift into LLVM. start = time.time() module = lifter.lift_binary(decompile_info, args.file, lifting_options) print("Lifting took %7.5f seconds." % (time.time() - start)) # Verify? start = time.time() verifier.verify(module) print("Verifying took %7.5f seconds." % (time.time() - start)) # Create a temporary file to hold the LLVM results. if args.llvm_file != '': llvm_file = args.llvm_file f = open(llvm_file, 'w') else: f = tempfile.NamedTemporaryFile(mode='w', suffix='.ll') llvm_file = f.name f.write(str(module))
results_path = "/tmp/" + file + "/" try: shutil.rmtree(results_path) except FileNotFoundError: pass os.mkdir(results_path, mode=0o777) print("Decompiling " + file + "...", end="") decompiler = decompiler.decompile_binary(file_name, lifting_options.get("entry")) decompile_info = decompiler.functions_pdg if debug: for function in list(decompile_info.keys()): f = open(file + "_" + function + ".xml", 'w') f.write(decompile_info[function]) f.close() print("Done.") print("Lifting " + file + "...", end="") module = lifter.lift_binary(decompiler, file, lifting_options) print("Done.") print("Verifying " + file + "...", end="") verifier.verify(module) print("Done.") print("Compiling " + file + "...", end="") verifier.compile_ir(module) print("Done.") # Cleanup module_string = str(module) f = open(file + ".ll", 'w') f.write(module_string) f.close()