[TOOL][Windows,Linux,Android,Apple] Unpack any Sony firmware file

Search This thread

munjeni

Senior Member
Jun 2, 2011
9,590
22,241
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
 

Attachments

  • sony_dump_tool.zip
    2.4 MB · Views: 4,323
Last edited:

Ahmad Tawfik

Senior Member
Aug 31, 2015
690
242
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
 
  • Like
Reactions: munjeni

russel5

Senior Member
Jun 13, 2012
859
1,257
40
Yekaterinburg
@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)
 
Last edited:
  • Like
Reactions: munjeni

munjeni

Senior Member
Jun 2, 2011
9,590
22,241
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.
 
  • Like
Reactions: russel5

SXUsr

Senior Member
Jul 11, 2010
8,157
2,875
Here =)
This is for unpacking only. :) You can read xda contain ton of tutorials related to how to pack boot image, just search please
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.
 

munjeni

Senior Member
Jun 2, 2011
9,590
22,241
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!
 
Last edited:

munjeni

Senior Member
Jun 2, 2011
9,590
22,241
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 :)
 
Last edited:
  • Like
Reactions: osm0sis

munjeni

Senior Member
Jun 2, 2011
9,590
22,241
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 :(
 
  • Like
Reactions: sijav and osm0sis

munjeni

Senior Member
Jun 2, 2011
9,590
22,241
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 :)
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 72
    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
    8
    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 :)
    8
    New version is out!

    - 12.06.2018 -> sin version 5 support
    8
    New version of the filecont tool now in windows, linux and arm, and also new version of the kernel_dump tool, enjoy!

    How to convert file_contexts.bin binary to plaintext file_contexts:
    filecont file_contexts.bin file_contexts

    You can use/modify these files and/or include them in your work as long as proper credits and a link to this thread are given.
    6
    Update:
    now tool is able to extract any sin file and output it to converted.file