decbackup 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- decbackup-0.1.0/LICENSE +191 -0
- decbackup-0.1.0/PKG-INFO +181 -0
- decbackup-0.1.0/README.md +155 -0
- decbackup-0.1.0/decbackup/__init__.py +10 -0
- decbackup-0.1.0/decbackup/__main__.py +5 -0
- decbackup-0.1.0/decbackup/backup.py +238 -0
- decbackup-0.1.0/decbackup/certs/netasq-firewall-ca.der +0 -0
- decbackup-0.1.0/decbackup/certs/stormshield-product-and-services-root-ca.der +0 -0
- decbackup-0.1.0/decbackup/certs/stormshield-products-root-ca.der +0 -0
- decbackup-0.1.0/decbackup/certs/stormshield-sns-enrollment-products-ca.der +0 -0
- decbackup-0.1.0/decbackup/cli.py +110 -0
- decbackup-0.1.0/decbackup/crypto.py +82 -0
- decbackup-0.1.0/decbackup/der.py +77 -0
- decbackup-0.1.0/decbackup/pkcs7.py +239 -0
- decbackup-0.1.0/decbackup/trust.py +187 -0
- decbackup-0.1.0/decbackup.egg-info/PKG-INFO +181 -0
- decbackup-0.1.0/decbackup.egg-info/SOURCES.txt +22 -0
- decbackup-0.1.0/decbackup.egg-info/dependency_links.txt +1 -0
- decbackup-0.1.0/decbackup.egg-info/entry_points.txt +2 -0
- decbackup-0.1.0/decbackup.egg-info/requires.txt +4 -0
- decbackup-0.1.0/decbackup.egg-info/top_level.txt +1 -0
- decbackup-0.1.0/pyproject.toml +53 -0
- decbackup-0.1.0/setup.cfg +4 -0
- decbackup-0.1.0/tests/test_decbackup.py +216 -0
decbackup-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined in Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (as well as "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation of a Source form, including but not limited to
|
|
32
|
+
compiled object code, generated documentation, and conversions to
|
|
33
|
+
other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright
|
|
52
|
+
owner or by an individual or Legal Entity authorized to submit on
|
|
53
|
+
behalf of the copyright owner. For the purposes of this definition,
|
|
54
|
+
"submitted" means any form of electronic, verbal, or written
|
|
55
|
+
communication sent to the Licensor or its representatives, including
|
|
56
|
+
but not limited to communication on electronic mailing lists, source
|
|
57
|
+
code control systems, and issue tracking systems that are managed by,
|
|
58
|
+
or on behalf of, the Licensor for the purpose of discussing and
|
|
59
|
+
improving the Work, but excluding communication that is conspicuously
|
|
60
|
+
marked or otherwise designated in writing by the copyright owner as
|
|
61
|
+
"Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025-2026 fl0l0u
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
decbackup-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: decbackup
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python clone of Stormshield SNS's decbackup: decrypt and verify .bkup appliance backups without the device
|
|
5
|
+
Author: fl0l0u
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/fl0l0u/decbackup
|
|
8
|
+
Project-URL: Documentation, https://github.com/fl0l0u/decbackup#readme
|
|
9
|
+
Project-URL: Repository, https://github.com/fl0l0u/decbackup.git
|
|
10
|
+
Project-URL: Issues, https://github.com/fl0l0u/decbackup/issues
|
|
11
|
+
Keywords: stormshield,sns,backup,decbackup,pkcs7,forensics
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: System Administrators
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Topic :: Security :: Cryptography
|
|
18
|
+
Classifier: Topic :: System :: Archiving
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: cryptography>=41
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
<h1 align="center">
|
|
28
|
+
<br>
|
|
29
|
+
decbackup
|
|
30
|
+
<br>
|
|
31
|
+
</h1>
|
|
32
|
+
|
|
33
|
+
<h4 align="center">Python clone of Stormshield SNS's backup decryption utility, built from a full reverse-engineering of decbackup + libncrypto.so</h4>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<a href="https://pypi.org/project/decbackup/">
|
|
37
|
+
<img src="https://img.shields.io/pypi/v/decbackup?style=flat-square" alt="PyPI">
|
|
38
|
+
</a>
|
|
39
|
+
<a href="LICENSE">
|
|
40
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
41
|
+
</a>
|
|
42
|
+
<img src="https://img.shields.io/badge/platform-any-lightgrey?style=flat-square" alt="Platform">
|
|
43
|
+
<img src="https://img.shields.io/badge/python-3.9%2B-yellow?style=flat-square" alt="Python">
|
|
44
|
+
<a href="https://github.com/fl0l0u/decbackup/actions">
|
|
45
|
+
<img src="https://img.shields.io/github/actions/workflow/status/fl0l0u/decbackup/ci.yml?style=flat-square&label=CI" alt="CI">
|
|
46
|
+
</a>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<p align="center">
|
|
50
|
+
<a href="#features">Features</a> •
|
|
51
|
+
<a href="#installation">Installation</a> •
|
|
52
|
+
<a href="#usage">Usage</a> •
|
|
53
|
+
<a href="#the-format">The Format</a> •
|
|
54
|
+
<a href="#development">Development</a> •
|
|
55
|
+
<a href="#license">License</a>
|
|
56
|
+
</p>
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
**decbackup** decrypts and verifies Stormshield Network Security (SNS)
|
|
61
|
+
backup files (`.bkup`) — no appliance required. It is a faithful Python
|
|
62
|
+
reimplementation of `/usr/Firewall/sbin/decbackup` and the backup container
|
|
63
|
+
code of `libncrypto.so`, derived from SNS **v5.1.4** by static analysis
|
|
64
|
+
plus an empirical error-code matrix against a live device (see
|
|
65
|
+
[RECON.md](RECON.md)).
|
|
66
|
+
|
|
67
|
+
## Features
|
|
68
|
+
|
|
69
|
+
| Feature | Description |
|
|
70
|
+
|---------|-------------|
|
|
71
|
+
| **Byte-exact format support** | `[BACKUP]` header, detached PKCS#7 trailer, AES-128-CBC payload |
|
|
72
|
+
| **Both password schemes** | v2 (PBKDF2-HMAC-SHA256) and legacy v1 (salted-SHA1) key derivation |
|
|
73
|
+
| **Full signature verification** | RSA over PKCS#7 authAttrs, messageDigest over header+payload, chain to the four CAs embedded in libncrypto, policy 1.3.6.1.4.1.11256.2.3, dates ignored (as on the device) |
|
|
74
|
+
| **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 |
|
|
75
|
+
| **Tiny dependency set** | `cryptography` only; DER/PKCS#7 parsing is in-tree (`decbackup/der.py`, `pkcs7.py`) |
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pip install decbackup
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or from a checkout:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install .
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The wheel bundles everything needed at runtime: the package code, the
|
|
90
|
+
four CA certificates extracted from `libncrypto.so` (`decbackup/certs/`),
|
|
91
|
+
and a `decbackup` console script. The only dependency is
|
|
92
|
+
`cryptography`.
|
|
93
|
+
|
|
94
|
+
## Usage
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Usage : () -i <backup> -o <output archive>
|
|
98
|
+
[-p <password>] [-d : dump backup header]
|
|
99
|
+
[-P : prompt for password]
|
|
100
|
+
[--no-verify : skip signature verification (clone extension)]
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
decbackup -i firewall.bkup -o archive.tar -p 's3cret'
|
|
105
|
+
tar tf archive.tar
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Success is silent (exit 0), exactly like the original; failure prints
|
|
109
|
+
`decrypt and/or verify backup failed (%d)` with the appliance's own error
|
|
110
|
+
code. `-d` prints the decoded header block after a successful run.
|
|
111
|
+
|
|
112
|
+
`--no-verify` has no counterpart on the device: it skips trailer
|
|
113
|
+
parsing and signature/chain checks to rescue backups whose signature
|
|
114
|
+
region is corrupted. It prints a warning and the output is
|
|
115
|
+
**unauthenticated** — decryption alone proves the password was right,
|
|
116
|
+
not that the backup came from a genuine appliance.
|
|
117
|
+
|
|
118
|
+
Library use:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from decbackup import decrypt_backup, BackupError
|
|
122
|
+
try:
|
|
123
|
+
header = decrypt_backup("firewall.bkup", "archive.tar", "s3cret")
|
|
124
|
+
print(header["model"], header["date"])
|
|
125
|
+
except BackupError as e:
|
|
126
|
+
print("failed:", e.code)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## The Format
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
0x000 0x400 [BACKUP] key=value header, NUL-terminated, zero-padded
|
|
133
|
+
0x400 4 be32 X — PKCS#7 trailer length
|
|
134
|
+
0x404 X detached PKCS#7 SignedData (device cert + CA intermediate)
|
|
135
|
+
0x404+X 4 be32 Y — payload length
|
|
136
|
+
0x408+X Y AES-128-CBC ciphertext (PBKDF2-SHA256 key, PKCS#7 padding)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The signature covers the **full 0x400-byte header block plus the decrypted
|
|
140
|
+
payload**; it chains device cert → *Stormshield Network Security Products
|
|
141
|
+
CA* → *Stormshield Products Root CA* (embedded). Expired device
|
|
142
|
+
certificates still verify — the appliance ignores dates, so backups stay
|
|
143
|
+
readable forever. Full details in [RECON.md](RECON.md).
|
|
144
|
+
|
|
145
|
+
## Development
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
decbackup/ the package (cli, backup format, crypto, pkcs7, der, trust, certs/)
|
|
149
|
+
analysis/ RE tooling: disassembler, strings, symbol lists, the device
|
|
150
|
+
extraction script and the empirical error-code matrix
|
|
151
|
+
tests/vectors/ real encbackup-produced backups + expected payloads
|
|
152
|
+
(created on an SNS 5.1.4 device, cross-validated against
|
|
153
|
+
the stock decbackup)
|
|
154
|
+
legacy/ the earlier single-file iteration (kept for reference)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
python tests/test_decbackup.py # exit code = number of failures
|
|
159
|
+
python analysis/probes.py # real-vs-clone error-code parity table
|
|
160
|
+
python analysis/fuzz.py 30000 # robustness contract fuzzer
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Releasing
|
|
164
|
+
|
|
165
|
+
Tagged pushes (`v*`) build an sdist + wheel, smoke-test the wheel against
|
|
166
|
+
the bundled device vectors, and publish to PyPI via trusted publishing
|
|
167
|
+
(see `.github/workflows/release.yml`). Pushes and PRs run lint + the
|
|
168
|
+
error-code parity suite on Python 3.9–3.13
|
|
169
|
+
(`.github/workflows/ci.yml`).
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
git tag v0.1.0 && git push origin v0.1.0 # → PyPI
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
Apache License 2.0 — see [LICENSE](LICENSE). The patent grant and
|
|
178
|
+
patent-retaliation clauses of Apache-2.0 apply.
|
|
179
|
+
|
|
180
|
+
*Stormshield* is a trademark of Stormshield. This project is unaffiliated
|
|
181
|
+
with Stormshield; it exists so that backups you own remain readable.
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<br>
|
|
3
|
+
decbackup
|
|
4
|
+
<br>
|
|
5
|
+
</h1>
|
|
6
|
+
|
|
7
|
+
<h4 align="center">Python clone of Stormshield SNS's backup decryption utility, built from a full reverse-engineering of decbackup + libncrypto.so</h4>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://pypi.org/project/decbackup/">
|
|
11
|
+
<img src="https://img.shields.io/pypi/v/decbackup?style=flat-square" alt="PyPI">
|
|
12
|
+
</a>
|
|
13
|
+
<a href="LICENSE">
|
|
14
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
15
|
+
</a>
|
|
16
|
+
<img src="https://img.shields.io/badge/platform-any-lightgrey?style=flat-square" alt="Platform">
|
|
17
|
+
<img src="https://img.shields.io/badge/python-3.9%2B-yellow?style=flat-square" alt="Python">
|
|
18
|
+
<a href="https://github.com/fl0l0u/decbackup/actions">
|
|
19
|
+
<img src="https://img.shields.io/github/actions/workflow/status/fl0l0u/decbackup/ci.yml?style=flat-square&label=CI" alt="CI">
|
|
20
|
+
</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="#features">Features</a> •
|
|
25
|
+
<a href="#installation">Installation</a> •
|
|
26
|
+
<a href="#usage">Usage</a> •
|
|
27
|
+
<a href="#the-format">The Format</a> •
|
|
28
|
+
<a href="#development">Development</a> •
|
|
29
|
+
<a href="#license">License</a>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
**decbackup** decrypts and verifies Stormshield Network Security (SNS)
|
|
35
|
+
backup files (`.bkup`) — no appliance required. It is a faithful Python
|
|
36
|
+
reimplementation of `/usr/Firewall/sbin/decbackup` and the backup container
|
|
37
|
+
code of `libncrypto.so`, derived from SNS **v5.1.4** by static analysis
|
|
38
|
+
plus an empirical error-code matrix against a live device (see
|
|
39
|
+
[RECON.md](RECON.md)).
|
|
40
|
+
|
|
41
|
+
## Features
|
|
42
|
+
|
|
43
|
+
| Feature | Description |
|
|
44
|
+
|---------|-------------|
|
|
45
|
+
| **Byte-exact format support** | `[BACKUP]` header, detached PKCS#7 trailer, AES-128-CBC payload |
|
|
46
|
+
| **Both password schemes** | v2 (PBKDF2-HMAC-SHA256) and legacy v1 (salted-SHA1) key derivation |
|
|
47
|
+
| **Full signature verification** | RSA over PKCS#7 authAttrs, messageDigest over header+payload, chain to the four CAs embedded in libncrypto, policy 1.3.6.1.4.1.11256.2.3, dates ignored (as on the device) |
|
|
48
|
+
| **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 |
|
|
49
|
+
| **Tiny dependency set** | `cryptography` only; DER/PKCS#7 parsing is in-tree (`decbackup/der.py`, `pkcs7.py`) |
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install decbackup
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or from a checkout:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The wheel bundles everything needed at runtime: the package code, the
|
|
64
|
+
four CA certificates extracted from `libncrypto.so` (`decbackup/certs/`),
|
|
65
|
+
and a `decbackup` console script. The only dependency is
|
|
66
|
+
`cryptography`.
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Usage : () -i <backup> -o <output archive>
|
|
72
|
+
[-p <password>] [-d : dump backup header]
|
|
73
|
+
[-P : prompt for password]
|
|
74
|
+
[--no-verify : skip signature verification (clone extension)]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
decbackup -i firewall.bkup -o archive.tar -p 's3cret'
|
|
79
|
+
tar tf archive.tar
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Success is silent (exit 0), exactly like the original; failure prints
|
|
83
|
+
`decrypt and/or verify backup failed (%d)` with the appliance's own error
|
|
84
|
+
code. `-d` prints the decoded header block after a successful run.
|
|
85
|
+
|
|
86
|
+
`--no-verify` has no counterpart on the device: it skips trailer
|
|
87
|
+
parsing and signature/chain checks to rescue backups whose signature
|
|
88
|
+
region is corrupted. It prints a warning and the output is
|
|
89
|
+
**unauthenticated** — decryption alone proves the password was right,
|
|
90
|
+
not that the backup came from a genuine appliance.
|
|
91
|
+
|
|
92
|
+
Library use:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
from decbackup import decrypt_backup, BackupError
|
|
96
|
+
try:
|
|
97
|
+
header = decrypt_backup("firewall.bkup", "archive.tar", "s3cret")
|
|
98
|
+
print(header["model"], header["date"])
|
|
99
|
+
except BackupError as e:
|
|
100
|
+
print("failed:", e.code)
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## The Format
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
0x000 0x400 [BACKUP] key=value header, NUL-terminated, zero-padded
|
|
107
|
+
0x400 4 be32 X — PKCS#7 trailer length
|
|
108
|
+
0x404 X detached PKCS#7 SignedData (device cert + CA intermediate)
|
|
109
|
+
0x404+X 4 be32 Y — payload length
|
|
110
|
+
0x408+X Y AES-128-CBC ciphertext (PBKDF2-SHA256 key, PKCS#7 padding)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The signature covers the **full 0x400-byte header block plus the decrypted
|
|
114
|
+
payload**; it chains device cert → *Stormshield Network Security Products
|
|
115
|
+
CA* → *Stormshield Products Root CA* (embedded). Expired device
|
|
116
|
+
certificates still verify — the appliance ignores dates, so backups stay
|
|
117
|
+
readable forever. Full details in [RECON.md](RECON.md).
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
decbackup/ the package (cli, backup format, crypto, pkcs7, der, trust, certs/)
|
|
123
|
+
analysis/ RE tooling: disassembler, strings, symbol lists, the device
|
|
124
|
+
extraction script and the empirical error-code matrix
|
|
125
|
+
tests/vectors/ real encbackup-produced backups + expected payloads
|
|
126
|
+
(created on an SNS 5.1.4 device, cross-validated against
|
|
127
|
+
the stock decbackup)
|
|
128
|
+
legacy/ the earlier single-file iteration (kept for reference)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python tests/test_decbackup.py # exit code = number of failures
|
|
133
|
+
python analysis/probes.py # real-vs-clone error-code parity table
|
|
134
|
+
python analysis/fuzz.py 30000 # robustness contract fuzzer
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Releasing
|
|
138
|
+
|
|
139
|
+
Tagged pushes (`v*`) build an sdist + wheel, smoke-test the wheel against
|
|
140
|
+
the bundled device vectors, and publish to PyPI via trusted publishing
|
|
141
|
+
(see `.github/workflows/release.yml`). Pushes and PRs run lint + the
|
|
142
|
+
error-code parity suite on Python 3.9–3.13
|
|
143
|
+
(`.github/workflows/ci.yml`).
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
git tag v0.1.0 && git push origin v0.1.0 # → PyPI
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
Apache License 2.0 — see [LICENSE](LICENSE). The patent grant and
|
|
152
|
+
patent-retaliation clauses of Apache-2.0 apply.
|
|
153
|
+
|
|
154
|
+
*Stormshield* is a trademark of Stormshield. This project is unaffiliated
|
|
155
|
+
with Stormshield; it exists so that backups you own remain readable.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""decbackup — Python clone of the Stormshield SNS backup decryption utility.
|
|
2
|
+
|
|
3
|
+
Reimplementation of ``/usr/Firewall/sbin/decbackup`` and the backup
|
|
4
|
+
container handling of ``libncrypto.so`` from Stormshield SNS v5.1.4,
|
|
5
|
+
derived by reverse engineering (see ``RECON.md``).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
from .backup import BackupError, decrypt_backup # noqa: F401
|