17

IDAPython is great plugin in IDA. It is so handy to write small script to decode, decrypt or fix (patch) a binary in IDA. I can just write, load and run a script, and can use print for the usual shotgun debugging. But when I develop a bigger IDAPython script, I need a way to debug it.

I have searched and found that I can debug IDAPython with WingIDE but I want to find another that doesn't require WingIDE. Is there another way to debug IDAPython scripts?

1
  • i guess i am old fashioned, i use 'print' Commented Mar 27, 2014 at 20:20

3 Answers 3

2

UPDATE: This seems to be obsolete.

You can debug IDAPython scripts using Python Tools for Visual Studio. It is completely free, and very easy to use.

See this tutorial for this information.

3
  • 1
    The tutorial is wrong or obsolete. I repeated the steps with Visual Studio 2019 and IDA 7.2, it doesn't work. When Visual Studio starts to attach to IDA, it reports error. The error text is very informative ;) it is "General error occurred"...
    – Vitalii
    Commented Aug 7, 2019 at 11:10
  • Thanks. Edited the answer to reflect it.
    – tmr232
    Commented Aug 7, 2019 at 12:34
  • That enable_attach(secret=" part is wrong. Needs to be something like ptvsd.enable_attach(address=('localhost', 5678)): reverseengineering.stackexchange.com/questions/25102/…
    – Trass3r
    Commented Oct 6, 2020 at 13:18
8

You can do this. Last summer I worked with Hexrays and WingIDE guys and got this working. In fact its in the docs!

http://wingware.com/doc/howtos/idapython

It rocks.

Riley

4

As far as i know there's no way to debug python inside IDA.

There are, however, a few python tools you could use to debug your own code. but it will essentially require you to develop your own python IDE/debugger utilities around the built-in python debugging tools.

I'm listing the possible methods by order of complexity (simplest first):

Compiling and running your own python code from python
The more basic approach is using the python compile built-in function to compile python code into bytecode, executing that with eval or exec (also built-in functions). compile returns an AST (Abstract Syntax Tree) object you can further manipulate/investigate.

Using The python debugger (from python)
If you want more advanced debugging abilities, python has it's own built-in python debugger module called pdb. You only need to tell pdb what python code to execute, and it'll spawn a debugger interface similar to gdb, the command line debugger lets you set conditional breakpoints, manipulate and analyze python code, and use most of the usual debugging tools.

Using the python debugging framework
the python debugger is built on top of python's bdb (basic debugger), it is a class implementing debugging functionality and can be used from within IDA's python command line. If you're going to use the bdb you'll have to create your own tools and UI around these utilities.

Edit: I saw WingIDE only now. since OP didn't specify what exactly is the issue using WingIDE, I hope at least one of the methods will be relevant.

2
  • I would imagine the issue is that it isn't cheap.
    – cb88
    Commented Jun 6, 2013 at 22:36
  • 1
    @cb88: 45$ vs the ~500$ IDA costs?.. sounds a bit odd but i guess it may be the reason.
    – NirIzr
    Commented Jun 6, 2013 at 23:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.