JusticeRage / Gepetto

IDA plugin which queries uses language models to speed up reverse-engineering
GNU General Public License v3.0
2.81k stars 260 forks source link

SSL Error #22

Closed osok closed 1 year ago

osok commented 1 year ago

I have IDA 7.7.220218 Windows x64 with HexRays Decompiler.

It is using python38. In the registry it referenced python.dll.
C:\Program Files\Python38\python38.dll

I installed the contents of the requirements using the executable in the same directory "C:\Program Files\Python38\python.exe" -m pip install -r requirements.txt

Everything installed. I moved the gepetto folder into the plugins director along with the gepetto.py. I get the gepetto as an option when I right click in IDA. When I choose rename variablesor explain functions, I get the following error:

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] 
IDAPython 64-bit v7.4.0 final (serial 0) (c) The IDAPython Team <idapython@googlegroups.com>
---------------------------------------------------------------------------------------------
Request to gpt-3.5-turbo sent...
General exception encountered while running the query: Can't connect to HTTPS URL because the SSL module is not available.

I did try to install the ssl module

"C:\Program Files\Python38\python.exe" -m pip install ssl

and got this error

Collecting ssl
  Using cached ssl-1.16.tar.gz (33 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Traceback (most recent call last):
        File "C:\Program Files\Python38\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Program Files\Python38\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "C:\Program Files\Python38\lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "C:\Users\michael\AppData\Local\Temp\pip-build-env-xaob5kxc\overlay\Lib\site-packages\setuptools\build_meta.py", line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "C:\Users\michael\AppData\Local\Temp\pip-build-env-xaob5kxc\overlay\Lib\site-packages\setuptools\build_meta.py", line 323, in _get_build_requires
          self.run_setup()
        File "C:\Users\michael\AppData\Local\Temp\pip-build-env-xaob5kxc\overlay\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
          super(_BuildMetaLegacyBackend,
        File "C:\Users\michael\AppData\Local\Temp\pip-build-env-xaob5kxc\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 33
          print 'looking for', f
                ^
      SyntaxError: Missing parentheses in call to 'print'. Did you mean print('looking for', f)?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
JusticeRage commented 1 year ago

Hi! Thanks for reporting this in detail! I think however that the issue has more to do with your Python installation than with this plugin. I recommend updating to the latest version of Python if possible, otherwise looking up specific solutions to this problem online.

osok commented 1 year ago

I disagree. If gepetto relies on a specific version of ssl then it should be reflected in the requirements.txt. Or if there is a minimum version of python or any dependancy it should be called out, not left to others to figure out. I will admit, I"m not python expert, but I have coded in Java, C, C++, golang for the past 30+ years. If I build a tool that is dependant on a third party library or a specifc version of the language I document that. I get that "go figure it out yourself" makes it esier to maintain a tool, and I accept it if thats truely the way you want to support the tool, but I don't have to agree with it.

I now have to sort out how to build an IDA Plugin with python, and how to test it, so that I can properly debug the environment to get to the root of the problem. I guess I could just randomly try different versions of tools to see what one of the trillion combinations work.

Maybe I just ask chatGPT how to fix it. :-)

I generally use anaconda, so this particular environment (not under conda) has only ever supported IDA and now Gepetto. It was part of the IDA Pro installation. This is the first python plugin I installed. So if my environment is messed up, well you get the point.

Have a nice day.

JusticeRage commented 1 year ago

That's fair, but here is the situation from my perspective.

I'll direct your attention to the fact that IDA may very well have detected your previous Anaconda environments on your system and could be using one of those. It comes with a utility in its folder called idapyswitch.exe which you can use to switch between installed environments in case there are several of them lying around. I'd be willing to bet that The Python 3.8 in which you're needlessly trying to install the ssl package (because it shouldn't need it) is not the one IDA is using.

Nobody's perfect, of course, neither am I and there are certainly bugs in this project. But considering that it's used by a lot of people, I think you should have the humility to assume that running it in a sane environment may just work and that yes, the issue might be with your specific installation.

Have a nice day too!

osok commented 1 year ago

All valid points!

osok commented 1 year ago

I did do some basic googling and realized this was a dependancy issue of gepetto so I came to you.

Like I said I'm not an expert in python. This freakin environment problems is exactly why I choose not use it. I code in other languages and just don't have a desire to spend the time dealing with python. So I appologize for some of the basic oversights, like 3.8, and as I found out 3.9, are no longer supported. However IDA doesn't support 3.10+. I did find the idapyswirch.exe, and as you might expect it only recogonizes 3.8, not 3.10 or 3.11.

I reopenned this merely to point out that I guess in order to use Gepetto you either have build python 3.9 from sources or have upgraded to 3.9 sometime in the past.

As you stated this is NOT your problem, I'm lefted wondering why does python 3.8 (not python 2.x) tell me I have an SSL problem when I execute the gepetto plugin?

Look I commend you for building this, if it worked for me, and it apparently does work for others, it is a time saver. So thank you for the effort. Please don't read any of my feed back as a coming from a pissed of user. It just doesn't make sense to me that there is a problem here, and the only way to fix it is to use an unsupported version of python, instead of another unsupported version of python. This seems more like an IDA Pro problem.

PS I used idapyswitch and now ida will not start, it complains of a problem in a cfg file related to python. commenting out the problem doesn't fix it. So I will be uninstalling IDA and reinstalling it.

JusticeRage commented 1 year ago

No worries! I know it can be frustrating to download a tool for somewhere and having it not work out of the box. To circle back to the original point, if I were aware that there is a specific Python version required to run the project, I would definitely list it on the front page. Testing for this is unfortunately difficult, as we're both experiencing with this issue. Python being notorious for being a hot mess when it comes to having multiple interpreters on a system so this is why it's my prime suspect here.

I don't know how familiar you are with IDA, but there's a text bar at the very bottom of the screen where you can type Python directly, that could help you figure some things out. I would recommend starting with:

import sys
print(sys.version)
print(sys.path)

This will let you know beyond the shadow of a doubt which interpreter is being used by IDA currently. In any case, doing a clean install of IDA should sort you out because you will get an option during setup to install a Python version shipped with IDA and known to be compatible (probably 3.8 or 3.9).

Finally, if you have a commercial license of IDA, this is definitely the sort of thing (broken .cfg file) that their support can help you out with, they're usually very reactive so definitely consider sending them an email.

osok commented 1 year ago

Re installing really is not a problem.

If there is a choice to install 3.9, then thats what I'll do. As many times as I have installed this, I like rebuilding my system from time to time, keeps it clean. I never noticed that there was an option. Hopefully that works, and this thread will help someelse.

Thanks for the time.

osok commented 1 year ago

The install recogonized that I had 3.10 and 3.11 installed but only install 3.8. The only choice I had was Python 2 or python 3. Never a choice for Python 3.9

JusticeRage commented 1 year ago

Wasn't there a dialog option somewhere to install a Python 3 version provided with IDA instead of using one on the system? What happens if you choose Python 3.10 or 3.11, does it work despite not being officially supported?

osok commented 1 year ago

never lets me choose 3.10 or 3.11, the only choice I had was python 2 or python3, this is IDA 7.7_A I have a few Hex Ray decompilers. This tim I uninstalled it and deleted the directory and registry. Trying again

osok commented 1 year ago

image

JusticeRage commented 1 year ago

If IDA offers to install its own Python, whatever it deploys should be fine for the plugin's purposes!

osok commented 1 year ago

Ok, So this time I tried idapyswitch.exe and 3.10 nd 3.11 were there. I tried 3.10 and everything seems to work.

Next I'll install gepetto.

Thank you again for the assistance.

osok commented 1 year ago

Switched to 3.11, and things seem to be working.

JusticeRage commented 1 year ago

Glad you were able to resolve this issue!