dod-cyber-crime-center / pyhidra

Pyhidra is a Python library that provides direct access to the Ghidra API within a native CPython interpreter using jpype.
Other
182 stars 16 forks source link

Cross Arch issue: JVM DLL not found #2

Closed lacraig2 closed 2 years ago

lacraig2 commented 2 years ago

On non-windows targets the file jvm.dll does not exist.

[Errno 2] JVM DLL not found: /Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home/bin/server/jvm.dll

This is likely due to the hard coding here:

https://github.com/Defense-Cyber-Crime-Center/pyhidra/blob/c487e4d39445d836e8626aacc65f206f127ab063/pyhidra/launcher.py#L135-L141

Target: OSX 11.6.4, Python 3.7.6, Ghidra 10.2 DEV

lacraig2 commented 2 years ago

Hi @DC3-DCCI,

I have tested your updates. They fix the issue on Linux, but fail on Mac.

On my machine the following is the path the code wants to use and the actual location it is looking for:

guessed_jvm = '/Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home/Home/server/libjli.dylib'
correct_jvm = '/Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home/lib/libjli.dylib'

Here's a bunch of macOS examples of paths for developing against:

% find  /Library/Java/JavaVirtualMachines/ -name "libjli.dylib"                            
/Library/Java/JavaVirtualMachines//temurin-11.jre/Contents/Home/lib/jli/libjli.dylib
/Library/Java/JavaVirtualMachines//temurin-11.jre/Contents/MacOS/libjli.dylib
/Library/Java/JavaVirtualMachines//openjdk-14.0.2.jdk/Contents/Home/lib/libjli.dylib
/Library/Java/JavaVirtualMachines//openjdk-14.0.2.jdk/Contents/MacOS/libjli.dylib
/Library/Java/JavaVirtualMachines//amazon-corretto-11.jdk/Contents/Home/lib/jli/libjli.dylib
/Library/Java/JavaVirtualMachines//amazon-corretto-11.jdk/Contents/MacOS/libjli.dylib
dc3-tsd commented 2 years ago

Thanks for making us aware of the issue. We're currently working on a revised fix.

dc3-tsd commented 2 years ago

The 0.1.3 release should resolve this. Can you give it a try and let us know if it's working now?

lacraig2 commented 2 years ago

I tried this. It does not find any JVM candidate.

For the jvm glob it produces the path Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home/Home/server to start searching. This path is not valid so it is not unexpected that it does not find any results.

dc3-tsd commented 2 years ago

We pushed a new commit which is not yet tagged. Let us know if this fixes it.

lacraig2 commented 2 years ago

Looks like it works. Thanks.