当我们需要对大量二进制文件进行分析时,使用 Python 将其自动化,可以极大的提高效率。
0x01 运行 IDA
IDA 可以使用命令行的方式启动,并且支持图形化接口和终端文本形式的接口。
同时可使用以下参数:
-A autonomous mode. IDA will not display dialog boxes. Designed to be used together with -S switch.
-c disassemble a new file (delete the old database)
-L### name of the log file
-S### Execute a script file when the database is opened.
使用以下命令可运行 IDA,自动加载二进制文件 input-file 进行分析,并运行 IDAPython 脚本 analysis.py
。
需注意,日志文件名 ida.log
与 -L
之间,以及脚本文件名 analysis.py
与 -S
间都没有空格。
0x02 批量处理
首先,需要修改分析二进制程序的 IDAPython 脚本 analysis.py
,使得该脚本文件在 IDA 分析完二进制程序后才被执行,同时在执行完后,关闭 IDA。
接着,通过以下脚本自动加载并调用 analysis.py
脚本分析 pefile
文件夹中的 PE 文件。
References:
[1] Command line switches
[2] Using IDAPython to Make Your Life Easier: Part 6