clearbluejar / ghidriff

Python Command-Line Ghidra Binary Diffing Engine
https://clearbluejar.github.io/ghidriff/
GNU General Public License v3.0
507 stars 21 forks source link

Ghidra 11.1 breaks BSIM #95

Closed clearbluejar closed 3 months ago

clearbluejar commented 3 months ago

In Ghidra 11.1, a new check was introduced to VTsession create. This would check to see if the destination program was RW.

Exception has occurred: ghidra.util.ReadOnlyException
ghidra.util.ReadOnlyException: VT Session destination program is read-only which prevents its use
Exception: Java Exception

The above exception was the direct cause of the following exception:

  File "/workspaces/ghidriff/ghidriff/bsim.py", line 82, in correlate_bsim
    session: VTSession = VTSessionDB.createVTSession(bsim_factory.name, p1, p2, session_ref)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/ghidriff/ghidriff/version_tracking_diff.py", line 138, in find_matches
    correlate_bsim(self, matches, p1, p2, p1_matches, p2_matches, monitor, self.logger,
  File "/workspaces/ghidriff/ghidriff/ghidra_diff_engine.py", line 1267, in diff_bins
    unmatched, matched, skip_types = self.find_matches(p1, p2)
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/ghidriff/ghidriff/__main__.py", line 88, in main
    pdiff = d.diff_bins(diff[0], diff[1])
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/ghidriff/ghidriff/__main__.py", line 104, in <module>
    main()
ghidra.util.ghidra.util.ReadOnlyException: ghidra.util.ReadOnlyException: VT Session destination program is read-only which prevents its use

Here: https://github.com/NationalSecurityAgency/ghidra/blob/ebfd108ddecfd0964ffa51f1cc8fcc3c70f3e7df/Ghidra/Features/VersionTracking/src/main/java/ghidra/feature/vt/api/db/VTSessionDB.java#L368-L374

clearbluejar commented 3 months ago

We can provide a workaround by manipulating a private variable in Java with reflection.

https://stackoverflow.com/questions/30107772/changing-of-private-variables