GitXplorerGitXplorer
d

strudra

public
28 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
3c618779f9a9cf646d145e3ab703a0b4e7dbb767

Update README.md

ddomenukk committed 4 years ago
Verified
49e2f012c521cc88712141918370a55399ae2401

Update README.md

ddomenukk committed 4 years ago
Unverified
56642038f6f900e5a7e665a53fe3fd872358caaa

caching, docs, v11

ddomenukk committed 4 years ago
Unverified
92b2941ef3691d35ec7c4242417dcfa56d533edf

ready for pip

ddomenukk committed 4 years ago
Unverified
0bf40e7ac6acdcf624eb48a6082f8431cf8df053

added local file store

ddomenukk committed 4 years ago
Unverified
9c1dd3f095407d8056142373dbea071382e232d2

embed cache

ddomenukk committed 4 years ago

README

The README file for this repository.

Strudra

Welcome to Strudra, a way to craft Ghidra structs in python, using ghidra_bridge.

It's quite convenient together with IPython, featuring tab completion, etc. Also, it can import, and somewhat export (try .to_cstruct_str()) c structs from and to Ghidra.

How Studra Works

Strudra loads all structs from Ghidra. For this to work, you have to setup ghidra_bridge in Ghidra: https://github.com/justfoxing/ghidra_bridge/

Then, you can create instances of these structs, set values in these structs, and serialize them. Good if you want to interact with your target.

How to Strud

First, install using pip install --user strudra. Afterwards, you can init a Strudra object. For this, you first have to setup and start ghidra_bridge in Ghidra.

Then, you can create a new strudra object.

from strudra import strudra

sd = strudra.Strudra()

You can pass in a custom Ghidra Bridge here, if you like. By default, it will serialize all data received from ghidra to struds.json, and reload from there, if Ghidra bridge is not available. You can pass in a different filename to cache to, or None to disable caching. You can even force_from_file=True, if you don't want any Ghdira interaction in subsequent runs.

We can now use all structs from Ghidra, but let's add one just for this example.

sd.add_struct("struct test{ int test1; char test2[2]; };")

Creating a Strud

Now, we can access the new test struct from ghidra. We can alread set values in the constructor

test_struct = sd.test(test1=0x1337)

We can use struct members by name or by offset

assert (test_struct.test == test_struct[0x0])

Arrays work, too!

test_struct.test2 = [0x42, 0x42]

Oh, and nested structs are fine as well, just try it! ;)

Reload

After having reversed new Structs in Ghidra, call reload on the Strudra object to get the latest updates.

Serialize

At the end, we can get the serialized bytes back, all members the correct byte order, and use it for example in pwntools.

bytes(test_struct)

Enjoy a new reverse engineering experience.