redballoonsecurity / ofrak

OFRAK: unpack, modify, and repack binaries.
https://ofrak.com
Other
1.85k stars 127 forks source link

Minor bugfix: detect when Ghidra client dies unexpectedly #312

Closed ANogin closed 1 year ago

ANogin commented 1 year ago

One sentence summary of this PR (This should go in the CHANGELOG!) Minor bugfix: detect when Ghidra client dies unexpectedly

Link to Related Issue(s) N/A

Please describe the changes in your request. If the Ghidra headless client dies unexpectedly, ghidra_proc.stdout.readline() in GhidraProjectAnalyzer._do_ghidra_import keeps returning an empty string, and the white True: would keep spinning forever. This change catches this scenario.

Just for context, I hit this issue with

[ghidra_analyzer.py:  139] Started ghidra import.: 619
User home directory does not exist: ?
User home directory does not exist: ?
User home directory does not exist: ?
[ghidra_analyzer.py:  145] 

[ghidra_analyzer.py:  145] Failed to find a supported JDK.  Please refer to the Ghidra Installation Guide's Troubleshooting section.

Not sure whether it's worth handling Failed to find a supported JDK explicitly. And I have not yet tried to figure out why "Failed to find a supported JDK" happened in the first place (although I am sure it's something trivial).

Anyone you think should look at this, specifically? Not sure.