disasm2vec
disasm2vec is a research framework designed to generate vector representations from disassembled C/C++ binaries. It provides a modular pipeline that handles compilation, disassembly, tokenization, and vectorization, enabling researchers and security analysts to transform raw code into machine-learning-ready features.
Features
- Automated Compilation: Seamlessly compiles C and C++ source files using GCC.
- Disassembly Wrapper: Extracts assembly instructions using
objdump, supporting both full and function-specific disassembly. - Intelligent Tokenization: Normalizes and cleans assembly instructions, with options to preserve or abstract register names.
- Vectorization: Implements TF-IDF vectorization with a flexible factory pattern for easy model management.
- End-to-End Pipeline: Orchestrates the entire process from source code to vector embedding.
- Extensible Architecture: Built with abstract base classes to easily support new compilers, disassemblers, or vectorizers.
Prerequisites
- Python: version 3.10 or higher.
- Operating System: Linux or Windows Subsystem for Linux (WSL).
- GCC: Required for compiling source files.
- Objdump: Required for disassembling binaries.
Note: The compilation (gcc) and disassembly (objdump) modules rely on system-level tools typically found in Linux environments. If you are on Windows, please use WSL.
Ensure both gcc and objdump are installed and available in your system's PATH.
Installation
Install directly from PyPI:
pip install disasm2vec
Or install from source:
git clone https://github.com/yourusername/disasm2vec.git
cd disasm2vec
pip install .
Usage
The core of the framework is the PipelineRunner, which processes a source file based on a configuration object.
Basic Example
from disasm2vec.pipeline import PipelineConfig, run_pipeline
# Configure the pipeline
config = PipelineConfig(
source_file="examples/sample.c",
build_dir="build",
asm_dir="asm",
model_path="models/base_tfidf_asm.pkl" # Path to pre-trained model or where to save a new one
)
# Run the pipeline
# returns:
# vector: The vector representation of the source file
# vectorizer: The fitted vectorizer instance
vector, vectorizer = run_pipeline(config)
print(f"Generated Vector Shape: {vector.shape}")
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for disasm2vec 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| disasm2vec-0.1.0.tar.gz | 36.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| disasm2vec-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.6 kB
Release files / disasm2vec-0.1.0.tar.gz
| Download URL | disasm2vec-0.1.0.tar.gz |
|---|---|
| Size | 36.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4efda753719a43240132b567ed558926ff43b47171f41f62caba1db0f7acb8ae
|
|
BLAKE2b-256 checksum How to use checksums |
b39ce43f371defe1363fff3d8cfeb56b7f4f7e174413657f2df919c457b8e621
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / disasm2vec-0.1.0-py3-none-any.whl
| Download URL | disasm2vec-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72acca07311400d24c50bb7f600abf11e2c4a73fb4e9ad7c94e0722191a8abb2
|
|
BLAKE2b-256 checksum How to use checksums |
90b3e06768a8c83dfbc9b0adf2fb99f47ff49eac081956aa977919a2aa148917
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for disasm2vec 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.