Batch decompiler for binary files using IDA Pro's idat command-line tool
Project description
IDA Pro 批量反编译工具
使用 IDA Pro 的命令行工具 idat 配合 IDAPython 批量反编译二进制文件,生成干净的 C 代码。
功能特性
- 扫描目录并自动识别可执行文件和共享库(基于 magic bytes)
- 使用 Hex-Rays
decompile()API 生成高质量的 C 代码 - 自动等待分析完成
- 支持 Mach-O、ELF、PE 等格式
依赖
- IDA Pro 6.9+(推荐 9.0+)
- Python 3.x
安装
使用 pip 安装
# 从 PyPI 安装
pip install ida-batch-decompile
# 从源码安装
pip install .
直接使用(无需安装)
直接克隆或下载本仓库即可:
git clone https://github.com/kamille-bidan123/ida2c_auto.git
cd ida2c_auto
使用方法
命令行方式
# 查看帮助
ida-decompile --help
# 处理单个文件
ida-decompile -i ./hello -o ./output -p /Applications/IDA\\ Professional\\ 9.1.app/Contents/MacOS/idat
# 处理整个目录
ida-decompile -i ./binaries -o ./output -p /Applications/IDA\\ Professional\\ 9.1.app/Contents/MacOS/idat
# 显示详细输出
ida-decompile -i ./binaries -o ./output -p /path/to/idat -v
必填参数
| 参数 | 说明 |
|---|---|
-i, --input-dir |
输入目录或单个二进制文件路径 |
-o, --output-dir |
C 文件输出目录 |
-p, --idat-path |
idat 可执行文件路径 |
可选参数
| 参数 | 说明 | 默认值 |
|---|---|---|
-t, --timeout |
每个文件的超时时间(秒) | 300 |
-v, --verbose |
显示详细输出 | 否 |
-h, --help |
显示帮助信息 | - |
--version |
显示版本号 | - |
示例
# 处理目录中的所有二进制文件
ida-decompile -i ./binaries -o ./output -p /Applications/IDA\\ Professional\\ 9.1.app/Contents/MacOS/idat
# 处理单个文件
ida-decompile -i ./hello -o ./output -p /Applications/IDA\\ Professional\\ 9.1.app/Contents/MacOS/idat
# 增加超时时间(处理大型文件)
ida-decompile -i ./binaries -o ./output -p /path/to/idat -t 600
# 显示详细处理过程
ida-decompile -i ./binaries -o ./output -p /path/to/idat -v
输出格式
生成的 C 文件格式如下:
/*
* File: hello_decompiled.c
* Generated from: hello
* Generated at: 2024-01-15 10:30:00
* Total functions: 15
*/
#include <stdint.h>
#include <stddef.h>
//-------------------------------------------------------------------------
// Function declarations
int __fastcall main(int argc, const char **argv, const char **envp);
int printf(const char *, ...);
//----- (0000000100000460) ----------------------------------------------------
int __fastcall main(int argc, const char **argv, const char **envp)
{
printf("Hello, World!\n");
return 0;
}
- 输出文件以
原文件名_decompiled.c命名 - 每个函数包含地址和顺序信息的注释
- 使用
=分隔不同函数
实现原理
工具使用 IDA Pro 的 idaapi.decompile() API:
- 使用
idat -A以自动模式加载二进制文件 - 等待 IDA 自动分析完成
- 执行 IDAPython 脚本调用
decompile()反编译所有函数 - 将所有函数的 C 代码合并到一个文件中
这与 IDA GUI 的"导出 C 代码"功能使用相同的底层 API,因此输出质量相同。
注意事项
- 确保 IDA Pro 已正确安装且
idat可执行文件存在 - 某些保护/混淆的二进制文件可能无法完整反编译
- 处理大型文件时可能需要增加超时时间
- idat 路径需要根据你的 IDA Pro 安装位置调整
- macOS 用户注意:如果 IDA Pro 位于
/Applications目录,可能需要添加执行权限
许可证
本工具仅供学习和研究使用。请遵守 IDA Pro 的使用协议。
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ida_batch_decompile-0.2.6.tar.gz
(11.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ida_batch_decompile-0.2.6.tar.gz.
File metadata
- Download URL: ida_batch_decompile-0.2.6.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e8484214c16285658b347baf44ef3f8ef15e075f292f5434d5d96b49cd17c05
|
|
| MD5 |
eaa1096d3507d985b67e11b59223a649
|
|
| BLAKE2b-256 |
adb46a86411ab0637dd65600fd9f00acf2591619f73d656530412bf46d243755
|
File details
Details for the file ida_batch_decompile-0.2.6-py3-none-any.whl.
File metadata
- Download URL: ida_batch_decompile-0.2.6-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f029edf672bdea872ff6d3ad24bbd7498bd916801610c6b6e3caec2d508fef7
|
|
| MD5 |
3164c38f354cc0d274b7b68e1dcc3c1e
|
|
| BLAKE2b-256 |
717feff63f8963cdd9092fed482903044c5485775b29247651b1b717482e92c0
|