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

Unable to export with error: MalformedURLException: Unknown Protocol: JAR #19

Open
mariaWitch opened this issue Dec 18, 2022 · 9 comments

Comments

@mariaWitch
Copy link

mariaWitch commented Dec 18, 2022

I have OpenJDK 17.0.5 and python 3 both installed, and I receive the following error when I use it on my file.


ghidra2dwarf.py> Running...

/home/maria/Downloads/ghidra_scripts/ghidra2dwarf.py:34: RuntimeWarning: PyTableCode.call caught a Throwable that is not an Exception:
java.lang.ExceptionInInitializerError
Jython internals might be in a bad state now that can cause deadlocks later on.
See http://bugs.jython.org/issue2536 for details.
  from libdwarf import LibdwarfLibrary
Traceback (most recent call last):
  File "/home/maria/Downloads/ghidra_scripts/ghidra2dwarf.py", line 34, in <module>
    from libdwarf import LibdwarfLibrary
java.lang.ExceptionInInitializerError
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at org.python.core.Py.loadAndInitClass(Py.java:1160)
	at org.python.core.Py.findClassInternal(Py.java:1095)
	at org.python.core.Py.findClass(Py.java:1129)
	at org.python.core.JavaImportHelper.isJavaClass(JavaImportHelper.java:184)
	at org.python.core.JavaImportHelper.tryAddPackage(JavaImportHelper.java:42)
	at org.python.core.imp.import_next(imp.java:1166)
	at org.python.core.imp.import_module_level(imp.java:1350)
	at org.python.core.imp.importName(imp.java:1528)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1285)
	at org.python.core.PyObject.__call__(PyObject.java:433)
	at org.python.core.__builtin__.__import__(__builtin__.java:1232)
	at org.python.core.imp.importFromAs(imp.java:1620)
	at org.python.core.imp.importFrom(imp.java:1595)
	at org.python.pycode._pyx13.f$0(/home/maria/Downloads/ghidra_scripts/ghidra2dwarf.py:518)
	at org.python.pycode._pyx13.call_function(/home/maria/Downloads/ghidra_scripts/ghidra2dwarf.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
	at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:287)
	at ghidra.python.GhidraPythonInterpreter.execFile(GhidraPythonInterpreter.java:239)
	at ghidra.python.PythonScriptExecutionThread.run(PythonScriptExecutionThread.java:51)
Caused by: java.lang.RuntimeException: java.net.MalformedURLException: Unknown protocol: jar
	at org.python.core.SyspathJavaLoader.findResource(SyspathJavaLoader.java:152)
	at java.base/java.lang.ClassLoader.getResource(ClassLoader.java:1403)
	at com.sun.jna.Native.extractFromResourcePath(Native.java:1085)
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:276)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:455)
	at com.sun.jna.Library$Handler.<init>(Library.java:192)
	at com.sun.jna.Native.loadLibrary(Native.java:646)
	at com.sun.jna.Native.loadLibrary(Native.java:630)
	at libdwarf.LibdwarfLibrary.<clinit>(LibdwarfLibrary.java:13)
	... 24 more
Caused by: java.net.MalformedURLException: Unknown protocol: jar
	at java.base/java.net.URL.<init>(URL.java:708)
	at java.base/java.net.URL.<init>(URL.java:569)
	at java.base/java.net.URL.<init>(URL.java:516)
	at org.python.core.SyspathJavaLoader.findResource(SyspathJavaLoader.java:150)
	... 32 more
Caused by: java.lang.IllegalStateException: Unknown protocol: jar
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)
	at java.base/java.net.URL.<init>(URL.java:703)
	... 35 more
java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
ghidra2dwarf.py> Finished!
ghidra2dwarf.py> Running...
Traceback (most recent call last):
  File "/home/maria/Downloads/ghidra2dwarf/ghidra2dwarf.py", line 34, in <module>
    from libdwarf import LibdwarfLibrary
java.lang.ExceptionInInitializerError
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:467)
	at org.python.core.Py.loadAndInitClass(Py.java:1160)
	at org.python.core.Py.findClassInternal(Py.java:1095)
	at org.python.core.Py.findClassEx(Py.java:1147)
	at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:233)
	at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:36)
	at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:221)
	at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:137)
	at org.python.core.PyObject.__findattr__(PyObject.java:902)
	at org.python.core.PyObject.__findattr__(PyObject.java:889)
	at org.python.core.imp.ensureFromList(imp.java:1484)
	at org.python.core.imp.ensureFromList(imp.java:1449)
	at org.python.core.imp.import_module_level(imp.java:1377)
	at org.python.core.imp.importName(imp.java:1528)
	at org.python.core.ImportFunction.__call__(__builtin__.java:1285)
	at org.python.core.PyObject.__call__(PyObject.java:433)
	at org.python.core.__builtin__.__import__(__builtin__.java:1232)
	at org.python.core.imp.importFromAs(imp.java:1620)
	at org.python.core.imp.importFrom(imp.java:1595)
	at org.python.pycode._pyx20.f$0(/home/maria/Downloads/ghidra2dwarf/ghidra2dwarf.py:518)
	at org.python.pycode._pyx20.call_function(/home/maria/Downloads/ghidra2dwarf/ghidra2dwarf.py)
	at org.python.core.PyTableCode.call(PyTableCode.java:173)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1687)
	at org.python.core.__builtin__.execfile_flags(__builtin__.java:535)
	at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:287)
	at ghidra.python.GhidraPythonInterpreter.execFile(GhidraPythonInterpreter.java:239)
	at ghidra.python.PythonScriptExecutionThread.run(PythonScriptExecutionThread.java:51)
Caused by: java.lang.RuntimeException: java.net.MalformedURLException: Unknown protocol: jar
	at org.python.core.SyspathJavaLoader.findResource(SyspathJavaLoader.java:152)
	at java.base/java.lang.ClassLoader.getResource(ClassLoader.java:1403)
	at com.sun.jna.Native.extractFromResourcePath(Native.java:1085)
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:276)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:455)
	at com.sun.jna.Library$Handler.<init>(Library.java:192)
	at com.sun.jna.Native.loadLibrary(Native.java:646)
	at com.sun.jna.Native.loadLibrary(Native.java:630)
	at libdwarf.LibdwarfLibrary.<clinit>(LibdwarfLibrary.java:13)
	... 29 more
Caused by: java.net.MalformedURLException: Unknown protocol: jar
	at java.base/java.net.URL.<init>(URL.java:708)
	at java.base/java.net.URL.<init>(URL.java:569)
	at java.base/java.net.URL.<init>(URL.java:516)
	at org.python.core.SyspathJavaLoader.findResource(SyspathJavaLoader.java:150)
	... 37 more
Caused by: java.lang.IllegalStateException: Unknown protocol: jar
	at org.apache.felix.framework.URLHandlersStreamHandlerProxy.parseURL(URLHandlersStreamHandlerProxy.java:373)
	at java.base/java.net.URL.<init>(URL.java:703)
	... 40 more
java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError
@mariaWitch mariaWitch changed the title Unable to export with error: MalformedURLException: Unknown Protocol: Jar Unable to export with error: MalformedURLException: Unknown Protocol: JAR Dec 18, 2022
@mariaWitch
Copy link
Author

ping @meowmeowxw @nneonneo @NextLight

@nneonneo
Copy link
Contributor

Duplicate of #17. I don't really understand what's happening here; I see some scattered references to a similar issue elsewhere online, but I cannot replicate this locally. It's odd that we have it happening on both Linux (which I presume you're using) and Windows (#17). I'd be interested to know what jar you're using, etc.

@mariaWitch
Copy link
Author

mariaWitch commented May 19, 2023

So I haven't tried this in a while, but the last time I recall, this was on ghidra 10.1.2, and I used the latest release of ghidra2dwarf. And yes I am using Linux.
Doing some quick inspections on the environment show that the following openjdks are installed.
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.17.0-openjdk-amd64 1711 /usr/lib/jvm/java-1.17.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64

The system is running Ubuntu 22.04, and is running the 6.2.1 linux kernel.

@mariaWitch
Copy link
Author

@nneonneo
If you have any specific information that you would like me to collect about my setup I can do that for you.
Also what version of OpenJDK are you using?

@nneonneo
Copy link
Contributor

I guess I'd like to know how you're running Ghidra (e.g. how is it packaged?), and which JDK you're actually running Ghidra with.

I'm on macOS, with the following Java:

$ java -version
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment GraalVM CE 22.3.2 (build 17.0.7+7-jvmci-22.3-b18)
OpenJDK 64-Bit Server VM GraalVM CE 22.3.2 (build 17.0.7+7-jvmci-22.3-b18, mixed mode, sharing)

@mariaWitch
Copy link
Author

It's packaged like any other ghidra release. I don't exactly know what you are asking for me with that. I run it with the ghidraRun script.
What version of Ghidra are you testing on? An older version of Ghidra may have a different version of jython, when I open up the python interpreter in Ghidra, this is what it says.

Python Interpreter for Ghidra
Based on Jython version 2.7.2 (v2.7.2:925a3cc3b49d, Mar 21 2020, 10:03:58)
[OpenJDK 64-Bit Server VM (Private Build)]
Press 'F1' for usage instructions

@nneonneo
Copy link
Contributor

In your Jython interpreter in Ghidra, can you post the output of “import sys; print sys.path”?

@mariaWitch
Copy link
Author

Here's what the output was:

['/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/dev/jython_cachedir/python-src', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/Python/data/jython-2.7.2/Lib', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/Python/lib/jython-standalone-2.7.2.jar/Lib', 
'__classpath__', 
'__pyclasspath__/', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/Python/data/jython-2.7.2/Lib/site-packages', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Processors/DATA/ghidra_scripts',
 '/home/maria/Downloads/ghidra2dwarf',
 '/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/Decompiler/ghidra_scripts',
 '/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/FunctionID/ghidra_scripts',
 '/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/GnuDemangler/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Debug/Debugger-agent-dbgmodel-traceloader/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/FileFormats/ghidra_scripts', 
'/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/Extensions/ghidra-xbe/ghidra_scripts',
 '/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Debug/Debugger/ghidra_scripts',
 '/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/Base/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Processors/PIC/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Processors/8051/ghidra_scripts', 
'/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/Extensions/retsync/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/Python/ghidra_scripts', 
'/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/Extensions/kaiju/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/VersionTracking/ghidra_scripts', 
'/home/maria/Downloads/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/MicrosoftCodeAnalyzer/ghidra_scripts', 
'/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/Extensions/Ghidra-Cpp-Class-Analyzer/ghidra_scripts', 
'/home/maria/Downloads/ghidra_10.1.2_PUBLIC_20220125/ghidra_10.1.2_PUBLIC/Ghidra/Features/BytePatterns/ghidra_scripts', 
'/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/osgi/compiled-bundles', 
'/home/maria/.ghidra/.ghidra_10.1.2_PUBLIC/osgi/felixcache']

@nneonneo
Copy link
Contributor

10.1.2 is a bit old. What happens with e.g. 10.3?

Have you tried using a clean install with no extensions? Move or rename /home/maria/.ghidra so it starts from a clean state without migrating any settings, add just ghidra2dwarf to the script path, and see if the problem occurs then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants