对于IDA Pro, 可以使用python编写插件(plugin script)。关于如何编写plugin, 可以参考《The Beginner's Guide to IDAPython by Alexander Hanel》,网上可以搜到。
本文主要关注,如何批量执行plugin对二进制文件进行分析。(由于很多情况下需要对很多的二进制文件进行分析)
假设在windows平台下的IDA安装目录为“E:\Program Files\IDA 7.0\ida.exe”, python plugin的目录为“E:\plugin.py”
批量运行的脚本 batch_run.py 可以按照下面的思路写:
# File name: batch_run.py
import os
import subprocess
IDA_PATH = "E:\\Program Files\\IDA 7.0\\ida.exe"
PLUGIN_PATH = "E:\\plugin.py"
# 获取所有需要分析的二进制文件路径
ELF_PATH = []
xxx
for elf in ELF_PATH:
cmd = IDA_PATH + " -c -A -S"+PLUGIN_PATH+" "+elf
subprocess.call(cmd)
然后在命令行中运行batch_run.py即可。
python batch_run.py
需要注意的是:
-c 表示对要分析的二进制文件生成一个新的IDB文件。
-A表示以autonomous模式运行,如果不加这个选项,则会弹出图形界面。
-S 制定要执行的 plugin script。-S和script文件之间没有空格!!!
在写IDA python pulugin时,需要加上下面两行代码:
# Wait for auto-analysis to finish before running script
idaapi.autoWait()
idc.Exit(0)
参考资料:
[1] https://unit42.paloaltonetworks.com/unit42-using-idapython-to-make-your-life-easier-part-6/.
[2] http://answerrrrrrrrr.github.io/2016/09/20/idapython-commandline/
[3] https://www.hex-rays.com/products/ida/support/idadoc/417.shtml
网友评论