A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
Actively maintained. Last release 3 days ago, commits in 8 of the last 26 weeks. A safe choice.
pip install dissect-cstructdissect.cstruct
A Dissect module implementing a parser for C-like structures. Structure parsing in Python made easy. With cstruct, you can write C-like structures and use them to parse binary data, either as file-like objects or bytestrings.
Parsing binary data with cstruct feels familiar and easy. No need to learn a new syntax or the quirks of a new parsing library before you can start parsing data. The syntax isn't strict C but it's compatible with most common structure definitions. You can often use structure definitions from open-source C projects and use them out of the box with little to no changes. Need to parse an EXT4 super block? Just copy the structure definition from the Linux kernel source code. Need to parse some custom file format? Write up a simple structure and immediately start parsing data, tweaking the structure as you go.
By design cstruct is incredibly simple. No complex syntax, filters, pre- or post-processing steps. Just structure parsing. For more information, please see the documentation.
Requirements
This project is part of the Dissect framework and requires Python.
Information on the supported Python versions can be found in the Getting Started section of the documentation.
Installation
dissect.cstruct is available on PyPI.
pip install dissect.cstruct
This module is also automatically installed if you install the dissect package.
Build and test instructions
This project uses tox to build source and wheel distributions. Run the following command from the root folder to build
these:
tox -e build
The build artifacts can be found in the dist/ directory.
tox is also used to run linting and unit tests in a self-contained environment. To run both linting and unit tests
using the default installed Python version, run:
tox
For a more elaborate explanation on how to build and test the project, please see the documentation.
Contributing
The Dissect project encourages any contribution to the codebase. To make your contribution fit into the project, please refer to .