my tool is for now read-only on purpose.
Writing the hashes would be easy to implement, but I don't know
if a simple (fopen, fseek, fwrite, fclose) to /dev/bml0/3 would break
something and I would feel very bad I a TV got bricked because of my tool.
If someone has experience in modifying his hashes, could you tell me
what would be the best approach to do so ?
I think a save way is to (programatically) dump /dev/bml0/3, modify it
and reflash it (with bmlrestore). It should work, but I haven't dared to try it

So if someone could tell me if writing via fwrite (directly to /dev/bml0/3) works
I can implement it).
Then the tool could check the hashes and ask if it should correct wrong hashes.
The structure of /dev/bml0/3 is as follows (don't know if posting a dump is ok):
4096 filler bytes (I think they are all 00 or ff, don't have the TV in reach).
after that 6 hashes are stored where a hash consists of the 16-byte hash itself and a 4 byte length (of the partition or file).
The length actually specifies over how many bytes the hash is calculated.
smartsmurf used this in calculating the hash over the first 4 bytes only, stored this hash and modified the size to 4
so he can change everything after those first 4 bytes (which is a header).
The hashes are in this order: kernel, uboot, fnw, authuld, root, boot
So in a nutshell, the bml0/3 structure is:
Code: Select all
[4096 bytes]
[16 bytes kernel hash][4 bytes kernel length]
[16 bytes uboot hash][4 bytes uboot length]
[16 bytes fnw hash][4 bytes fnw length]
[16 bytes authuld hash][4 bytes authuld length]
[16 bytes root hash][4 bytes root length]
[16 bytes boot hash][4 bytes boot length]
The structure of the macpartition file ist very simple:
Code: Select all
[16 byte mtd_exe hash][4 byte mtd_exe length][16 byte mtd_app hash][4 byte mtd_app length]
I don't know the order in which the hashes are checked
but mtd_exe and mtd_app should be later then the rest of them
(don't mess with the other hashes if you don't really know what you are doing).
Be very very careful when modifying the hashes you
can brick your system which every single one of them !!!
(That is why I haven't implemented the auto-update function).
cu
Cyberdemon