[TOOL] UnSIN ~ SIN v3/v4/v5 Unpacker [v1.13]

IgorEisberg

Senior Member
Jul 6, 2009
1,729
3,752
153
www.audiobudget.com
This tool was especially made for the new SIN v3 format used in Xperia Z3+/Z4 and Xperia Z4 Tablet (and more recent Xperia devices as well), as well as SIN v4 format introduced with Xperia XZ Premium and SIN v5 format introduced with Xperia XZ2 and Xperia XZ2 Compact.
This tool can unpack every SIN v3/v4/v5 file to it's contained binary or EXT4 image file, the later can then be extracted with 7zip to its inner files.

Special credits to @Androxyde (of Flashtool) for original Java SIN code, @tal.aloni for Sparse decompression method and Dino Chiesa for TAR extraction method.

SUPPORTED SIN FORMATS:
SIN v3
= Custom format (utilizing LZ4 compression)
SIN v4 = gzip + tar + Android sparse format
SIN v5 = tar + Custom sparse format (utilizing LZ4 compression)

REQUIREMENTS:
Windows: 64-bit support only. No other requirements.
Linux: 64-bit support only. No other requirements

USAGE:
Just drag and drop a SIN file onto this EXE file, or write in Command Prompt "unsin system.sin" (or any other SIN image).
Make sure you have at least 6GB of free space on your hard drive, as the output EXT4 images are huge.

Note: super_*.img (extracted from super_*.sin) has to be further unpacked into system_a/b.img, product_a/b.img and vendor_a/b.img:
* Windows: Using 7zip, right-click the super_*.img, then use "Open Inside #" see all of the contained partitions (they will be labeled with the *.ext extension).
* Linux: Using "lpunpack super_*.img" (Google for a pre-compiled lpunpack binary)

COMMAND-LINE OPTIONS:
unsin
--- Intro, version and usage instructions.
unsin <file path 1> [<file path 2> ... <file path n>] --- Unpack specified *.sin file(s)
unsin -d --- Unpack all *.sin files in the current directory (non-recursive)
unsin -d <dir path 1> [<dir path 2> ... <dir path n>] --- Unpack all *.sin files in the specified directories (non-recursive)
unsin -dr --- Unpack all *.sin files in the current directory (recursive)
unsin -dr <dir path 1> [<dir path 2> ... <dir path n>] --- Unpack all *.sin files in the specified directories (recursive)

NOTES:
* The order of the options has no significance.
(i.e. -dr is the same as -rd)
* The options are case-insensitive. (i.e. -d is the same as -D)

CHANGELOG:
v1.13 [May 20, 2020]
:
- Added support for super.sin images. (Note: those have to be further unpacked using lpunpack into system_a/b.img, product_a/b.img and vendor_a/b.img)
- Added exit status on success (code 0) and failure (code 1) for usage with automation scripts.
- Built using the latest .NET Core SDK 3.1.300.
v1.12 [October 1, 2019]:
- Added intro, version and usage instructions to binary (when executing without any arguments)
- .NET Core Windows x64 binary rebuilt with .NET Core 3.0 and file size reduced to ~1.8MB.
- .NET Core Linux x64 binary rebuilt with .NET Core 3.0 and file size reduced to ~2.1MB.
- The .NET Framework variant is discontinued, final version is v1.11.
v1.11 [August 12, 2019]:
- Added .NET Core native self-contained binaries: UnSIN 1.11 (Win x64).zip and UnSIN 1.11 (Linux x64).zip
v1.11 [May 31, 2019]
:
- Fixed unsparsing of SINs containing non-EXT4 images that were split into multiple sparse parts. (mainly affecting recent modem.sin images)
v1.10 [June 12, 2018]:
- Fixed wrong implementation of FILL sparse chunk type that resulted in corrupted images in rare occasions.
v1.9 [April 9, 2018]:
- Workaround for certain SIN files that contain 2 unexpected 0x00 bytes, specifically on F5121 Oreo firmware's oem.sin files. Purpose of these bytes is unknown, probably reserved for future use, but can be safely skipped.
- Added command-line options by a user's request.
v1.8 [March 23, 2018]:
- Fixed a silly mistake that resulted in corrupted EXT4 images.
- Significantly optimized memory usage.
v1.7 [March 23, 2018]:
- Added support for SIN v5 (tar + Custom sparse format) files that were introduced in Xperia XZ2 and Xperia XZ2 Compact firmware.
v1.6 [June 29, 2017]:
- Removed some unnecessary stages, making the extraction a lot faster.
- Improved checking of available disk space, to accommodate for the removal of pre-assigned container file.
v1.5 [June 10, 2017]:
- Fixed extraction for SIN v4. Images can now be mounted properly.
v1.4 [June 6, 2017]:
- The extracted images are now identical to those extracted by Flashtool, and can be mounted properly.
- Fixed support for old SIN v3 formats that used a different partition information (i.e. Xperia C).
v1.3 [May 11, 2017]:
- Fixed SIN v4 support for non-sparse binaries.
v1.2 [May 10, 2017]:
- Added support for SIN v4 (gzip + tar + Android sparse format) files that were introduced in Xperia XZ Premium firmware. (NOTE: At least .NET Framework 4.0 is now required!)
v1.1 [December 1, 2016]:
- Algorithms were fixed to support large Nougat-based SIN files.
v1.0 [June 5, 2015]:
- Initial release.
 

Attachments

Last edited:

SirRobin78

Senior Member
Nov 15, 2010
545
59
58
Please can someone explain me how i can extract the media files from the xperia tablet z4 firmeware within the memorystick_red.sin file? i´ve tried several things, got an ext4 file but all tools get an error message or told me the file is not valid...

Thank you!
 

AndroPlus

Senior Member
Mar 13, 2013
1,707
3,984
153
Kyoto
androplus.org
v1.2 [May 10, 2017]:
- Added support for SIN v4 (gzip+tar+Android sparse format) files that were introduced in Xperia XZ Premium firmware. (NOTE: At least .NET Framework 4.0 is now required!)
Thank you for quick update!
v1.2 is working great for system.sin, but it fails to decompress image chunks if I try to unpack elabel or kernel.
It says other process is using 'LTALabel.000' and the process can't access.
 

IgorEisberg

Senior Member
Jul 6, 2009
1,729
3,752
153
www.audiobudget.com
Thank you for quick update!
v1.2 is working great for system.sin, but it fails to decompress image chunks if I try to unpack elabel or kernel.
It says other process is using 'LTALabel.000' and the process can't access.
v1.3 [May 11, 2017]:
- Fixed SIN v4 support for non-sparse binaries.

Note that the kernel and fotakernel have a new format. (the signature is ANDROID rather than ELF).
.