Giter VIP home page Giter VIP logo

tintinweb / ida-batch_decompile Goto Github PK

View Code? Open in Web Editor NEW
276.0 18.0 61.0 44 KB

*Decompile All the Things* - IDA Batch Decompile plugin and script for Hex-Ray's IDA Pro that adds the ability to batch decompile multiple files and their imports with additional annotations (xref, stack var size) to the pseudocode .c file

Home Page: https://marketplace.visualstudio.com/items?itemName=tintinweb.vscode-decompiler

License: GNU General Public License v3.0

Python 100.00%
ida decompile ida-plugin batch-processing ida-batch-decompile reverse-engineering

ida-batch_decompile's Introduction

ida-batch_decompile

Decompile all the things!

IDA Batch Decompile is a plugin for Hex-Ray's IDA Pro that adds the ability to batch decompile multiple files and their imports with additional annotations (xref, stack var size) to the pseudocode .c file

idabatchdecompile

๐Ÿค pssst! - ida-batch_decompile is also part of project: unbox - a nobrainer commandline tool to unpack and decompile all sorts of things.

Usage

idascript (gui mode)

  1. open target, wait for analysis to finish
  2. IDA Pro -> File/Script file... -> <this_python_script>
  3. IDA Pro -> File/Produce file-> IdaDecompileBatch ...
  4. tick Annotate StackVarSize, Annotate Func XRefs
  5. click OK to decompile.

Note: File will be saved in target folder as <target_image_name.c>

idascript (cmdline batch mode)

<path_to_ida>/ida(w|w64)(.exe) -B -M -S"<path_to_this_script> \"--option1\" \"--option2\"" "<target>"

Note that options need to be quoted with \"

Available options, see --help

--output                        ... output file path
--annotate-stackvar-size        ... annotate function stack variable sizes
--annotate-xrefs                ... annotate function xrefs
--imports                       ... process imports
--recursive                     ... recursive batch decompile
--experimental-decompile-cgraph ... experimental: manually decompile function call graph

Ida Plugin

  1. Follow the IDA Pro documentation on how to add python plugins.
  2. IDA Pro -> File/Produce file -> IdaDecompileBatch ...

run

ida console: decompiling dbghelp.dll

[__main__/36908][DEBUG     ] [idabatchdecompile.PLUGIN_ENTRY  ] [+] initializing IdaDecompileBatchPlugin
[__main__/36908][DEBUG     ] [idabatchdecompile.__init__      ] [+] is_windows: True
[__main__/36908][DEBUG     ] [idabatchdecompile.__init__      ] [+] is_ida64: False
[__main__/36908][DEBUG     ] [idabatchdecompile.wait_for_analysis_to_finish] [+] waiting for analysis to finish...
[__main__/36908][DEBUG     ] [idabatchdecompile.wait_for_analysis_to_finish] [+] analysis finished.
[__main__/36908][DEBUG     ] [idabatchdecompile.load_plugin_decompiler] [+] trying to load decompiler plugins
[__main__/36908][DEBUG     ] [idabatchdecompile.load_plugin_decompiler] [+] decompiler plugins loaded.
[__main__/36908][DEBUG     ] [idabatchdecompile.PLUGIN_ENTRY  ] [+] Mode: commandline w/o args
[__main__/36908][DEBUG     ] [idabatchdecompile.set_ctrl      ] [+] IdaDecompileBatchPlugin.set_ctrl(<__main__.IdaDecompileBatchController object at 0x056FCF90>)
[__main__/36908][DEBUG     ] [idabatchdecompile.init          ] [+] IdaDecompileBatchPlugin.init()
[__main__/36908][DEBUG     ] [idabatchdecompile.init          ] [+] setting up menus
[__main__/36908][INFO      ] [idabatchdecompile.PLUGIN_ENTRY  ] [i] IdaDecompileBatch loaded, see Menu: ('File/Produce file/', 'IdaDecompileBatch ...')
...
 The application has been completely decompiled.
[__main__/36908][DEBUG     ] [idabatchdecompile.decompile_all ] [+] finished decompiling 'dbghelp.dll' as 'dbghelp.c'

annotated pseudocode: dbghelp.c

//----- (03052800) --------------------------------------------------------
// **** Variables ****
// * stack size: 20
// {"diff_size": 4, "offset_text": "[bp+0h]", "size": 4, "name": " s", "offset": 0}
// {"diff_size": 4, "offset_text": "[bp+4h]", "size": 4, "name": " r", "offset": 4}
// {"diff_size": 4, "offset_text": "[bp+8h]", "size": 4, "name": "arg_0", "offset": 8}
// {"diff_size": 4, "offset_text": "[bp+Ch]", "size": 4, "name": "dwBytes", "offset": 12}
// {"diff_size": 4, "offset_text": "[bp+10h]", "size": 4, "name": "arg_8", "offset": 16}
// *******************
// ***** XREFS *****
// * # 1
// sub_30733D0+30
// *******************
int __stdcall sub_3052800(int a1, SIZE_T dwBytes, int a3)
{
  int result; // eax@17
  HANDLE v4; // eax@21
...

//github.com/tintinweb

ida-batch_decompile's People

Contributors

tintinweb avatar wmliang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ida-batch_decompile's Issues

Can not load the script

since a exception as bellow, while init the plugin.

    raise Exception("hexrays decompiler is not available :(")
Exception: hexrays decompiler is not available :(

MacOS, IDA 7 (is system not supported?)

Erm is it python don't work in Ida 7.0?

I notice my script format don't have .py filter, so I switch to All Files(.)
D:\ida_batch_decompile.py: D:\ida_batch_decompile.py,1: Bad or ill-formed preprocessor command

"SyntaxError: invalid syntax" and "NameError: name 'Choose2' is not defined"

I cloned the repository to use the latest script, and tried using the "idascript (gui mode)" method on IDA Pro 7.5. I received the following error:

File "C:\IDA 7.5\python\3\ida_idaapi.py", line 614, in IDAPython_ExecScript
    code = compile(raw.decode(encoding), script, 'exec')
  File "C:/repos/ida-batch_decompile/ida_batch_decompile.py", line 57
    except Exception, e:
                    ^
SyntaxError: invalid syntax

I corrected the except Exception, e: error and similar errors like in d7dd594 , but this lead to another error:

File "C:\IDA 7.5\python\3\ida_idaapi.py", line 614, in IDAPython_ExecScript
    code = compile(raw.decode(encoding), script, 'exec')
  File "C:/repos/ida-batch_decompile/ida_batch_decompile.py", line 176
    print "[+] stats: %r" % stats
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("[+] stats: %r" % stats)?

I added the parentheses to all effected print statements, but then:

File "C:\IDA 7.5\python\3\ida_idaapi.py", line 615, in IDAPython_ExecScript
    exec(code, g)
  File "C:/repos/ida-batch_decompile/ida_batch_decompile.py", line 423, in <module>
    class TestEmbeddedChooserClass(Choose,Choose2):
NameError: name 'Choose2' is not defined

At that point, I'm not sure how to fix this. Any help would be appreciated.

Edit:
I've since made a fork that might be exclusive to IDA 7.4+:
https://github.com/TBirdSoars/ida-batch_decompile

IDA no longer throws errors when loading the script through
File -> Script file... -> ida_batch_decompile.py
and IDA Batch Decompile appears under File -> Produce file.

Unfortunately, selecting this appears to do nothing, and I'm not sure why.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.