huettenhain / dhrake

The Delphi Hand Rake
147 stars 17 forks source link

ClassCastException on Ghidra 10.2 #4

Closed JackHack96 closed 1 year ago

JackHack96 commented 1 year ago

I tried running these scripts using Ghidra 10.2 but I get the following error when trying to execute DhrakeInit:

> Unable to load script: DhrakeInit.java
>   detail: Unexpected error: java.lang.ClassCastException: class ghidra.app.plugin.core.osgi.GhidraPlaceholderBundle cannot be cast to class ghidra.app.plugin.core.osgi.GhidraSourceBundle (ghidra.app.plugin.core.osgi.GhidraPlaceholderBundle and ghidra.app.plugin.core.osgi.GhidraSourceBundle are in unnamed module of loader ghidra.GhidraClassLoader @47d384ee)

I'm using Ghidra 10.2.2 on Ubuntu 22.04. I'm still a newbie to Ghidra so maybe there could be something else wrong, I don't know.

huettenhain commented 1 year ago

It works fine for me on Ghidra 10.2.1, haven't upgraded to 10.2.2 yet. I will upgrade and test it with 10.2.2 ASAP.

huettenhain commented 1 year ago

No problems running it under Ghidra 10.2.2 either. Can you provide more context about what you are doing, maybe with screenshots?

JackHack96 commented 1 year ago

Ok. I have installed Ghidra using Flatpak (https://flathub.org/apps/details/org.ghidra_sre.Ghidra), then I created a folder in my home directory named "ghidra_scripts" in which I placed the "dhrake" folder containing the two Java files.

image Using the Scripts Manager I created a "Delphi" folder and imported the Dhrake scripts. Upon running "DhrakeInit" that error popped up.

huettenhain commented 1 year ago

Weird. Note that none of my source files mention any GhidraSourceBundle, so I am not sure where that cast is coming from. Does it show you a complete stack trace by any chance?

JackHack96 commented 1 year ago

Yeah it's very weird. And what's even more strange is that now I can't reproduce it, instead it just says:

> Unable to load script: DhrakeInit.java
>   detail: The class could not be found. It must be the public class of the .java file: dhrake.DhrakeInit not found by 6de36364 [21]

With no useful logging if run from the CLI:

🍺❯ flatpak run org.ghidra_sre.Ghidra
openjdk version "17.0.4.1" 2022-08-12
OpenJDK Runtime Environment 21.9 (build 17.0.4.1+12)
OpenJDK 64-Bit Server VM 21.9 (build 17.0.4.1+12, mixed mode)
INFO  Using log config file: jar:file:/app/lib/ghidra/Ghidra/Framework/Generic/lib/Generic.jar!/generic.log4j.xml (LoggingInitialization)  
INFO  Using log file: /home/matteo/.ghidra/.ghidra_10.2.2_FLATPAK/application.log (LoggingInitialization)  
INFO  Loading user preferences: /home/matteo/.ghidra/.ghidra_10.2.2_FLATPAK/preferences (Preferences)  
INFO  Loading previous preferences: /home/matteo/.ghidra/.ghidra_10.1.4_FLATPAK/preferences (Preferences)  
Gtk-Message: 20:11:01.182: Failed to load module "canberra-gtk-module"
Gtk-Message: 20:11:01.182: Failed to load module "canberra-gtk-module"
INFO  Class search complete (857 ms) (ClassSearcher)  
INFO  Initializing SSL Context (SSLContextInitializer)  
INFO  Initializing Random Number Generator... (SecureRandomFactory)  
INFO  Random Number Generator initialization complete: NativePRNGNonBlocking (SecureRandomFactory)  
INFO  Trust manager disabled, cacerts have not been set (ApplicationTrustManagerFactory)  
INFO  User matteo started Ghidra. (GhidraRun)  
INFO  Opening project: /home/matteo/miniverse-ghidra/miniverse (DefaultProject)  
INFO  Packed database cache: /tmp/matteo-Ghidra/packed-db-cache (PackedDatabaseCache) 

Maybe I should try to run this using a non-flatpak version of Ghidra, dunno...

huettenhain commented 1 year ago

I hate to be that guy, I have been on the receiving end of it many times - but right now, this honestly sounds like a problem with the Ghidra install to me, not with Dhrake. I will close this for now as "cannot reproduce", but I am happy to re-open and investigate if you can give me a better idea of what Dhrake is doing to cause the problem.

JackHack96 commented 1 year ago

I hate to be that guy, I have been on the receiving end of it many times - but right now, this honestly sounds like a problem with the Ghidra install to me, not with Dhrake. I will close this for now as "cannot reproduce", but I am happy to re-open and investigate if you can give me a better idea of what Dhrake is doing to cause the problem.

Don't worry I understand xD I also think that's a problem with the Ghidra setup and when I'll have some free time I'll try to install Ghidra without using Flatpak.