Malcarve
Detects and extracts obfuscated, embedded content from files.
Overview
Malcarve is a tool for detecting and extracting obfuscated, embedded content from files. In particular it is targeted at extracting malicious payloads such as those contained in malware attack documents and droppers.
This version of malcarve has been adapted from https://github.com/shendo/malcarve. Some functionality has been simplified and improved, while other functionality has been removed.
Installation
Malcarve requires gcc to compile its components written in C:
sudo apt install gcc
Note that only linux x86_64 is supported.
Install using pip:
pip install malcarve-cbl
If installed in editable mode, the C compilation script will need to be manually called:
./malcarve-cbl/malcarve_cbl/ext/build.sh
pip install -e malcarve-cbl
Usage
Binary data can be checked for embedded and/or encrypted data via carve_buffer():
from malcarve_cbl.malcarve_cbl import FoundFormat, carve_buffer
data: bytes = b"abYWJjWVdKakVmTG4wTjZBNlB1RWxwcGxaVTVLU1RzNlRSTVM1N2pRMmRlNDk0eUIwRzEzQ1ZZNExEY1hHT1NP"
found_formats: list[FoundFormat] = carve_buffer(data)
print(found_formats[0].content.decode())
print(found_formats[0].encoding_info.encoding_offsets_string)
print(found_formats[0].encoding_info.keyed_encoding_string)
Output:
https://exampleurl.com/this/is/an/example
base64(0x0-0x56)->base64(0x2-0x41)->xor(0x6-0x2f)
xor(key:0x79, bytes:1, increment:13)
In this case, malcarve found an url which had been xor'd, then base64 encoded twice. the xor was identified as being a 2 byte incrementing xor where every time a set of 2 bytes were encoded, the key incremented by 13. The starting key was 0x79.
Dependency management
Dependencies are managed in the pyproject.toml and debian.txt file.
Version pinning is achieved using the uv.lock file.
Because the uv.lock file is configured to use a private UV registry, external developers using UV will need to delete the existing uv.lock file and update the project configuration to point to the publicly available PyPI registry instead.
To add new dependencies it's recommended to use uv with the command uv add <new-package>
or for a dev package uv add --dev <new-dev-package>
The tool used for linting and managing styling is ruff and it is configured via pyproject.toml
The debian.txt file manages the debian dependencies that need to be installed on development systems and docker images.
Sometimes the debian.txt file is insufficient and in this case the Dockerfile may need to be modified directly to install complex dependencies.
Acknowledgements
This repository was based off of https://github.com/shendo/malcarve
Metadata
Release files for malcarve-cbl 13.0.41
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 | Actions |
|---|---|---|---|---|
| malcarve_cbl-13.0.41.tar.gz | 176.6 kB | Without provenance | Details for malcarve_cbl-13.0.41.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| malcarve_cbl-13.0.41-py3-none-any.whl | Python 3 | none | any | Details for malcarve_cbl-13.0.41-py3-none-any.whl |
Total release size: 218.9 kB
Release files / malcarve_cbl-13.0.41.tar.gz
| Download URL | malcarve_cbl-13.0.41.tar.gz |
|---|---|
| Size | 176.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a00710bac010b71be4042a832aad44fb2954acde8dfd1e9e7449333ff2e392bb
|
|
BLAKE2b-256 checksum How to use checksums |
c613d1f4b4152be4641277f9bea7db8f0f963ebb53ab2104c03c467cae31d6cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / malcarve_cbl-13.0.41-py3-none-any.whl
| Download URL | malcarve_cbl-13.0.41-py3-none-any.whl |
|---|---|
| Size | 42.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba255d1a9cc3c0ce5e392601eab7cdc85ac163ec03767e6e2df72949e573ebb7
|
|
BLAKE2b-256 checksum How to use checksums |
c8df33acff5657ad146c0bd6b327217d82c3ce4bbe46092fd78b5e72efac591b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for malcarve-cbl 13.0.41
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.