Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ghidra started in PyGhidra mode, Jython disabled, but scripts in the Scripts Manager are still executed with Jython #7856

Open
joxeankoret opened this issue Feb 25, 2025 · 4 comments
Assignees
Labels
Feature: Python/PyGhidra Status: Internal This is being tracked internally by the Ghidra team

Comments

@joxeankoret
Copy link

joxeankoret commented Feb 25, 2025

Describe the bug

I have started Ghidra in PyGhidra mode and verified it by running some commands in the console. I have also disabled Jython as I don't use it. Then, I tried to run some Python script I'm developing from the Scripts Manager and realized that it's still using Jython instead of my Python 3.11 installation.

To Reproduce

  1. Run Ghidra in PyGhidra mode.
  2. Disable Jython.
  3. Create a python script in some directory configured to appear in the Ghidra's Script Manager with only the following lines:
import sys
print("Python version", sys.version)
  1. Run the script.
  2. It will print something like the following text, clearly showing that it isn't using PyGhidra but Jython:
('Python version', '2.7.4 (tags/v2.7.4:3f256f4a7, Aug 18 2024, 10:30:53)\n[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)]')

Expected behavior
Running my script using my PyGhidra installation, not Jython.

Environment (please complete the following information):

  • OS: Ubuntu 22.04.5 LTS
  • Java Version: JDK 23
  • Ghidra Version: 11.3.1
  • Ghidra Origin: Github release
@v-p-b
Copy link

v-p-b commented Feb 25, 2025

Maybe this one helps: #7472 (comment) ?

@joxeankoret
Copy link
Author

Thank you very much! Indeed, it fixes the issue.
However, it would be cool if, by default, when running in PyGhidra mode, it would use PyGhidra instead of Jython.

@v-p-b
Copy link

v-p-b commented Feb 25, 2025

I'd like to add that I can't seem to find this annotation documented. I think previous answers were based on a runtime warning:

#7037 (comment)

IMO documentation regarding PyGhidra use in scripts needs improvement.

@ryanmkurtz
Copy link
Collaborator

However, it would be cool if, by default, when running in PyGhidra mode, it would use PyGhidra instead of Jython.

I was waiting for a major release (i.e., Ghidra 12.0) before changing the default from Jython to PyGhidra, since there are currently a lot more Jython scripts without the tag than PyGhidra. But since users will most likely want to move to PyGhidra, the default will indeed change.

@ryanmkurtz ryanmkurtz self-assigned this Feb 25, 2025
@ryanmkurtz ryanmkurtz added Feature: Python/PyGhidra Status: Internal This is being tracked internally by the Ghidra team labels Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Python/PyGhidra Status: Internal This is being tracked internally by the Ghidra team
Projects
None yet
Development

No branches or pull requests

3 participants