[TOOL][Windows,Linux,Android,Apple] Unpack any Sony firmware file - Sony Cross-Device General

Disclaimer:
Our tool was made for testing and educational purposes, ME is not responsible for what you have doing using our tool, you must agree that you using our tool on your own risk, I am not responsible for anything or anything else you doing/do with using our tool!
Hello! I have made universal tool which is able to extract any format of the Sony image. Also tool is able to dump and extract directly from block device. After 20.Jan.2017 we are able now to convert sin file on the fly and flash it directly to block device. Supported formats which tool is able to deal with:
1. sin v1
2. sin v2
3. sin v3
4. sin v4
5. sin v5
6. img
7. elf
How to use:
since this is a command line tool, you must run it trought an batch file or trought your command line, e.g:
sony_dump DESTINATIONFOLDER PATHTOTHEFILE
sony_dump out kernel.elf
sony_dump out boot.img
sony_dump out kernel.sin
sony_dump out /dev/block/platform/msm_sdcc.1/by-name/boot (android version only)
sony_dump out /dev/block/platform/msm_sdcc.1/by-name/FOTAKernel (android version only)
sony_dump out anysinfile.sin
for flashing sin file to block device e.g: sony_dump /dev/block/platform/msm_sdcc.1/by-name/system system.sin
Enjoy!
Changelog:
- 01.Jan.2017 -> implemented sin to elf converter, now kernel.sin can be extracted
- 01.Jan.2017 -> now any sin file can be converted to converted.file
- 02.Jan.2017 -> now sin version 3 with lz4 compressed data is supported
- 02.Jan.2017 -> improved non compresed sin files extraction
- 02.Jan.2017 -> some cleanups ; now arm version, arm version with pie and linux version
- 04.Jan.2017 -> fix large sin files extraction, curently I have removed arm and windows version of the program since I have no idea how to get LFS working on non 64bit platform, so last one is for Linux 64-bit platform only until I find a way to write files bigger than 2gb If you have working example tell me please!
- 05.Jan.2017 -> LFS fixed, now tool generates valid system.ext4 from uncompressed sin, suuport again for linux, for arm, for windows, tested only on linux and windows by now, tool support by now large files (LFS) and propertly generates output. If you find bugs please report. Tommorow hope fix for compressed big sin files
- 07.Jan.2017 -> finished. Now all types of the sin files can be extracted. Sin files decompression fail on 32 bit machines/devices if output file reach 0xffffffff bytes so everything after output of the 0xffffffff bytes is not a valid, I have no idea which toolchain have full 64 bit support on 32 bit platform so I am unable to make LFS (large files support) on 32 bit platfom. File output which is smaller than 0xffffffff bytes is valid on 32 bit platform. But on any 64 bit platform tool working flawless and you can extract any sin file so no problem with LFS and etc! I have tested on win10 64 bit and ubuntu 64 bit and can confirm that any sin files is extracted correctly. Tried on android 32 bit but file output which is smaller than 0xffffffff bytes is a valid but till after file reach size of the 0xffffffff bytes is no more valid! Have no idea why. Not tried on 64 bit android but I am pretty sure it will work the same like on 64 bit windows and 64 bit linux.
- 07.Jan.2017 -> while compared extracted sin with one of the flashtool I have noticed one or two blocks missing in my output file , it was since whileloop was wrong in one case, done some right small changes and now all case is ok, file is identic to one from flashtool
- 08.Jan.2017 -> Finally tool is abble to work on booth 32 bit and 64 bit linux, android and windows machine by fully supporting LFS
- 12.Jan.2017 -> sony_dump, detect file extensions in sin
- 12.Jan.2017 -> small tool for convert file_contexts.bin (binary) to file_contexts (textual)
- 15.Jan.2017 -> removed part of the old mechanism related to sin version and file size detection, in some case cache.sin was failed to extract since file size calculation was wrong, now definitelly any sin file can be extracted
- 20.Jan.2017 -> redesigned a way for extracting boot.sin files, now it extract elf instead of unpacking it fully, so if you need to unpack fully just rerun tool with elf file. Also now we can convert on the fly and flash any sin file directly to block device
- 01.May.2017 -> support for sin version 1 & 2, some improvements for ver 3
- 18.May.2017 -> compiled for mipsel 32bit & 64bit (litle endian), mips 32bit and mips 64bit (big endian), linux 32bit & 64bit, arm 32bit and arm 64bit, windows, all is static without dependencies
- 07.Jun.2017 -> support for sin version 4
- 24.12.2017 -> apple x86 and apple i386 support
- 12.06.2018 -> sin version 5 support
- 13.06.2018 -> self implemented custom sparse format (no more need libsparse) because had problem with out of memory extracting large sin files
- 17.06.2018 -> fully implemented sin v5, removed mips and mips64 big endian builds (because my tool not support that)
- 17.10.2019 -> some sin files produce wrong ext4 file, fixed now. Removed osx support right now, if you need it download source code from git and compile by self, I have no free time to mess with it
- 18.10.2019 -> another bug discovered, ext4 padding on some sin files was missing, fixed now
- 20.10.2019 -> some updates, osx binaries now included
- 03.11.2019 -> propertly unpack ext4 images, this include extra bytes at the end of ext4, it is realy need if you going to fully emulate sony gpt disk inside virtual machine ; inflate progress bar
Small tool for converting binary->plaintext plaintext->binary file_contexts:
- https://forum.xda-developers.com/showpost.php?p=70881172&postcount=1985
Credits:
- I must give credit to @Androxyde since I have looked into his java source code for understanding lz4a commpresed sin's, thanks for open source, I realy appreciate your hard work on flashtool!
Source code:
- https://github.com/munjeni/anyxperia_dumper

I don't have a Sony smartphone and probably won't use your tool but really thank you for that tool ?
Sent from my Redmi Note 3 using Tapatalk

Update: Now sin can be extracted!

Ahmad Tawfik said:
I don't have a Sony smartphone and probably won't use your tool but really thank you for that tool ?
Sent from my Redmi Note 3 using Tapatalk
Click to expand...
Click to collapse
You can extract boot.img with it!

munjeni said:
You can extract boot.img with it!
Click to expand...
Click to collapse
bro first thanks for your great tool.
you mean with this tool we can unpack kernel yes? ( with those command )
then how can repack it ( after do our change ) ?
sorry if this question is nooby

This is for unpacking only. You can read xda contain ton of tutorials related to how to pack boot image, just search please

Update:
now tool is able to extract any sin file and output it to converted.file

Sorry sin version 3 is not supported, I am working on it, only sin version 1 & 2 by now!

Now sin version 3 with lz4 compressed data is supported! Report bugs please if you get!

New version, improved non compressed sin files extraction, now for example 1.5 gb system.sin files can be extracted in just some secconds, amazing

Now versions for:
- Linux
- arm
- arm with pie
- Windows

. .

@munjeni thanks for this tool, great work. but
i'm trying your linux version and this tool not extract pagesize info and made broken boot.img, ie if i'm try extract kernel.sin your tool create boot.img (but it's a same sin file) and if i'm try extract .elf, tool create boot.img (but same elf)

You can't use folder out and boot.img from the same directory! Boot.img from ouy directory is nothing than temp file. In next version all temp files will ne deleted on app finish to prevent mess. Also next version will be working one for sin files, cutently I forgot to include spare data generation which cause non valid extracted big sin files e.g. system.sin, problem also is my compiler and can't fwrite bigger files that 2gb, tommorow I think I will finish all and finaly produce a valid tool.

munjeni said:
This is for unpacking only. You can read xda contain ton of tutorials related to how to pack boot image, just search please
Click to expand...
Click to collapse
To be fair many of them don't work, I've even installed Linux on an old laptop to try and learn how to repack but always get stuck with "android boot magic not found" and googling hasn't helped at all. An updated guide really wouldn't go a miss.

Sin of big size - extraction is now working under linux 64-bit, need some small changes to do to get it working correctly! I am sorry I have removed 32-bit version since I have no idea how to make LFS working under 32-bit platform but have tried almost everything, no way. Please let me know if you have a tested and working example of the LFS for 32-bit windows! And tell me please which compiler you used!

Finaly fixed everything, now tool generates valid system.ext4, suport again for linux, for arm, for windows, tested only on linux and windows by now, tool support by now large files (LFS) and propertly generates output. If you find bugs please report. Please try on android since I have not tested. :good:
Edit:
Uh, downloaded z5 premium rom, extracted system.sin and tool failed on v3 sin, seems I forgot something in curently huge source code, will check tommorow sorry On z1 uncompressed images working flawles, since I have now z5 rom on my disk I will fix bug sorry

Newer sin e.g. system.sin contains mixed data, compresed and uncompresed, holy s I must rewrite half of the my code to get thing propertly parsed... Damn

Does android support off64_t on 32 bit toolchain anybody know?

finished. Now all types of the sin files can be extracted. Sin files decompression fail on 32 bit machines/devices if output file reach 0xffffffff bytes (4 gb) so everything after output of the 0xffffffff bytes (4 gb) is not a valid, I have no idea which toolchain have full 64 bit support on 32 bit platform so I am unable to make LFS (large files support) on 32 bit platfom. File output which is smaller than 0xffffffff bytes (4 gb) is valid on 32 bit platform. But on any 64 bit platform tool working flawless and you can extract any sin file so no problem with LFS and etc! I have tested on win10 64 bit and ubuntu 64 bit and can confirm that any sin files is extracted correctly. Tried on android 32 bit but file output which is smaller than 0xffffffff bytes (4gb) is a valid but till after file reach size of the 0xffffffff bytes (4gb) is no more valid. 32 bit platform is limited and we can do nothing on that. Not tried on 64 bit android but I am pretty sure it will work ok the same like on 64 bit windows and 64 bit linux.
This tool is primary designed for extracting any sony boot image format from, you can extract any boot image using this tool on 32 bit platform or on 64 bit platform without any problem, without cares to LFS! But for seccondary thing you can use to extract any sin file, on 64 bit platform it will success for sure but on 32 bit platform it is limited because LFS in my case is not working corectly on 32 bit platform if output of the file is bigger than 4 GB

Related

[GUIDE] How to extract system files from stock firmware

First of all: Tool to be used in this guide was developed by user And_pda from Russian 4pda.ru forum. So all credits must go to And_pda
The original thread (in Russian) is here. Actually the original thread is about several tools to works with different images for different phones. But we will talk only about Moto X.
The guide will describe how to extract all files from system partition from stock firmware. The tools works under Windows (I personally tested it on Win 7).
If you unzip any stock firmware you will find one file, which represents system partition: system.img.
To extract all files from system.img please do:
1. Download ImgExtractor_1_3_4.rar and extract it.
2. Create directory System in the folder where system.img is located;
3. Copy ImgExtractor.exe into the folder where system.img is located;
4. Run CMD and "cd" to the folder where system.img is located
5. In CMD run the following: ImgExtractor system.img System
After ImgExtractor finished you will have all system files and folders in System directory.
That's all
PS. ImgExtractor also can extract modem firmware (NON-HLOS.bin)
Anyway to extract system image on 4.4, inject su binary re-image, and msfastboot flash?
Sent from my XT1080 using Tapatalk
djnikko said:
Anyway to extract system image on 4.4, inject su binary re-image, and msfastboot flash?
Sent from my XT1080 using Tapatalk
Click to expand...
Click to collapse
Maybe. But to get the locked recovery to flash it must be signed by moto thousand bit code.
extract for something like my signature?
Hey this will mos def save some time. Thanks my dude
Sent from my XT1095
Can you get this to work with motoboot.img? It'll make it possible to downgrade to bootloaders such as 4-21, 3-15, etc.
mr_verystock said:
Can you get this to work with motoboot.img? It'll make it possible to downgrade to bootloaders such as 4-21, 3-15, etc.
Click to expand...
Click to collapse
Phone's cid partition changes with every firmware update so bootloader downgrade will not work. The phone just won't boot up. I know the man who tried all this tricks - he flashed dumps from phones with unlocked bootloaders.
Pretty cool tool... I just wished it would keep the original timestamps for the directories and files....
Is there any way to assemble extracted files and build original system files?
Sent from my SM-N910C using Tapatalk
Latest version if any need it
It can't handle large img files though.
works on Samsung Galaxy S6 , Note 4 , cache.img , hidden.img , files which ext4 unpacker couldn't handle.
How big were the img files? It can't handle the 4GB LG G4 .img files but works fine with the smaller Motorola RAZR HD Maxx .img files.
i used it only for cache and hidden, so <250MB. I didn't tried on larger files.
That's why it works.... the Motorola img files were 1 GB or less... it can't handle the LG G4 files.
it would be great if the author patched/forked the original ext4 unpacker, so it can open newer img's like this (sparse with moded header) , so we would've had a GUI, because imgextractor is only text.
imgextractor is the only one that works on Motorola img files.
yes, even with Samsung Galaxy Note 4 / S6 and newer devices, on the IMG file - the ext4 sparse header is not standard, but i said, since this program (imgextractor) is based on ext4 unpacker sources, it could've keeped that GUI and only mod a little.
Anyway, you could also open IMG with the original ext4 unpacker if you fix it first with IMGEXTRACTOR. to fix: convert IMG file from MODED SPARSE EXT4 to normal EXT4 (> imgextractor.exe original.img temp.ext4 -conv) and then back to FIXED SPARSE EXT4 (> imgextractor.exe temp.ext4 fixed.img -conv). Now open fixed.img in ext4 unpacker program and it will work.
l.e. I found what the problem was, on Samsung Exynos devices, and the newer ones, the IMG files headers are 32 bytes, instead of the normal 28, Chainfire explains it here. So that's why ext4 unpacker gives error on opening. For alternative fix (instead of the conversion i explain upper in this post using imgextractor) you can use Chainfire's sgs4ext4fs tool , works on Windows/Linux, builds and other useful tool here.
Also there is a tool for Motorola IMG files there, see the Usage section.
gracias
tanks bro work in motorola razr hd stock kitkat system.img
BenjaminW8 said:
can you maybe make a more detailed guide how you did this
i cant seem to make sytem.img to extract for the s7 Edge
Click to expand...
Click to collapse
I believe you want be able to utilize Imgextractor as the S7 system.img exceeds the supported size of the Imgextractor

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

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 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 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)
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 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.
Its very good
Thanks
Thanks Bro. great idea and amazing job
Sent from my Sony Xperia Z3 ™ Single D6643 - Sen liked my work or my help click thanks!
Toni Junior
Awesome work mate
Cool ??
Sent from my D5833 using XDA Free mobile app
Thanks Bro. great idea and amazing job
Great Job
Good work!
Also it unpacks old .sin files without problems
Rootk1t said:
Good work!
Also it unpacks old .sin files without problems
Click to expand...
Click to collapse
Yep, as long as they are v3.
IaguCool said:
Yep, as long as they are v3.
Click to expand...
Click to collapse
How can i determine version of .sin?
Rootk1t said:
How can i determine version of .sin?
Click to expand...
Click to collapse
Open the SIN file with a Hex Editor. The first byte should be 0x03. The next 3 bytes say "SIN" in ASCII.
Thank you @IaguCool and @Androxyde. You guys are indispensable.
najoor said:
Thank you @IaguCool and @Androxyde. You guys are indispensable.
Click to expand...
Click to collapse
Kind words, thank you.
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!
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.
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!)
Great work. Extracting the system image now works.
Digging in modem files to see CA combinations supported...
IgorEisberg said:
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!)
Click to expand...
Click to collapse
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.
AndroPlus said:
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.
Click to expand...
Click to collapse
Hmm interesting, I'll see what I can do.
AndroPlus said:
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.
Click to expand...
Click to collapse
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).
.

[HOW-TO / VIDEO / WIN-LIN-OSX] Extract System/Data files directly from a FTF

Good morning family!
It's my very first time posting in this subforum, but I think this tutorial was actually something needed, since all threads everyone can found while Googling are quite old (like, from the Xperia S times ), and also I'm quite tired of infinite threads like this and this, so...
Today I bring you an extensive and unified guide on how to extract ANY SYSTEM FILE from a FlashTool's Firmware (FTF), whether it's from the userdata.sin or from the system.sin.
Since this is going to be a guide for all OSes, there are some programs you'll need in general,
Latest version available of FlashTools (for SIN dumping purposes).
A reader tool for the extracted image, which can be:
An EXT4 reader / mounter.
An Unyaffs2, if you're using this guide for an old device (like the already mentioned Xperia S, and older).
Some cups of coffee, and lots of patience [IMPORTANT].
But, some of them will be platform specific, so the thread will split in:
2nd post: WINDOWS
3rd post: LINUX
4th post: OSX
Here you've a video tutorial showing the whole process for the 3 OSes:
If you're enjoying it, don't forget to press Thanks button and rate this thread!​
WINDOWS GUIDE
Step 1 - Extract the SIN we need
Using your favourite archive manager (WinRAR, 7-Zip, etc), open the FTF you want to extract the files from. (FYI: an FTF is just a Zip file with renamed extension)
Now copy/extract the SIN you want to unpack to a folder of your preference.
Step 2 - Dump the SIN
I'll take into account you already had installed Flashtools and Java JRE, in which case I highly encourage you to update both to the latest version available.
Now, open Flashtools. Click on Tools, Sin Editor. Hit the [...] and locate the SIN you previously extracted. Now, hit the [Extract Data] button. After a couple of minutes the bar should start running.
Once finished, you can have 2 kind of files: a .yaffs2 or a .ext4/.ext3/.ext2 file, which require different procedures on how to see it's contents.
Step 3.a - Convert the file to a readable format - UnYaffs2
If the file you get is a .yaffs2 format file, you're going to need to extract it. For doing so, you need this tool, which contains a executable and a cygwin dll.
Extract this .rar contents to the very same folder where you placed the SIN, and thus, where the .yaffs2 is located.
Now, while you're in that folder press the shift key in your keyboard, and while you keep pressing it, right click on a blank space in that folder. In the menu choose Open a Command Prompt here.
To end the proccess, type
Code:
unyaffs2.exe [COLOR="DarkOrchid"]<the-name-of-the-yaffs2>[/COLOR]
Where <the-name-of-the-yaffs2> you must type the file name of the yaffs2 (e.g. system.yaffs2)
The files will get extracted and you'll be able to pick the ones you need.
Step 3.b - Mount the image - Linux Reader
There're many many tools to mount a EXT format image in Windows, but in this case, I'll use the Diskinternals Linux Reader, since it's free and it's compatible with all 3 possible formats you can encounter: .ext4/.ext3/.ext2.
Download it from here and install it. (It must be this version, since newer ones are broken.)
Once done, you should be perfectly able to double-click-to-mount the EXT file Flashtools generated without any trouble.
LINUX GUIDE
Step 1 - Extract the SIN we need
Using your favourite archive manager (Ark, Peazip, etc), open the FTF you want to extract the files from. (FYI: an FTF is just a Zip file with renamed extension)
Now copy/extract the SIN you want to unpack to a folder of your preference.
Step 2 - Dump the SIN
I'll take into account you already had installed Flashtools and Java JRE, in which case I highly encourage you to update both to the latest version available.
Now, open Flashtools. Click on Tools, Sin Editor. Hit the [...] and locate the SIN you previously extracted. Now, hit the [Extract Data] button. After a couple of minutes the bar should start running.
Once finished, you can have 2 kind of files: a .yaffs2 or a .ext4/.ext3/.ext2 file, which require different procedures on how to see it's contents.
Step 3.a - Convert the file to a readable format - UnYaffs2
If the file you get is a .yaffs2 format file, you're going to need an extra tool to extract it. For doing so, you are going to need the unyaffs2 tool.
You can download a pre-compiled binary from here, or you can compile your own using GCC with the source code, the header and the code below inside a Terminal (Ctrl+Alt+T to open it).
Code:
gcc -o unyaffs unyaffs.c
Once you've a working UnYaffs2 binary, just copy it to the very same folder where you placed the SIN, and thus, where the .yaffs2 is located, and type in a Terminal (Ctrl+Alt+T to open it).
Code:
cd [COLOR="DarkOrchid"]<file-route-of-the-sin>[/COLOR]
./unyaffs2 [COLOR="Blue"]<the-name-of-the-yaffs2>[/COLOR]
Where <file-route-of-the-sin> is where the SIN was located, and where <the-name-of-the-yaffs2> you must type the file name of the yaffs2 (e.g. system.yaffs2)
The files will get extracted and you'll be able to pick the ones you need.
Step 3.b - Mount the image
Since we're already in Linux, mounting a EXT image is not that hard. Just mount it using this commands in a Terminal (Ctrl+Alt+T to open it).
Code:
cd [COLOR="DarkOrchid"]<file-route-of-the-sin>[/COLOR]
mkdir android
sudo mount -t ext[color="RED"]*[/color] -o loop <name-of-the-image> android/
Where <file-route-of-the-sin> is where the SIN was located, where <the-name-of-the-image> you must type the file name of the ext image (e.g. system.ext4), and finally, where ext*, replace * with the version number of the EXT image you're mounting, usually, ext4
Now, once finished, to unmount it, type in a Terminal.
Code:
sudo umount android
rm -fr android
OSX GUIDE
Step 1 - Extract the SIN we need
Using your favourite archive manager (UnRarX, ZipEg, etc), open the FTF you want to extract the files from. (FYI: an FTF is just a Zip file with renamed extension)
Now copy/extract the SIN you want to unpack to a folder of your preference.
Step 2 - Dump the SIN
I'll take into account you already had installed Flashtools and Java JRE, in which case I highly encourage you to update both to the latest version available.
Now, open Flashtools. Click on Tools, Sin Editor. Hit the [...] and locate the SIN you previously extracted. Now, hit the [Extract Data] button. After a couple of minutes the bar should start running.
Once finished, you can have 2 kind of files: a .yaffs2 or a .ext4/.ext3/.ext2 file, which require different procedures on how to see it's contents.
Step 3.a - Convert the file to a readable format - UnYaffs2
If the file you get is a .yaffs2 format file, you're going to need an extra tool to extract it. For doing so, you are going to need the unyaffs2 tool.
You can download a pre-compiled binary from here, or you can install your own using Brew. From a Terminal (Command+Space, then type in Terminal) type the following commands.
Code:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null #This is just to Install Brew for the first time. If you already have it, it's not needed.
brew install unyaffs
If you chose using the UnYaffs2 binary, copy it to the very same folder where you placed the SIN, and thus, where the .yaffs2 is located.
If you chose the Brew installation, just continue.
Now, type in a Terminal (Command+Space, then type in Terminal).
Code:
cd [COLOR="DarkOrchid"]<file-route-of-the-sin>[/COLOR]
unyaffs2 [COLOR="Blue"]<the-name-of-the-yaffs2>[/COLOR]
Where <file-route-of-the-sin> is where the SIN was located, and thus, where the yaffs2 file is located; and where <the-name-of-the-yaffs2> you must type the file name of the yaffs2 (e.g. system.yaffs2)
The files will get extracted and you'll be able to pick the ones you need.
Step 3.b - Mount the image - Ext4FUSE
There're many many tools to mount a EXT format image in OSX, but in this case, since we don't need RW access, but just RO, I'll use ext4fuse, since it's free and it's more than compatible with our needs.
To install it you'll need Brew. To get things ready, type the following commands in a Terminal (Command+Space, then type in Terminal).
Code:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null #This is just to Install Brew for the first time. If you already have it, it's not needed.
brew tap homebrew/fuse
brew install Caskroom/cask/osxfuse
brew install ext4fuse
If you're on OSX Yosemite, El Capitan, or Leopard, you may need an extra command to add yourself to the Operator group, so that you can have readonly permissions to the disks.
Use it only if you get an error while trying to access the mounted EXT image later.
Code:
sudo dscl . append /Groups/operator GroupMembership [COLOR="red"]<your-user>[/COLOR]
Where your user <your-user> is your username.
Now, to mount the ext4 image, type in a Terminal (Command+Space, then type in Terminal).
Code:
mkdir android
ext4fuse [COLOR="DarkOrchid"]<path-to-the-ext4-image>[/COLOR] android
Where <path-to-the-ext4-image> you must type in the full path where the SIN was located, and thus, where the EXT4 image is located.
Use this as reference.
Reserved
In case I need it
Great job! Keep up the good work!!
Well. great guide.
Just a note, Microsoft officially released Bash on Ubuntu on Windows yesterday. Try it. It's a full fledged Linux subsystem but unfortunately only available to Windows Insiders. It would be the best alternate to cygwin.
Boot.img
How can i extract the boot.img
or is this applicable to every single .sin file present in the .ftf file
serajr said:
Great job! Keep up the good work!!
Click to expand...
Click to collapse
Thank you, I appreciate your words
mfbcool said:
Well. great guide.
Just a note, Microsoft officially released Bash on Ubuntu on Windows yesterday. Try it. It's a full fledged Linux subsystem but unfortunately only available to Windows Insiders. It would be the best alternate to cygwin.
Click to expand...
Click to collapse
I know, I saw the demonstration in the //build/, but since it hasn't been released for all yet (I guess it'll be for Redstone 2?), I didn't saw it necessary to be included.
sandeep.sethi said:
How can i extract the boot.img
or is this applicable to every single .sin file present in the .ftf file
Click to expand...
Click to collapse
No, this is only applicable for system.sin, userdata.sin, cache.sin and probably modem.sin.
However, if many of you request it, I could try making another for the kernel (boot.img)... But remember, every device doesn't have the same way/method to unpack the kernel, so making a generic tutorial for all wouldn't be possible
No, this is only applicable for system.sin, userdata.sin, cache.sin and probably modem.sin.
However, if many of you request it, I could try making another for the kernel (boot.img)... But remember, every device doesn't have the same way/method to unpack the kernel, so making a generic tutorial for all wouldn't be possible
Click to expand...
Click to collapse
if u can provide the guide it would be very helpful :fingers-crossed: :fingers-crossed:
This thread got featured in XDA Portal, thank you guys!
I tried extracting Xperia Pro's system SIN (can't remember the exact name but the one with the largest file size) using the latest version of Flashtool but wasn't successful. Like it's not supported yet.

[TOOL] Convert sin to flashable.zip

Disclaimer:
Our tool was made for testing and educational purposes, ME is not responsible for what you do on/with your device using our tool, you must agree that you using our tool on your own risk, I am not responsible if you brick your device or anything else!
What is this for:
This tool converts xperia sin file and directly create flashable.zip for use to flash your android device with recovery.
Changelog:
- version 1. (missing selinux label generator)
- version 2. (implemented selinux label generator tool. Missing static busybox)
- version 3.
- version 4. some small corections, added missing update-binary
- version 5. some improvements, new sin unpack tool
How to use:
Extract sin2zip.rar archive & simple run CONVERT.bat & chose system.sin image , tool will produce flashable.zip
What you need to check or probably modify in generated flashable.zip:
1. busybox I have used is 32bit, it will work on 64bit too (not busybox.exe !!), I not recommend to change busybox, but before you go for busybox replace make sure it is STATIC busybox and have working (chcon and chown) with -h parameter!
2. check updater-script e.g. first 3 lines and last 2 lines!
3. this -> https://forum.xda-developers.com/showpost.php?p=80593639&postcount=7
Source code:
modified ext4_read tool is in attachment. Original ext4_read is here, many thanks to author! I have notified Igor, hope we see selabels listing integration in 7z without need for hackish ext4_read
sony dump tool -> https://github.com/munjeni/anyxperia_dumper
munjeni said:
This tool converts xperia sin file and directly create flashable.zip for using with recovery. 75 percent is done. 25 percent of the things is missing, selinux related things. I need help for implement selinux to the 7z to list selinux labels from ext4! Here is work in proogress
Click to expand...
Click to collapse
Maybe @SuperR. of SuperR's Kitchen fame HERE could give you some pointers on this. :fingers-crossed:
Maybe you could work together to integrate some of your great Sony specific tools into the Kitchen
That kitchen do not have anything related to our tool. I have done some progress in extracting selabels from ext4 by searcing with inode number \0/
Right now tool is able to extract selabels by inode number pointing
So you are on the drawing board again! Cool... :highfive:
About what you wrote in the j4nn's thread (1. to make fota unpack tool), count on me if you need help, ok!
If I'm not mistaken, I sent you a ota update_package file from my x performance some time ago, but if I am, here it goes again.
Cheers.
serajr said:
So you are on the drawing board again! Cool... :highfive:
About what you wrote in the j4nn's thread (1. to make fota unpack tool), count on me if you need help, ok!
If I'm not mistaken, I sent you a ota update_package file from my x performance some time ago, but if I am, here it goes again.
Cheers.
Click to expand...
Click to collapse
Thanks! I will look into ota package till after I finish our tool
Almost done! New version v2 is out! Made small tool to read ext4 image and print selabels to updater-script, it look like this:
if regular file or folder:
Code:
run_program("/tmp/busybox", "chcon", "u:object_r:location_exec:s0", "/system/bin/xtwifi-inet-agent");
if symlink:
Code:
run_program("/tmp/busybox", "chcon", "-h", "u:object_r:vendor_file:s0", "/system/bin/xxd");
Tool is curently 95 percent done, not realy ready for flashig produced flashable.zip , need to implement 5 percent of the things. You can try but plese do not try to flash with recovery it will not work corectly!
Version 3 done! Before you flash flashable.zip please check updater-script first 3 lines and last 2 lines! Do in mind our tool didn't include the rest of firmware like kernel, vendor...etc, tool only convert one sin file to flashable.zip, if you need the rest of firmware run CONVERT.bat and chose another sin file, do merges in zip by hand and do merges-modification in updater-script by hand too. Not recommended for newbies! I can't tell you if produced flashable.zip is working I'm not tried to flash flashable.zip, but I think it going work. Important thing is initial tool is done and somebody need to test. Let me know Enjoy!
Version 4 done. Enjoy!
@serajr here is some info https://forum.xda-developers.com/showpost.php?p=80599561&postcount=1330 , your file is the same format as j4nn
Version 5 done.

[KITCHEN][WINDOWS] Multi Image Kitchen - Repack Android partitions

Multi Image Kitchen - Repack Android partitions from Windows
Possibilities:
Unpacking and packing partitions: System, Vendor, Product, ODM, SOCKO, ELABLE (RAW, SPARSE)
Unpacking and packing partitions with extension: * .img; * .fex; * .Partition; * .new.dat; * .new.dat.br; * .lz4; * .exT4; * .tar; * .md5
Unpacking and packaging logo partition: logo.img, logo.partition
Unpacking and Packaging: _aml_dtb.partition (Single, Multi, Multi / Gzipped)
Extract from the PAYLOAD.BIN file sections file
Removing from the Super.img file partitions
Unpacking and packaging of resource partition: resource.img
Unpacking and packaging SOC Amlogic firmware, Rockchip and Allwinner
Unpacking and assembling Service Package: * .zip (Update.zip)
Decompiling and compile applications (* .apk)
Github: https://github.com/CryptoNickSoft/MIK
Reserved
Reserved 2
Download link not working for me
Scramble said:
Download link not working for me
Click to expand...
Click to collapse
Update
Mine's in Russian
Edit: Nevermind, I've managed to change the language
RichardHer said:
Mine's in Russian
Edit: Nevermind, I've managed to change the language
Click to expand...
Click to collapse
So do something wrong.
omg, thanks you,this tool is useful!
@CryptoNick
Amazing, I was finally able to extract the system.fex. Originally I have a super.fex, which contained 3 other files: product.fex, system.fex and vendor.fex
Out of the 3 fex-files only 2 were automatically extracted after the initial split: system.fex and vendor.fex. The 3rd file product.fex could be manually extracted with your tool.
System.fex etc. can be created after modification, but how do I re-pack the 3 sub-files into the single super.fex again?
Packaging in super.fex has not yet been implemented. If there is a desire, help the project is financially and I will have more motivation to develop it.
Scramble said:
Download link not working for me
Click to expand...
Click to collapse
yes , not working
Zhao li said:
yes , not working
Click to expand...
Click to collapse
Everything is excellent friend
下载链接对我缠绕
just a readme
GitHub - CryptoNickSoft/MIK: Repack Android partitions from Windows
Repack Android partitions from Windows. Contribute to CryptoNickSoft/MIK development by creating an account on GitHub.
github.com
GitHub - CryptoNickSoft/MIK: Repack Android partitions from Windows
Repack Android partitions from Windows. Contribute to CryptoNickSoft/MIK development by creating an account on GitHub.
github.com
thanks
CryptoNick said:
GitHub - CryptoNickSoft/MIK: Repack Android partitions from Windows
Repack Android partitions from Windows. Contribute to CryptoNickSoft/MIK development by creating an account on GitHub.
github.com
Click to expand...
Click to collapse
CryptoNick said:
GitHub - CryptoNickSoft/MIK: Repack Android partitions from Windows
Repack Android partitions from Windows. Contribute to CryptoNickSoft/MIK development by creating an account on GitHub.
github.com
Click to expand...
Click to collapse
Thanks
Halo sir,can this tool solve Samsung devices that fail to flash with odin in the system.img section, after editing system.img with the other tool ?
Droid Maps said:
Halo sir,can this tool solve Samsung devices that fail to flash with odin in the system.img section, after editing system.img with the other tool ?
Click to expand...
Click to collapse
Hey! Try. I did not test, since this functionality is not interesting to me.
After hours and hours of googling I finally found something that can unlock logo.img files on Windows. However, it doesn't seem to work for me. I got the following error:
[7920] Failed to execute script 'imgextractor' due to unhandled exception!
Traceback (most recent call last):
File "imgextractor.py", line 374, in <module>
File "imgextractor.py", line 368, in main
File "imgextractor.py", line 261, in __ext4extractor
File "ext4.py", line 484, in __init__
ext4.MagicError: Invalid magic value in superblock: 0x0000 (expected 0xEF53)
I would really appreciate help as I'm really desperate by now.

Categories

Resources