Python-KZB is a Python utility that extracts and rebuilds KZB/KZBF archives found inside embedded firmware blobs (QNX images, bitmaps.bin, cluster assets, etc.). It handles the full pipeline: parse headers, walk the file table, decompress payloads, fix alignment/padding, and reassemble a byte-perfect archive on the way back. It’s built to be loud about errors and to produce valid outputs that actually boot/display, not just “some bytes on disk”.
- Unpack: Validates magic, sizes, and alignment; extracts entries with correct filenames, offsets, and lengths. Supports zlib/deflate; unknown codecs are dumped raw for later.
- Repack: Builds
.kzb/.kzbffrom a folder + manifest with recomputed offsets, sizes, checksums, and padding that mirrors the original layout. - Integrity checks: Optional CRC/hash verification (when present). Strict bounds checks on every read to kill “unpack requires a buffer of 4 bytes” bugs before they happen.
- Metadata preservation: Keeps original order, alignment, and naming to stay diff-friendly and drop-in compatible.
- Error-tolerant extraction: Salvages good entries and pinpoints the exact broken offset instead of face-planting the whole run.
- PNG sanity: Auto-repairs common PNG/zlib edge cases (IHDR lengths, CRCs) and clearly flags genuinely corrupted images.
- 4-byte discipline: Every 32-bit field is read with preflight
len(buf) >= 4checks and explicit offset reporting.
The program can repack a kzb folder back into .kzb format, I am still currently testing the output to validate if it is creating a good file.