Mstar-bin-tool Info
cpio -idmv < rootfs.cpio
# modify
find . | cpio -o -H newc > new_rootfs.cpio
mstar-bin-tool is a command-line utility designed for unpacking, repacking, and manipulating firmware binaries for devices running on MStar (now part of MediaTek) chipsets. These chipsets were historically ubiquitous in digital TVs, set-top boxes, and embedded IoT devices. This tool is essential for embedded developers, security researchers, and enthusiasts looking to modify device behavior, port operating systems, or analyze stock firmware without proprietary vendor SDKs.
In the world of embedded systems, few things are as frustrating as encountering a proprietary file format. For developers, hobbyists, and security researchers working with MStar (now part of MediaTek) based devices—such as smart TVs, IP cameras, set-top boxes, and car infotainment systems—the .bin file extension often represents a significant roadblock.
Enter mstar-bin-tool . This open-source Python script has become the unofficial Swiss Army knife for reversing, unpacking, and repacking MStar/Cherry firmware images.
In this guide, we will dissect everything you need to know about mstar-bin-tool: what it is, how it works, why it exists, and a step-by-step tutorial on using it for firmware analysis.
# Unpack
python mstar_bin_tool.py -f input.bin -c device.ini -u
The config file is critical. Example:
[General]
format=mstar
[Header]
size=1024
magic=MSTAR
encrypted=0
[Partitions]
count=5
[Partition0]
name=bootloader
offset=0x1000
size=0x80000
type=raw
[Partition1]
name=kernel
offset=0x81000
size=0x400000
type=zimage mstar-bin-tool
[Partition2]
name=rootfs
offset=0x481000
size=0x2000000
type=squashfs
[Partition3]
name=logo
offset=0x2481000
size=0x100000
type=raw
[Partition4]
name=params
offset=0x2581000
size=0x10000
type=env
You must obtain or create the correct config for your device. Often found in the tool's configs/ folder or in device forums.
After unpack, you'll find rootfs.squashfs inside the unpacked folder.
Mount and modify (Linux only):
sudo mount -t squashfs rootfs.squashfs /mnt/rootfs -o loop
# make changes inside /mnt/rootfs
sudo unsquashfs -d rootfs_extracted rootfs.squashfs
# modify files in rootfs_extracted/
sudo mksquashfs rootfs_extracted/ new_rootfs.squashfs -comp xz
Replace the old .squashfs file with new_rootfs.squashfs before repacking. cpio -idmv < rootfs
bottom of page