ioncodes / idacode

An integration for IDA and VS Code which connects both to easily execute and debug IDAPython scripts.
725 stars 77 forks source link

IDA has no python.exe but exists python64.dll, In such case how to specify the python path in settings.py? #35

Closed YuanBoXie closed 1 year ago

YuanBoXie commented 1 year ago

IDA Pro 7.0 My setting.py is:

HOST = "127.0.0.1"
PORT = 7065
DEBUG_PORT = 7066
PYTHON = "C:\\Users\\97527\\.conda\\envs\\gemini\\python.exe"
LOGGING = False

But

C:\Program Files\IDA 7.0\plugins\idacode.py: No module named concurrent.futures
Traceback (most recent call last):
  File "C:\Program Files\IDA 7.0\python\ida_idaapi.py", line 553, in IDAPython_ExecScript
    execfile(script, g)
  File "C:/Program Files/IDA 7.0/plugins/idacode.py", line 3, in <module>
    import idacode_utils.plugin as plugin
  File "C:\Program Files\IDA 7.0\plugins\idacode_utils\plugin.py", line 11, in <module>
    from idacode_utils.socket_handler import SocketHandler
  File "C:\Program Files\IDA 7.0\plugins\idacode_utils\socket_handler.py", line 1, in <module>
    import tornado.websocket, debugpy
  File "C:\Users\97527\AppData\Roaming\Python\Python27\site-packages\tornado\websocket.py", line 37, in <module>
    from tornado.queues import Queue
  File "C:\Users\97527\AppData\Roaming\Python\Python27\site-packages\tornado\queues.py", line 35, in <module>
    from tornado.locks import Event
  File "C:\Users\97527\AppData\Roaming\Python\Python27\site-packages\tornado\locks.py", line 18, in <module>
    from concurrent.futures import CancelledError
ImportError: No module named concurrent.futures

---------------------------------------------------------------------------------------------
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] 

How can I solve this problem?

YuanBoXie commented 1 year ago

I modified the tornado source code and skipped this issue. But Then I meet another issue: [IDACode] settings.PYTHON version mismatch, aborting load: [IDACode] IDA interpreter: 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)]win32 [IDACode] settings.PYTHON: 2.7.18 |Anaconda, Inc.| (default, Apr 23 2020, 17:26:54) [MSC v.1500 64 bit (AMD64)]win32 I can't find python.exe in the IDA Pro folder, I can only find python.dll and python64.dll, so maybe IDA interpreter: 2.7.13 is packed in this dll. In such a case, how can I specify the python variable in the idacode_utils/setting.py file?

YuanBoXie commented 1 year ago

Such a problem may be caused by IDA Pro 7.0. At this version of IDA Pro, It packs python env in python64.dll not pack python.exe, so I can't find python.exe to manually install the dependency. At the same time, I can't specify the python path in settings.py.

Is there anyone who install this plugin at version 7.0? How do you solve this problem?

ioncodes commented 1 year ago

In theory (I haven't tested this): It should be possible to use a "built-in" Python interpreter (as in, shipped as DLL), but it would require a lot of tweaking, and I'm not even sure if debugpy would support that properly. Your best bet is just getting an IDA Pro copy that introduced Python 3 (IDA Pro 7.4 and onwards), as these are best supported. Another thing you can try: Download idapyswitch.exe and see if you can force IDA 7.0 to use an external installation of Python, if that works it should solve all your issues.

Is there a specific reason why you're using IDA 7.0?

YuanBoXie commented 1 year ago

Thanks for your reply. Because I have some scripts written in python 2.7, IDA Pro 7.5+ can't use python2.7 so I tried to run this in version 7.0. But it seems this problem can't easily be solved. So I do as you say, I rewrite scripts in Python3 and upgrade the IDA Pro to version 7.5 then issue#35 can be solved.