Giter VIP home page Giter VIP logo

Comments (3)

mahaloz avatar mahaloz commented on June 14, 2024

Ok, I've answered my own question. THIS IS AMAZING! Truly @justfoxing, amazing project. This works:

[ins] In [1]: import ghidra_bridge
         ...: b = ghidra_bridge.GhidraBridge(namespace=globals()) # creates the bridge and loads the fl
         ...: at API into the global namespace
         ...: print(getState().getCurrentAddress().getOffset())
4196125

[ins] In [2]: module = b.remote_import("ghidra.framework.model")

[ins] In [6]: class MyListener(module.DomainObjectListener):
         ...:     def domainObjectChanged(self, ev):
         ...:         print(ev)
         ...: 

[ins] In [7]: l = MyListener()

[ins] In [8]: l
Out[8]: <_bridged___main__.MyListener('org.python.proxies.__main__$MyListener$7@4082bddb', type=__main__.MyListener, handle=93b68807-cf8e-4a3e-9452-76a43a2198a7)>

[ins] In [9]: currentProgram.addListener(l)

ghidra.framework.model.DomainObjectChangedEvent[source=fauxware - .ProgramDB]

That last line you are seeing is a callback being handled after I changed a name in Ghidra. Wow, I'm honestly amazing.

I did however get one crash on the Ghidra side:

AttributeError: 'ghidra.program.database.ProgramDB' object has no attribute '__module__'
Traceback (most recent call last):
  File "/home/mahaloz/ghidra_scripts/jfx_bridge/bridge.py", line 1003, in local_get
    result = getattr(target, name)
AttributeError: 'ghidra.program.database.ProgramDB' object has no attribute '__module__'
Traceback (most recent call last):
  File "/home/mahaloz/ghidra_scripts/jfx_bridge/bridge.py", line 1003, in local_get
    result = getattr(target, name)
AttributeError: 'instancemethod' object has no attribute '_partialmethod'
Traceback (most recent call last):
  File "/home/mahaloz/ghidra_scripts/jfx_bridge/bridge.py", line 1003, in local_get
    result = getattr(target, name)
AttributeError: 'instancemethod' object has no attribute '__code__'
Traceback (most recent call last):
  File "/home/mahaloz/ghidra_scripts/jfx_bridge/bridge.py", line 1003, in local_get
    result = getattr(target, name)
AttributeError: 'instancemethod' object has no attribute '__defaults__'
Traceback (most recent call last):
  File "/home/mahaloz/ghidra_scripts/jfx_bridge/bridge.py", line 1003, in local_get
    result = getattr(target, name)
AttributeError: 'instancemethod' object has no attribute '__kwdefaults__'
Traceback (most recent call last):
  File "/home/mahaloz/ghidra_scripts/jfx_bridge/bridge.py", line 1003, in local_get
    result = getattr(target, name)
AttributeError: 'instancemethod' object has no attribute '__text_signature__'

from ghidra_bridge.

justfoxing avatar justfoxing commented on June 14, 2024

Yup, you can subclass Java classes remotely, this is super cursed :P Glad you've got your code sorted. Be aware that you may end up with issues if you close your ghidra bridge client while you have a callback like this registered - Ghidra will keep trying to send events to the callback, and the ghidra bridge server will throw exceptions when it finds the connection from the client closed, which can make things very sad if it's a callback that blocks the UI thread. If you do start having problems with that, check out https://github.com/justfoxing/jfx_bridge/#remoteify-and-remote-exec for an example of pushing a custom callback class onto the Ghidra-side to allow you to handle client disconnects safely.

As for the crash - hard to say without seeing the code you're using. Is it actually crashing your code, or is it just logging a bunch of AttributeErrors? IPython in particular queries for a bunch of attributes that may or may not exist as part of its amazing featureset, so a bunch of AttributeErrors are expected there.

from ghidra_bridge.

mahaloz avatar mahaloz commented on June 14, 2024

Yeah @justfoxing, the code I used to trigger this is exactly the code you see above in an IPython instance.
As for the disconnection causing crashes after you disconnect, you are totally right; It does, lol. Thanks for the advice, I'll close the issue since those crashes aren't causing anything bad :).

from ghidra_bridge.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.