Jump to content











- - - - -

Extract md5 checksum from tar.md5 file?


  • Please log in to reply
3 replies to this topic

#1 Guest_AnonVendetta_*

Guest_AnonVendetta_*
  • Guests

Posted 11 September 2020 - 03:58 AM

I have a collection of Samsung Android firmwares. They are individually packaged as zips, but when extracted there is 1 or more tar.md5 files (usually just one that is around 3.5GB). I can open these tar.md5 files with 7-Zip/WinRAR, inside them are partition images that correspond to on-device partitions. These tar.md5 files are individually verified by Odin/Heimdall before flashing. I can also just remove the md5 extension before flashing, to make it just a plain tar. But then no verification is done.

I'm sure that this checksum must be stored somewhere in the tar.md5 (header or footer, most likely). How can I extract just the checksum, preferably to a standard md5 text file? Then I could check each file without running them through the flashing software one by one.

Another question: some of the files inside the tar.md5 have img, mbn, ext4, and bin extensions. I'm not sure which of these are Android-specific, or if they're all just generic formats. I'm sure that these are either ext4-formatted images, or raw binary images. Any way to mount them in Windows and extract the contents? I dont want to resort to using Linux, even though I run Mint in a VM because I'm a beginner ROM/kernel developer.

#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 September 2020 - 06:53 AM

The archives should be "normal" .tar ones and the MD5 hash is simply appended to the file (you can call it a footer even if it is post-added and isn't part of the actual tar format), so you can extract the last few bytes.
 
Check the tool posted here:
https://www.droidthu...img-to-tar-md5/
tar-Tool_Odin3-v3.10.7_by_mkh.mourad.zip
which is a tool to create tar.md5 files for use with Odin.
The "core" is a small batch:

rem Create the tar file:
SETLOCAL ENABLEDELAYEDEXPANSION
rem // clear previous files.
RMDIR /S /Q AllFiles
MKDIR AllFiles
call set curentDir="%cd%%"
FOR /f "delims=" %%G in ('DIR /S /A:-D /B *.img *.bin') do (
call cd %%~dpG
call !curentDir!\BIN\tar --create --format=gnu -b20 --quoting-style=escape --owner=0 --group=0 --totals --mode=644 -f %%~nG.tar %%~nxG
xcopy %%~nxG !curentDir!\AllFiles\
)
cd !curentDir!


rem Creat a AllInOne Tar file for all img and bin files
cd AllFiles
call !curentDir!\BIN\ls *.img *.bin > allfiles.txt
call !curentDir!\BIN\tar --create --format=gnu -b20 --quoting-style=escape --owner=0 --group=0 --totals --mode=644 -f allfiles.tar -T allfiles.txt
del /Q allfiles.txt
cd !curentDir!


rem Create the md5 final file:
FOR /f "delims=" %%G in ('DIR /S /A:-D /B *.tar') do (
call cd %%~dpG
call !curentDir!\BIN\md5sum -t %%~nxG >> %%~nxG
call !curentDir!\BIN\mv %%~nxG %%~nxG.md5

)
cd !curentDir!

 

Most probably (but it has to be checked) the Odin tool (and similar stuff dealing with tar.md5) gathers the offset to the beginning of the MD5 hash reading the "size" field of the .tar header at offset 124:
https://www.gnu.org/...e/Standard.html

If the files inside are actual volume images, IMDISK should be able to access/mount them :unsure:, but of course you will need to install an EXT2/3/4 driver in windows.

 

:duff:

Wonko

 



#3 Guest_AnonVendetta_*

Guest_AnonVendetta_*
  • Guests

Posted 11 September 2020 - 07:13 AM

I'll look into that tool, didnt even notice it whilen searching. Dont know why Samsung doesnt just store the partition images in plain old zips. Surely they could just create a zip.md5.....Tar seems to be inherently Unix-like-specific.

 

You say header...but isnht a header the opposite of a footer? Header is at the beginning of a file, footer is at the end.

 

I'm not sure which of the images have filesystems inside them. Any way to analyze them? I think the system.img.ext4, cache.img.ext4, and hidden.img.ext4 contain a filesystem, but I'm pretty sure they're sparse. I havent found any Windows tool that can mount them.

 

Edit: boot.img and recovery.img dont contain a valid FS, but I know how to unpack, modify, and repack them. Not sure how they can container files/folders without a valid FS. They are essentially ramdisks stored in img format, representing Android's boot and recovery partition (the former is critical, the latter not so much except for specific things). The boot poartition is not to be confused with the bootloader, which is separate.



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 11 September 2020 - 08:29 AM

The .tar "normal" file has a header (link given).

 

In the header besides other info there is the size of the .tar file.

 

Since the output of MD5Sum is appended at the end of the .tar file (thus becoming a sort of footer of the .tar.md5 file, but NOT belonging to the .tar) its position in the .tar.md5 file is right at the end of the original .tar file, i.e. with offset the size of the original .tar file present in the header (still of the original .tar file).

 

:duff:

Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users