Mirror of onekey-sec/unblob
  • Python 97.6%
  • Rust 1.2%
  • Nix 0.9%
  • Shell 0.2%
Find a file
Quentin Kaiser 30534f0e7c
Merge pull request #1693 from onekey-sec/renovate/lock-file-maintenance-pyproject.toml
chore(deps): lock file maintenance (pyproject.toml)
2026-11-03 09:34:09 +00:00
.github chore(deps): update github/codeql-action action to v3.39.1 2026-10-26 17:53:02 +00:00
docs chore: ruff format development docs 2026-10-12 17:34:13 +02:00
fuzzing Refactored report format to use Pydantic. 2025-09-15 07:35:41 -04:00
python/unblob Merge pull request #1693 from onekey-sec/renovate/lock-file-maintenance-pyproject.toml 2026-11-03 09:34:09 +00:00
rust refactor(rust): create python modules declaratively 2026-10-15 23:30:27 +02:00
tests fix(tar): recheck directory paths before restoring their metadata 2026-11-03 10:14:24 +01:00
.dockerignore Add container public docker image workflow 2021-12-13 16:20:16 +01:00
.envrc chore: let direnv watch every .nix file when using nix 2025-04-14 11:06:15 +02:00
.gitattributes feat(docs): improve README file 2026-03-04 17:04:30 +01:00
.gitignore fix(docs): added cache folder to git ignore 2025-05-17 11:28:05 +02:00
.pre-commit-config.yaml feat(rust): auto-generate pyi stubs from pre-commit 2026-10-15 23:30:27 +02:00
.taplo.toml chore: add taplo as a toml formatter and linter 2025-01-13 14:40:36 +01:00
AGENTS.md docs: add AGENTS.md with handler-writing rules for coding agents 2026-10-30 18:14:40 +01:00
Cargo.lock chore(deps): update rust crate pyo3 to v0.29.3 2026-10-12 00:34:32 +00:00
Cargo.toml chore(rust): create a cargo workspace 2025-02-01 17:59:32 +01:00
CLAUDE.md docs: add AGENTS.md with handler-writing rules for coding agents 2026-10-30 18:14:40 +01:00
CODE_OF_CONDUCT.md unblob: renaming leftover references to IoT-Inspector 2022-06-08 21:31:43 +02:00
CONTRIBUTING.md feat(docs): add contribution guide 2026-03-04 15:05:43 +01:00
default.nix chore(nix): make vendored dependencies update-able 2023-06-07 18:05:48 +02:00
deny.toml chore(deps): add cargo deny 2026-03-04 17:05:32 +01:00
Dockerfile fix(docker): build lzfse wheels at build time 2026-09-15 11:07:41 +02:00
flake.lock chore(deps): lock file maintenance (flake.nix) 2026-09-29 09:51:44 +00:00
flake.nix chore(nix): fix check-json-schema pre-commit hook 2026-10-12 17:34:56 +02:00
install-deps.sh chore(deps): move away from www.7-zip.org 2026-11-02 17:40:17 +01:00
LICENSE chore: split license file into LICENSE and NOTICE 2026-03-04 15:05:43 +01:00
mkdocs.yml feat(docs): added extension so that we can mbed Markdown syntax inside raw HTML blocks 2025-05-17 14:15:55 +02:00
NOTICE chore: split license file into LICENSE and NOTICE 2026-03-04 15:05:43 +01:00
overlay.nix chore(deps): migrate from p7zip to 7zip 2026-03-09 09:10:53 +01:00
package.nix feat(handler): add LZFSE decompression handler 2026-08-31 08:57:28 +02:00
pyproject.toml chore(deps): update dependency ruff to v0.17.3 2026-11-03 08:17:46 +00:00
README.md feat(docs): improve README file 2026-03-04 17:04:30 +01:00
renovate.json chore(deps): enable OSV vulnerability alerts in Renovate 2026-03-04 17:06:16 +01:00
rust-toolchain.toml chore(deps): pin rust toolchain with rust-toolchain.toml 2026-03-04 17:05:32 +01:00
SECURITY.md unblob: renaming leftover references to IoT-Inspector 2022-06-08 21:31:43 +02:00
shell.nix fix(nix): unblob packaging needs access to pyproject.toml as well 2025-08-29 15:07:27 +02:00
uv.lock chore(deps): lock file maintenance (pyproject.toml) 2026-11-03 10:19:16 +01:00
vulture_whitelist.py refactor(reporting): move encryption status into metadata 2026-09-08 10:04:27 +02:00

unblob

Accurate, fast, and easy-to-use extraction suite for binary blobs.

unblob parses unknown binary blobs for 78+ archive, compression, and file-system formats, extracts their content recursively, and carves out unknown chunks. It is the perfect companion for extracting, analyzing, and reverse engineering firmware images.

CI PyPI version PyPI downloads License: MIT


Demo

demo


Features

  • 78+ supported formats — archives, compression streams, and file systems including SquashFS, JFFS2, UBI/UBIFS, ext, CPIO, ZIP, 7-Zip, gzip, XZ, LZMA, LZ4, and many more. See the full list.
  • Recursive extraction — extracts containers within containers up to a configurable depth (default: 10 levels).
  • Precise chunk detection — identifies both start and end offsets of each chunk according to the format standard, minimizing false positives.
  • Unknown chunk carving — carves out and reports data that does not match any known format, automatically identifying null/0xFF padding.
  • Entropy analysis — calculates Shannon entropy and chi-square probability for unknown chunks, useful for spotting encrypted or compressed data.
  • JSON metadata reports — generates structured reports with chunk offsets, sizes, entropy, file ownership, permissions, timestamps, and more.
  • Multi-processing — uses all available CPU cores by default for fast extraction.
  • Extensible plugin system — write custom format handlers and extractors and load them at runtime with --plugins-path.
  • No elevated privileges required — runs safely as a regular user.
  • Battle-tested — fuzz tested against a large corpus of firmware images; relies on audited, pinned dependencies.

Installation

pip install unblob

Then install the required external extractor tools. On Ubuntu/Debian:

sudo apt install android-sdk-libsparse-utils e2fsprogs p7zip-full unar zlib1g-dev liblzo2-dev lzop lziprecover libhyperscan-dev zstd lz4

For SquashFS support, also install sasquatch:

curl -L -o sasquatch_1.0.deb "https://github.com/onekey-sec/sasquatch/releases/download/sasquatch-v4.5.1-6/sasquatch_1.0_$(dpkg --print-architecture).deb"
sudo dpkg -i sasquatch_1.0.deb && rm sasquatch_1.0.deb

Verify that all extractors are available:

unblob --show-external-dependencies

Docker (batteries included)

The Docker image bundles all extractors — no extra setup needed:

docker run \
  --rm \
  --pull always \
  -v /path/to/extract-dir:/data/output \
  -v /path/to/files:/data/input \
  ghcr.io/onekey-sec/unblob:latest /data/input/firmware.bin

Note: Mount directories must be owned by the same uid:gid. On multi-user systems, add -u $UID:$GID to the command.

Kali Linux

sudo apt install unblob

Nix

nix profile install nixpkgs#unblob

Or add it to your NixOS/home-manager configuration — see the installation docs for flake and overlay examples.

From source

git clone https://github.com/onekey-sec/unblob.git
cd unblob
uv sync --no-dev
uv run unblob --show-external-dependencies

Requires Python ≥ 3.10, uv, and a Rust toolchain (for the compiled extensions).


Usage

Command line

Extract a file (output goes to <filename>_extract/ by default):

unblob firmware.bin

Specify a custom output directory:

unblob -e /tmp/output firmware.bin

Generate a JSON metadata report:

unblob --report report.json firmware.bin

Limit recursion depth and enable entropy analysis:

unblob -d 5 -n 2 firmware.bin

Skip files matching a magic string prefix:

unblob --skip-magic "POSIX tar archive" firmware.bin

Load a custom handler plugin:

unblob -P ./myplugins/ firmware.bin

Full CLI reference

Usage: unblob [OPTIONS] FILE

Options:
  -e, --extract-dir DIRECTORY     Extract the files to this directory.
  -f, --force                     Force extraction even if outputs already exist.
  -d, --depth INTEGER             Recursion depth (default: 10).
  -n, --entropy-depth INTEGER     Entropy calculation depth (default: 1; 0 = off).
  -P, --plugins-path PATH         Load plugins from the provided path.
  -S, --skip-magic TEXT           Skip files with a given magic prefix.
  -p, --process-num INTEGER       Number of parallel worker processes (default: CPU count).
  --report PATH                   Write a JSON metadata report to this file.
  -k, --keep-extracted-chunks     Keep extracted chunks on disk.
  --delete-extracted-files TEXT   Delete intermediate files after extraction.
  -v, --verbose                   Increase verbosity (-v, -vv, -vvv).
  --show-external-dependencies    List required external tools and their status.
  -h, --help                      Show this message and exit.

Python API

from pathlib import Path
from unblob.processing import ExtractionConfig, process_file

config = ExtractionConfig(
    extract_root=Path("/tmp/output"),
    randomness_depth=1,
)

result = process_file(config, Path("firmware.bin"))

To also write a JSON report:

process_file(config, Path("firmware.bin"), report_file=Path("report.json"))

ExtractionConfig accepts the same options as the CLI: max_depth, process_num, skip_magic, force_extract, keep_extracted_chunks, and more. See the API reference for the full list.


Testing

unblob uses pytest. Integration test fixtures are stored in Git LFS.

# Install Git LFS (one-time setup)
git lfs install

# Install all development dependencies
uv sync --all-extras --dev

# Run the full test suite
uv run pytest tests/ -v

Documentation

Full documentation is available at https://unblob.org:


Contributing

Contributions are welcome! If you would like to add support for a new format or improve an existing one:

  1. Open an issue to describe the format (hex dumps, spec links, and sample files help a lot).
  2. Read the development guide to learn how to write handlers and extractors.
  3. Fork the repository, implement your changes, and open a pull request.

If you just need a format supported and don't want to implement it yourself, open an issue — we'll consider adding it.

See CONTRIBUTING for more details.


License

unblob is licensed under the MIT License.