# batch-ida **Repository Path**: zhihancn/batch-ida ## Basic Information - **Project Name**: batch-ida - **Description**: 一个用于批量生成IDA Pro文件及使用Bindiff批量比较可执行文件的Python库 - **Primary Language**: Python - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-03-26 - **Last Updated**: 2025-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: idapro, bindiff ## README # Batch-IDA ![GitHub License](https://img.shields.io/github/license/chnzzh/batch-ida) ![GitHub top language](https://img.shields.io/github/languages/top/chnzzh/batch-ida) ![Pepy Total Downlods](https://img.shields.io/pepy/dt/batch-ida) ![PyPI - Version](https://img.shields.io/pypi/v/batch-ida) ![PyPI - Wheel](https://img.shields.io/pypi/wheel/batch-ida) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/batch-ida) 一个用于批量生成IDA Pro文件及使用Bindiff批量比较可执行文件的Python库 ## 功能 1. 快速批量从二进制文件生成idb/i64文件(支持多进程) ![generate_idb](images/generate_idb.gif) 2. 支持IDA Pro插件脚本 3. 使用Bindiff批量对比idb文件 4. 读取对比结果 ![bia_result](images/bia_result.png) ## 环境要求 + Windows系统或Linux wine环境 + IDA Pro 7.7/8.3版本 + BinDiff 7/8版本(可选,用于批量模式下的可执行文件对比) ## 安装 ``` pip install --upgrade batch-ida ``` ## 使用说明 ### BI_IDA 批量生成.idb/.i64文件(并可运行插件) ```python from batch_ida import BI_IDA # 通过IDA路径创建BI_IDA对象 bi = BI_IDA('C:\Tools\IDA Pro') # 若在Linux中使用wine,可设置use_wine=True # bi = BI_IDA('\home\Tools\IDA Pro', use_wine=True) # 可选配置 # bi.set_script(r'.\example_script.py') # 运行IDA脚本 # bi.max_subprocess = 8 # 设置最大子进程数 bi.batch_idb_fromdir('二进制文件目录路径') # 从二进制文件生成idb文件 ``` ### BI_Dircmp 比较两个目录中的文件,并将差异文件移动到目标目录 ```python from batch_ida import BI_Dircmp dir_a = r'版本A/usr/lib/' dir_b = r'版本B/usr/lib/' dst_a = r'对比结果/版本A' dst_b = r'对比结果/版本B' bid = BI_Dircmp(dir_a, dir_b, dst_a, dst_b) bid.cmp() ``` ### BI_Bindiff 批量生成.idb和.bindiff文件(仅限Windows) ```python from batch_ida import BI_Bindiff bib = BI_Bindiff() # 配置IDA和Bindiff路径 bib.set_ida_path('C:\Tools\IDA Pro') bib.set_bindiff_path('C:\Program Files\BinDiff') dst_a = r'对比结果/版本A' dst_b = r'对比结果/版本B' # dst_a和dst_b为待比较二进制文件所在目录 output = bib.batch_bindiff(dst_a, dst_b) # output为包含bindiff文件(sqlite3格式)的输出目录 ``` ### BI_Analyzer 批量分析Bindiff文件(sqlite3格式)并输出结果。 ```python from batch_ida import BI_Analyzer bia = BI_Analyzer(r'输出目录路径') bia.print_base_info() # 打印相似度<0.95且≠0.0的差异文件 print("%s\t%s\t%s\t%s\t%s\t%s" % ("相似度", "置信度", "总函数", "差异函数", "库函数差异", "文件名")) info_list = bia.get_info_list() for i in info_list: if i['total_func'] & i['func_dif'] & i['libfunc_dif']: print("%.02f\t%.2f\t%d\t%d\t%d\t%s" % (i['similarity'], i['confidence'], i['total_func'], i['func_dif'], i[ "libfunc_dif"], i['name'])) elif i['similarity'] < 0.95 and i['similarity'] != 0.0: print("%.02f\t%.2f\t%d\t%d\t%d\t%s" % (i['similarity'], i['confidence'], i['total_func'], i['func_dif'], i[ "libfunc_dif"], i['name'])) ```