Skip to main content

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

malcarve_cbl-12.0.21.tar.gz (140.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

malcarve_cbl-12.0.21-py3-none-any.whl (42.3 kB view details)

Uploaded Python 3

File details

Details for the file malcarve_cbl-12.0.21.tar.gz.

File metadata

  • Download URL: malcarve_cbl-12.0.21.tar.gz
  • Upload date:
  • Size: 140.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for malcarve_cbl-12.0.21.tar.gz
Algorithm Hash digest
SHA256 bb1528cfe1a9e4daa0619252b236772fe6f5671f8a52dcaf39d8b88e6a31e3fa
MD5 a2f196312e77f891bed92e2df775bc8a
BLAKE2b-256 d6a0aaabdc0f05c496f69b583631b2ef8124ef5abd18b43ead0b3be68bfa1d39

See more details on using hashes here.

File details

Details for the file malcarve_cbl-12.0.21-py3-none-any.whl.

File metadata

  • Download URL: malcarve_cbl-12.0.21-py3-none-any.whl
  • Upload date:
  • Size: 42.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for malcarve_cbl-12.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 417964514a3bfe9b651c97926c247e9fe516836786932449e287f25abcc50426
MD5 942ddd188ab5066d9e5d64d824405cdb
BLAKE2b-256 6e3aeb4a63b56f25bd12a8803b4219eebabd9439c00e05155e845808934b5d3b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

12.0.21 This release

2 files

11.0.11

2 files

10.0.9

2 files

10.0.2

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page