Skip to content

Commit 40f8164

Browse files
authored
Merge pull request #7 from libdebug/dev
Sync main with dev branch
2 parents cca18d2 + 7c0a412 commit 40f8164

98 files changed

Lines changed: 9982 additions & 188 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
timeout-minutes: 15
2020
strategy:
2121
matrix:
22-
python-version: ["3.10", "3.13"]
22+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
2323

2424
steps:
2525
- uses: actions/checkout@v4
@@ -39,7 +39,7 @@ jobs:
3939
run: |
4040
python -m pip install --upgrade pip
4141
python -m pip install --upgrade wheel build
42-
python -m pip install pwntools pytest libdebug
42+
python -m pip install pwntools pytest libdebug mktestdocs
4343
4444
- name: Install library
4545
run: |

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,65 @@
11
# libdestruct
2+
3+
**Native structs made Pythonic.**
4+
5+
libdestruct is a Python library for defining C-like data structures and inflating them directly from raw memory. It is designed for reverse engineering, binary analysis, and debugger scripting — anywhere you need to make sense of packed binary data without writing boilerplate.
6+
7+
With libdestruct you can:
8+
- Define C structs using Python type annotations
9+
- Read and write typed values from raw memory buffers
10+
- Follow pointers, including self-referential types (linked lists, trees)
11+
- Work with arrays, enums, and nested structs
12+
- Parse C struct definitions directly from source
13+
- Snapshot values and track changes with freeze/diff/reset
14+
15+
## Installation
16+
17+
```bash
18+
pip install git+https://github.com/mrindeciso/libdestruct.git
19+
```
20+
21+
## Your first script
22+
23+
```python
24+
from libdestruct import struct, c_int, c_long, inflater
25+
26+
class player_t(struct):
27+
health: c_int
28+
score: c_long
29+
30+
memory = bytearray(b"\x64\x00\x00\x00\x39\x05\x00\x00\x00\x00\x00\x00")
31+
32+
lib = inflater(memory)
33+
player = lib.inflate(player_t, 0)
34+
35+
print(player.health.value) # 100
36+
print(player.score.value) # 1337
37+
38+
# Write a new value back to memory
39+
player.health.value = 200
40+
print(player.health.value) # 200
41+
```
42+
43+
You can also skip the Python definition and parse C directly:
44+
45+
```python
46+
from libdestruct.c.struct_parser import definition_to_type
47+
48+
player_t = definition_to_type("""
49+
struct player_t {
50+
int health;
51+
long score;
52+
};
53+
""")
54+
55+
player = player_t.from_bytes(b"\x64\x00\x00\x00\x39\x05\x00\x00\x00\x00\x00\x00")
56+
print(player.health.value) # 100
57+
```
58+
59+
## Project Links
60+
61+
Documentation: [docs/](docs/)
62+
63+
## License
64+
65+
libdestruct is licensed under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)