[TOOL] UnSIN ~ SIN v3/v4/v5 Unpacker [v2.0]

Search This thread

IgorEisberg

Senior Member
Jul 6, 2009
1,835
3,967
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 its 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 SharpZipLib for GZIP and TAR extraction methods.

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:
unsin [-o DIR] <sin_files>
Where -o DIR lets you specify an output directory (default: next to each SIN file).
Or, if on Windows, just drag and drop a SIN file onto the EXE file.
Make sure you have a lot of free space on your hard drive, as some raw images can be huge.

Note: super.img (extracted from super.sin) has to be further unpacked into individual partition images:
* 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 or compile yourself from AOSP source)

CHANGELOG:
v2.0 [January 19, 2024]
:
- Replaced .NET's GZipStream and old TAR extraction code with SharpZipLib equivalents which reduced binary size.
- Code refactored, redundant options removed.
- Added "-o" option to specify an output directory.
- Sparse chunks are no longer extracted to a temporary directory. Instead, they are read to memory, parsed and written to the output file sequentially.
- Built using the latest .NET SDK 8.0.101.
v1.13 [May 20, 2020]:
- Added support for super.sin images. (Note: those have to be further unpacked using lpunpack into individual partition images)
- 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

  • UnSIN 2.0 (Linux x64).zip
    761.6 KB · Views: 289
  • UnSIN 2.0 (Win x64).zip
    645.2 KB · Views: 1,776
Last edited:

SirRobin78

Senior Member
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!
 

IgorEisberg

Senior Member
Jul 6, 2009
1,835
3,967
www.audiobudget.com
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!)
 
  • Like
Reactions: AndroPlus

VeixES

Senior Member
Mar 5, 2012
428
193
Tallinn
Great work. Extracting the system image now works.
Digging in modem files to see CA combinations supported...
 

AndroPlus

Senior Member
Mar 13, 2013
1,898
4,156
Kyoto
androplus.org
Lenovo P11
Xiaomi Mix Fold 2
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,835
3,967
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).
.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 106
    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 its 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 SharpZipLib for GZIP and TAR extraction methods.

    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:
    unsin [-o DIR] <sin_files>
    Where -o DIR lets you specify an output directory (default: next to each SIN file).
    Or, if on Windows, just drag and drop a SIN file onto the EXE file.
    Make sure you have a lot of free space on your hard drive, as some raw images can be huge.

    Note: super.img (extracted from super.sin) has to be further unpacked into individual partition images:
    * 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 or compile yourself from AOSP source)

    CHANGELOG:
    v2.0 [January 19, 2024]
    :
    - Replaced .NET's GZipStream and old TAR extraction code with SharpZipLib equivalents which reduced binary size.
    - Code refactored, redundant options removed.
    - Added "-o" option to specify an output directory.
    - Sparse chunks are no longer extracted to a temporary directory. Instead, they are read to memory, parsed and written to the output file sequentially.
    - Built using the latest .NET SDK 8.0.101.
    v1.13 [May 20, 2020]:
    - Added support for super.sin images. (Note: those have to be further unpacked using lpunpack into individual partition images)
    - 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.
    7
    All apps from XZ2 working on XZ Premium Soundenhancement, fingerprint service, cametracommon, and some new apps like XperiaX loops, overlay file etc.
    Only camera and settings not working on xz premium Needed port I try but not effect yet. I thing it is possible. Setting Has a new icon.

    I made a silly mistake in v1.7, so some of the apps will probably be corrupted. You should get v1.8 and unpack the SIN again.
    The mistake was resolved. Should have checked MD5 before releasing v1.7. Silly me.

    v1.8 [March 23, 2018]:
    - Fixed a silly mistake that resulted in corrupted EXT4 images.
    - Significantly optimized memory usage.

    NOTE: Don't use v1.7, even if your EXT4 can be opened - they are corrupted and some data will be invalid! Update to v1.8.
    7
    Fixed for Nougat.
    It should also work much smoother and use far far less RAM and CPU while it's working.
    Take note: it takes time, just be patient, and use it on an SSD if you have one to speed things up.
    6
    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. Details are in the OP.
    5
    @IgorEisberg Unable to Unsin XZ2 and XZ2 compact .sin files. It seems that the .sin files are not gzipped anymore. Zipping them manually and then trying unsin.exe results in broken .ext4 file. Needs more skills and knowhow than i can provide. thank you

    Sadly, that's not the main issue. The optional gzip decompression was an easy fix. However, now...
    Code:
    Extracting sparse files from SIN... Done!
    Restoring image from sparse files... Failed!
    ERROR: Unknown chunk type: 0xCAC5
    Sony used some new Android Sparse format.
    The known Sparse chunk types are: 0xCAC1 (Raw), 0xCAC2 (Fill), 0xCAC3 (Don't Care) and 0xCAC4 (CRC).
    Sony used a new type: 0xCAC5
    This calls for further investigation about the meaning of this chunk type.