Extract md5 checksum from tar.md5 file?
Posted 11 September 2020 - 03:58 AM
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.
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:
which is a tool to create tar.md5 files for use with Odin.
The "core" is a small batch:
rem Create the tar file:
rem // clear previous files.
RMDIR /S /Q 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\
rem Creat a AllInOne Tar file for all img and bin files
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
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
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:
If the files inside are actual volume images, IMDISK should be able to access/mount them , but of course you will need to install an EXT2/3/4 driver in windows.
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.
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).
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users