An IDAPython script that automatically decompiles and exports all functions in an IDA database into multiple C/C++ source files. The script intelligently recreates the directory structure based on the Functions tree (folders) in IDA, keeping your decompiled code organized.
- Folder Structure Preservation: Recreates the folder hierarchy from IDA's Functions tree directly into the output directory.
- Batch Decompilation: Leverages the Hex-Rays Decompiler to decompile all functions in bulk.
- Unmapped Functions Handling: Functions that don't belong to any specific folder or source file are cleanly grouped into an
_unmapped.cppfile. - Customizable: Allows enabling/disabling the export of library functions and toggling silent mode to suppress Hex-Rays batch messages.
- IDA Pro 8.x or 9.x.
- A Hex-Rays Decompiler matching the architecture of the binary being analyzed (e.g., x86, x64, ARM).
- Open your target binary in IDA Pro.
- Wait for IDA's auto-analysis to complete.
- Go to File -> Script file... (or press
Alt-F7) and selectida_export_all_decompiled.py. - A prompt will appear asking for the output directory. By default, it will suggest a folder named
<binary_name>_decompilednext to your input binary. - Confirm the output directory.
- Wait for the script to finish batch decompilation. You can check the progress in IDA's Output window.
You can tweak a few settings directly at the top of the ida_export_all_decompiled.py file:
INCLUDE_LIBRARY_FUNCTIONS = FalseFalse: Skips functions marked as library functions by IDA.True: Exports all recognized functions, including library and thunk functions.
SILENT_MODE = FalseFalse: Allows IDA to show normal Hex-Rays progress and messages.True: Minimizes batch decompiler messages for a cleaner output window.
MIT License