binsync / binsync

A reversing plugin for cross-decompiler collaboration, built on git.
https://binsync.net
BSD 2-Clause "Simplified" License
573 stars 41 forks source link

Binsync UI Doesn not open in Ghidra #386

Closed outercloudstudio closed 3 months ago

outercloudstudio commented 3 months ago

Description

When running the start UI script, the UI does not open. This has only started occurring after updating to the latest version.

Steps to reproduce the bug

  1. Install binsync with pip install -U binsync[ghidra] then binsync --install
  2. Launch script within Ghidra
  3. Observe result

Environment

Python: 3.12.4 Windows: 11 Ghidra: 11.1.1 binsync: 4.3.0

Additional context

This is printed in the logs:

binsync_plugin.py> Running...
INFO:libbs_vendored.jfx_bridge.bridge:Server launching in background - will continue to run after launch script finishes...
INFO:libbs_vendored.jfx_bridge.bridge:serving! (jfx_bridge v1.0.0, Python 2.7.3)
binsync_plugin.py> Finished!
WARNING:libbs_vendored.jfx_bridge.bridge:Handling connection from ('127.0.0.1', 59209)
WARNING:libbs_vendored.jfx_bridge.bridge:Closing connection from ('127.0.0.1', 59209)
outercloudstudio commented 3 months ago

After some investigation it looks like BridgeClosedException is causing the bridge to stop.

outercloudstudio commented 3 months ago

This could be an issue with the jfx bridge

outercloudstudio commented 3 months ago

Earliest working version: 4.1.12

mahaloz commented 3 months ago

@outercloudstudio yeah the exception you see is caused by something going wrong on the Python side and crashing. Causing this later exception. Thanks for all the debugging. I'll take a look.

If you end up having time, it would help even more if you could once do the following:

  1. In Ghidra scripts, enable the libbs start server script
  2. In Tools->Libbs start the Libbs backend.
  3. In another terminal, run binsync -s ghidra

That last step will either correctly start binsync, or show you the real root cause error. Ty!

outercloudstudio commented 3 months ago

Installing binsync[extras] so that I can run the -s ghidra right now 👍

outercloudstudio commented 3 months ago

I am getting this error when trying to run the command binsync -s ghidra

binsync -s ghidra
INFO | 2024-07-08 01:28:11,110 | binsync.extras | Extras not installed, some features will not be available.
usage: binsync [-h] [--install] [--install-angr-only INSTALL_ANGR_ONLY] [--run-plugin RUN_PLUGIN]
binsync: error: unrecognized arguments: -s ghidra
outercloudstudio commented 3 months ago

Okay I swapped out the command for binsync --run-plugin ghidra and the UI momentarily opened before crashing and returning this error:

Traceback (most recent call last):
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\Scripts\binsync.exe\__main__.py", line 7, in <module>
    sys.exit(main())
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\__main__.py", line 125, in main
    return run_plugin(args.run_plugin)
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\__main__.py", line 27, in run_plugin
    return plugin.start()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\decompilers\ghidra\server\__init__.py", line 5, in start
    start_ui()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\decompilers\ghidra\server\control_panel_window.py", line 66, in start_ui
    connected = cp_window.configure()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\decompilers\ghidra\server\control_panel_window.py", line 46, in configure
    config = ConfigureBSDialog(self.controller)
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\ui\config_dialog.py", line 252, in __init__
    self._init_widgets()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\ui\config_dialog.py", line 285, in _init_widgets
    self._fill_table_with_configs()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\ui\config_dialog.py", line 316, in _fill_table_with_configs
    top_conf = self.load_saved_config()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\ui\config_dialog.py", line 486, in load_saved_config
    config = self.controller.load_saved_config()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\api\controller.py", line 1215, in load_saved_config
    config = ProjectConfig.load_from_file(self.binary_path() or "")
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\decompilers\ghidra\server\controller.py", line 28, in binary_path
    return self.ghidra.binary_path
  File "C:\Users\outer\AppData\Local\Programs\Python\Python310-32\lib\site-packages\binsync\decompilers\ghidra\server\ghidra_client.py", line 96, in binary_path
    return self.server.binaryPath()
AttributeError: 'NoneType' object has no attribute 'binaryPath'

I believe this is what you were looking for @mahaloz

mahaloz commented 3 months ago

@outercloudstudio thats exactly what I was looking for! However, it also seems your running an outdated binsync. Can you go back to latest?

outercloudstudio commented 3 months ago

@outercloudstudio thats exactly what I was looking for! However, it also seems your running an outdated binsync. Can you go back to latest?

Should I install binsync or binsync[ghidra] because it looks like binsync[ghidra] is on a lower version.

Attempting to run binsync -s ghidra on 4.3.0 has this error:

from PySide6.QtCore import (
ModuleNotFoundError: No module named 'PySide6'

I tried a quick fix of pip install pyside6 but with no luck.

pip install pyside6
ERROR: Could not find a version that satisfies the requirement pyside6 (from versions: none)
ERROR: No matching distribution found for pyside6
outercloudstudio commented 3 months ago

I downgraded to python 3.9 and I can install the normal binsync. However running binsync -s ghidra results in this error:

Traceback (most recent call last):
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\Scripts\binsync.exe\__main__.py", line 7, in <module>
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\binsync\__main__.py", line 141, in main
    start_ghidra_remote_ui()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\binsync\interface_overrides\ghidra.py", line 53, in start_ghidra_remote_ui
    cp_window = ControlPanelWindow()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\binsync\interface_overrides\ghidra.py", line 28, in __init__
    self._interface = DecompilerInterface.discover(force_decompiler=GHIDRA_DECOMPILER)
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\api\decompiler_interface.py", line 785, in discover
    return deci_class(**interface_kwargs)
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\decompilers\ghidra\interface.py", line 60, in __init__
    super().__init__(
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\api\decompiler_interface.py", line 104, in __init__
    self.config = config if config is not None else LibbsConfig.update_or_make()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\configuration.py", line 142, in update_or_make
    config.save()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\configuration.py", line 30, in save
    self.save_location.parent.mkdir()
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1323, in mkdir
    self._accessor.mkdir(self, mode)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\outer\\AppData\\Local\\libbs\\libbs'
Exception ignored in: <function GhidraDecompilerInterface.__del__ at 0x000002AF024A6280>
Traceback (most recent call last):
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\decompilers\ghidra\interface.py", line 68, in __del__
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\decompilers\ghidra\interface.py", line 115, in shutdown
  File "C:\Users\outer\AppData\Local\Programs\Python\Python39\lib\site-packages\libbs\api\decompiler_interface.py", line 151, in shutdown
AttributeError: 'GhidraDecompilerInterface' object has no attribute 'config'

FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\outer\\AppData\\Local\\libbs\\libbs'

outercloudstudio commented 3 months ago

@mahaloz I got it to run. Manually creating the folder at C:\Users\outer\AppData\Local\libbs fixed it

mahaloz commented 3 months ago

@outercloudstudio to upgrade the version just do:

pip install -U binsync

Since you already will have the ghidra deps. I think I fixed your issue in #385. Upgrade to version 4.3.1 and it should be fixed. Lmk if not.

outercloudstudio commented 3 months ago

Yep it's fixed 👍