Mstar-bin-tool-master/ ├── mstar_unpack.py # Main unpacking entry point ├── mstar_pack.py # Repacking utility ├── mstar_defs.h / .py # Header definitions (magic, offsets) ├── crypto/ │ ├── mstar_crypto.py # XOR, AES-CBC (if key known) │ └── mstar_crc.py # Checksum verification ├── compress/ │ ├── mstar_lzma.py # Custom LZMA properties │ └── mstar_none.py # Uncompressed passthrough └── partitions/ ├── boot.py # U-Boot image handling ├── system.py # SquashFS detection └── env.py # Environment variables (mmcblk) The Tool detects multiple header signatures:

The structure follows standard security/forensic tool documentation. Document Version: 1.0 Classification: Reverse Engineering / Firmware Analysis Utility Target Platform: MStar (MediaTek) SoC firmware images ( .bin , .img , .pkg ) Abstract The Mstar-bin-tool-master is an open-source utility designed for the extraction, modification, and repacking of firmware binaries derived from MStar/MediaTek system-on-chip (SoC) devices. These binaries typically employ proprietary header structures, custom LZMA compression variants, and segmented layouts (e.g., boot , system , misc ). This paper dissects the tool’s architecture, supported firmware formats, cryptographic and compression handling, and provides a step-by-step methodology for using the tool in firmware reverse engineering, vulnerability research, and custom firmware creation. 1. Introduction MStar Semiconductor (acquired by MediaTek) dominates the smart TV and set-top box (STB) market. Firmware updates for these devices are distributed as monolithic binary blobs (e.g., update.bin , MstarUpgrade.bin ). Without proper tooling, these blobs are opaque, hindering security audits, root access, or brick recovery.

# Rebuild SquashFS (same block size as original) mksquashfs new-rootfs/ system_new.bin -comp xz -b 131072 -noappend python mstar_pack.py -i ./unpacked_dir/ -o modified.bin --header MSTU --version V02.33 --pad 0xFF