Skip to main content


decbackup

Python clone of Stormshield SNS's backup decryption utility, built from a full reverse-engineering of decbackup + libncrypto.so

PyPI License Platform Python CI

Features • Installation • Usage • The Format • Development • Releasing • License


decbackup decrypts and verifies Stormshield Network Security (SNS) backup files (.bkup) — no appliance required. It is a faithful Python reimplementation of /usr/Firewall/sbin/decbackup and the backup container code of libncrypto.so, derived from SNS v5.1.4 by static analysis plus an empirical error-code matrix against a live device (see RECON.md).

Features

Feature Description
Byte-exact format support [BACKUP] header, detached PKCS#7 trailer, AES-128-CBC payload
Both password schemes v2 (PBKDF2-HMAC-SHA256) and legacy v1 (salted-SHA1) key derivation
Full signature verification RSA over PKCS#7 authAttrs, messageDigest over header+payload, chain to the four CA certificates embedded in libncrypto, policy 1.3.6.1.4.1.11256.2.3, dates ignored (as on the device)
Original CLI parity same flags (-i -o -p -P -d), same messages, same numeric error codes (0/1/6/7/8/12/13/32) — validated against the real binary on device
Tiny dependency set cryptography only; DER/PKCS#7 parsing is in-tree (decbackup/der.py, pkcs7.py)

About the v1 row: no released SNS version emits the legacy v1 scheme (both tested encbackup builds write v2), so the v1 path is validated only through failure-path vectors, not a decryptable v1 backup.

Installation

pip install decbackup

Or from a checkout:

pip install .

The wheel bundles everything needed at runtime: the package code, the four CA certificates extracted from libncrypto.so (decbackup/certs/), and a decbackup console script. The only dependency is cryptography.

Usage

Usage : () -i <backup> -o <output archive>
                    [-p <password>] [-d : dump backup header]
                    [-P : prompt for password]
                    [--no-verify : skip signature verification (clone extension)]
decbackup -i firewall.bkup -o archive.tar -p 's3cret'
tar tf archive.tar

Success is silent (exit 0), exactly like the original; failure prints decrypt and/or verify backup failed (%d) with the appliance's own error code. -d prints the decoded header block after a successful run.

Output-file contract (same as the device): the -o file is created and truncated early, and deleted on every failure path — a pre-existing file at -o is destroyed even when the backup is rejected.

--no-verify has no counterpart on the device: it skips trailer parsing and signature/chain checks to rescue backups whose signature region is corrupted. It prints a warning and the output is unauthenticated — decryption alone proves the password was right, not that the backup came from a genuine appliance.

Library use:

from decbackup import decrypt_backup, BackupError
try:
    header = decrypt_backup("firewall.bkup", "archive.tar", "s3cret")
    print(header["model"], header["date"])
except BackupError as e:
    print("failed:", e.code)

The Format

0x000   0x400   [BACKUP] key=value header, NUL-terminated, zero-padded
0x400   4       be32 X — PKCS#7 trailer length
0x404   X       detached PKCS#7 SignedData (device cert + CA intermediate)
0x404+X 4       be32 Y — ciphertext length
0x408+X Y       AES-128-CBC ciphertext (PBKDF2-SHA256 key¹, PKCS#7 padding)

¹ v2 key derivation; the legacy v1 scheme instead uses a salted-SHA1 derivation (see RECON.md). Y counts ciphertext bytes including the padding, so it exceeds the plaintext by a partial or full AES block.

The signature covers the full 0x400-byte header block plus the decrypted payload; it chains device cert → Stormshield Network Security Products CA → Stormshield Products Root CA (embedded). Expired device certificates still verify — the appliance ignores dates, so backups stay readable forever. Full details in RECON.md.

Development

decbackup/        the package (cli, backup format, crypto, pkcs7, der, trust, certs/)
analysis/         RE tooling: disassembler, strings, symbol lists, the device
                  extraction script and the empirical error-code matrix
tests/vectors/    device-derived containers + expected payloads:
                  test/nopass/big/mid are stock encbackup output from an
                  SNS 5.1.4 device (cross-validated against the stock
                  decbackup); v1probe/v1badkey are patched v4.2.8
                  containers; extdup/lazyparse are pinned fuzz-crash
                  mutations; trunc/xzero/ct/cert/mv3/v9/yt/ys/mvx are
                  byte-edited probes
legacy/           the earlier single-file iteration (kept for reference)
pip install -e ".[dev]"               # dev extras: ruff
ruff check .                          # lint (same as CI)
python tests/test_decbackup.py        # exit code = number of failures
python analysis/probes.py             # real-vs-clone error-code parity table
python analysis/fuzz.py 30000         # robustness contract fuzzer

Releasing

Tagged pushes (v*) build an sdist + wheel, smoke-test the wheel against one bundled vector (test.bkup: clean decrypt, plus the wrong-password failure contract), and publish to PyPI via trusted publishing (see .github/workflows/release.yml). Pushes to master/main and pull requests run lint + the error-code parity suite on Python 3.9–3.13 (.github/workflows/ci.yml).

git tag v0.1.0 && git push origin v0.1.0   # → PyPI

License

Apache License 2.0 — see LICENSE. The patent grant and patent-retaliation clauses of Apache-2.0 apply.

Stormshield is a trademark of Stormshield. This project is unaffiliated with Stormshield; it exists so that backups you own remain readable.

Metadata

Release files for decbackup 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for decbackup 0.2.0
File Size Uploaded Provenance Actions
decbackup-0.2.0.tar.gz 114.2 kB With provenance Details for decbackup-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for decbackup 0.2.0
File Interpreter ABI Platform Actions
decbackup-0.2.0-py3-none-any.whl Python 3 none any Details for decbackup-0.2.0-py3-none-any.whl

Total release size: 150.2 kB

Release files / decbackup-0.2.0.tar.gz

Download URL decbackup-0.2.0.tar.gz
Size 114.2 kB
Tags Source
SHA-256 checksum
How to use checksums
68fe26b9b4a22f73975c57c5c7e297a6d3152f3564308e1afed6de6fd3786606
BLAKE2b-256 checksum
How to use checksums
6422fe1482cefc72c9c3028a58490bc1376335ea5dbbfaa71f7a761ac1132ca8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / decbackup-0.2.0-py3-none-any.whl

Download URL decbackup-0.2.0-py3-none-any.whl
Size 35.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
321f82853f3c1fb26e1c39895bd46f92fda74899fe339f2a832aa7c97ab8cefa
BLAKE2b-256 checksum
How to use checksums
101ea16cac6702d24e02eb83019a5b470f5bc0d9382e013b8068459d53e89dc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for decbackup 0.2.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for decbackup-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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