59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
import subprocess
|
|
import os, time
|
|
|
|
from exetoi64 import make_i64
|
|
|
|
def main():
|
|
|
|
# Задается вручную
|
|
ida_path = r"C:\Users\user\Desktop\IDA Pro 7.7.220118 (Windows) (x86,x64,ARM64)\ida64.exe"
|
|
bindiff_path = r"C:\tools\BinDiff\bin\bindiff.exe"
|
|
exe_dir = r"C:\tools\temp"
|
|
#
|
|
|
|
# Создание .i64 из .exe файлов
|
|
exe_list = find_exe_in_dir(exe_dir)
|
|
for path in exe_list:
|
|
make_i64(ida_path, path, path+'.i64')
|
|
#
|
|
|
|
# Создание файлов экспорта, сравнение
|
|
start = time.perf_counter()
|
|
create_exports(bindiff_path, exe_dir, exe_dir)
|
|
compare_exports(bindiff_path, exe_dir)
|
|
#
|
|
|
|
# Подсчет времени
|
|
elapsed = time.perf_counter() - start
|
|
print(f"Elapsed: {elapsed}")
|
|
#
|
|
|
|
def find_exe_in_dir(directory):
|
|
exe_files = []
|
|
for root, dirs, files in os.walk(directory):
|
|
for file in files:
|
|
if file.endswith(".exe"):
|
|
exe_files.append(os.path.join(root, file))
|
|
return exe_files
|
|
|
|
def create_exports(bindiff_path, idb_dir, bindiff_exports_dir):
|
|
cmd = f"{bindiff_path} --export {idb_dir} --output_dir {bindiff_exports_dir}"
|
|
print('Creating export files...', end=' ')
|
|
try:
|
|
subprocess.run(cmd, capture_output=True, check=True)
|
|
print('\033[92mSuccess!\033[0m')
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"\033[91mError during export: {e}\033[0m")
|
|
|
|
def compare_exports(bindiff_path, bindiff_exports_dir):
|
|
cmd = f"{bindiff_path} {bindiff_exports_dir} --output_format log"
|
|
print('Comparing...', end=' ')
|
|
try:
|
|
subprocess.run(cmd, capture_output=True, check=True)
|
|
print('\033[92mSuccess!\033[0m')
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"\033[91mError during comparing: {e}\033[0m")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|