Comments (3)
Hi, Tom.
Could you give me the actual code you're running across the GhidraBridge to get this issue? I'm unable to replicate it across the bridge as written (using ghidra_bridge 0.2.5, jfx_bridge 0.7.1, and Ghidra 9.1.2) - when I make some modifications to work around an unrelated issue (thanks for helping me find that! [but it's not your problem :P]), I get the expected behaviour (data populated in the buffer - I'm using an ELF file instead of a PE because that's what I had open, but that won't make a difference). Here's what works for me:
In [1]: import ghidra_bridge
In [2]: b = ghidra_bridge.GhidraBridge(namespace=globals())
In [3]: array = b.remote_import("array")
In [4]: start = 0x100000
In [5]: length = 16
In [6]: buffer = b.remote_eval("array.array('b', data)", array=array, data = b"\0"*length) # need to remote_eval this to work around "b" being set to unicode by the bridge
In [7]: print(buffer)
array('b', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
In [8]: currentProgram.getMemory().getBytes(currentProgram.getAddressFactory().getDefaultAddressSpace().getAddress(hex(start)), buffer)
Out[8]: 16
In [9]: print(buffer)
array('b', [127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
Similarly, when I run your code directly in the Ghidra python interpreter, I get the expected behaviour:
>>> import array
>>> length = 16
>>> start = 0x100000
>>> buffer = array.array ("b", b"\0" * length)
>>> print(buffer)
array('b', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
>>> currentProgram.getMemory().getBytes(currentProgram.getAddressFactory().getDefaultAddressSpace().getAddress(hex(start)), buffer)
16
>>> print(buffer)
array('b', [127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
from ghidra_bridge.
Added a fix to the unrelated issue in jfx_bridge 0.8.0. So with that, the bridged code now reads:
In [1]: import ghidra_bridge
In [2]: b = ghidra_bridge.GhidraBridge(namespace=globals())
In [3]: array = b.remote_import("array")
In [4]: start = 0x100000
In [5]: length = 16
In [6]: buffer = array.array("b", b"\0"*length)
In [7]: print(buffer)
array('b', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
In [8]: currentProgram.getMemory().getBytes(currentProgram.getAddressFactory().getDefaultAddressSpace().getAddress(hex(start)), buffer)
Out[8]: 16
In [9]: print(buffer)
array('b', [127, 69, 76, 70, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
It makes no difference to your problem, just slightly cleaner.
from ghidra_bridge.
Ahh, so I was doing something stupid!
This was key...
array = self.bridge.remote_import("array")
buffer = self.bridge.remote_eval("array.array('b', data)", array=array, data = b"\0"*length)
With that in place everything works very much as expected, thanks for your assistance!
from ghidra_bridge.
Related Issues (20)
- AttributeError: 'instancemethod' object has no attribute '__len__' (bridge.py", line 974) HOT 5
- PyPI description has three sequential steps all numbered "1" HOT 2
- Timeout value is not configurable in `ghidra_bridge_server.py` HOT 1
- Are you able to write to a ghidra project? HOT 1
- findBytes return an empty Array HOT 1
- Unable to stop auto-analysis for script connected via ghidra_bridge HOT 1
- Expose other IPC channels HOT 1
- How to put arguments in remote_eval?
- setComment causes BridgeException HOT 2
- Cannot inherit bridged classes HOT 1
- Unhashable type _bridged_ghidra.program.database.function.FunctionDB HOT 2
- Bad file descriptor HOT 1
- Socket not closed, when GhidraBridge Object gets out of scope HOT 5
- Timeout Condition HOT 6
- How to remote debug with VSCode? HOT 4
- Windows: Binding on low port blocked by firewall HOT 3
- How to pass arguments to the post script HOT 1
- Question: how does the RPC bridge handle class callbacks? HOT 3
- using in IDE with proper auto completion
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ghidra_bridge.