[MM / N] [LB] Dirtycow Temp Root Shell and Debloat Script (Freeze Unwanted Apps)

yacloo

Senior Member
Dec 13, 2010
261
140
73
İstanbul
Exactly!! :highfive:
Btw, check this guy's approach! (and his sources)
Unfortunately for us >>> $ lstat 'system/bin/dnsmasq' and '//init' failed: Permission denied :(
there is a info for others from github page
This code has only been tested for the Galaxy S7 Active on the September security patch. To make this work on other versions, INIT_OFFSET in farm.c may need to be modified.
 
  • Like
Reactions: serajr

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,010
18,602
263
São Paulo - SP
there is a info for others from github page
This code has only been tested for the Galaxy S7 Active on the September security patch. To make this work on other versions, INIT_OFFSET in farm.c may need to be modified.
I've already seen that... thank you!
The problem is that we won't be able to patch /init binary with dirtycow. Sony's guys are doing their job very well!!
 

p0kemon

Member
Nov 28, 2016
49
90
0
in oob of the nand memory
I am able to dump all units including one which contain drm key. How that is possible convert .ta to .img ?
Hey I am able to produce right partition hash, inded its adler32 algo as mentioned in oshmoun link to the ta header, with that thing I am prety sure we can reconstruct unlocked trim area back to locked state by restoring back most important units, removing unit 8b2 and restoring back deleted unit 1046B and finaly generate right adler32 hash into partition header. I am not 100% sure in all that but 50% it is possible :) Every unit contain 4 magic bytes, 4 bytes unit name, 4 bytes unit lenght, 4 bytes 0xFF, and unit data. Unit data must be 4 bytes aligned, for example if unit data contain 9 bytes in lenght 3 extra bytes must be added at the end 0xFFFFFF. Trim area contain two partitions, one is trim partition and seccond is misc partition. Every partition contain partition header, partition header contain 4 magic bytes, 4 bytes adler32 hash, and 6 extra bytes which contain partition num, partition part and partition number of blocks. Adler32 is calculated on 6 extra bytes after adler32 hash & partition data. Thats all which I know now. Sorry for being offtopic but if this is realy possible we no need any rooting tool and any tadumper, just use flash tool for dump trim area, than unlock bootloader, boot an recovery, install rooting package, dump unlocked trim area, reconstruct unlocked trim area, flash reconstructed trim area back and ooola :)

Exactly!! :highfive:
TA.img has a size of approximately 2mb (Z3 and Z3C at least)!
And this is the contents of backup.sh which does the job!
Sure, but only ~0xA0000 bytes is used, the rest is 0x0 ! In general 15 percent of that 0xA0000 bytes is important, the rest is logs! ;)

Is flashtool able to dump unit 1046B ?
 
Last edited:
  • Like
Reactions: serajr

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,010
18,602
263
São Paulo - SP
Nougat has fixed this exploit :(
I have not had time to check this yet, but it is very likely that sony has patched nougat's kernel indeed!!

Hey I am able to produce right partition hash, inded its adler32 algo as mentioned in oshmoun link to the ta header, with that thing I am prety sure we can reconstruct unlocked trim area back to locked state by restoring back most important units, removing unit 8b2 and restoring back deleted unit 1046B and finaly generate right adler32 hash into partition header. I am not 100% sure in all that but 50% it is possible :) Every unit contain 4 magic bytes, 4 bytes unit name, 4 bytes unit lenght, 4 bytes 0xFF, and unit data. Unit data must be 4 bytes aligned, for example if unir data contain 9 bytes in lenght 3 extra bytes must be added at the end 0xFFFFFF. Trim area contain two partitions, one is trim partition and seccondbis misc partition. Partition header contain 4 magic bytes, 4 bytes adler32 hash, and 6 extra bytes which contain partition num, partition part and partition number of blocks. Adler32 is calculated on 6 extra bytes after adler32 hash & partition data. Thats all which I know now.

Sure, but only ~0xA0000 bytes is used, the rest is 0x0 ! In general 15 percent of that 0xA0000 bytes is important, the rest is logs! ;)
That's great news! God job bro!! :highfive:
It would be amazing if you succeed on that.
 

rayman

Senior Recognized Developer
May 1, 2008
278
1,392
93
Hey I am able to produce right partition hash, inded its adler32 algo as mentioned in oshmoun link to the ta header, with that thing I am prety sure we can reconstruct unlocked trim area back to locked state by restoring back most important units, removing unit 8b2 and restoring back deleted unit 1046B and finaly generate right adler32 hash into partition header. I am not 100% sure in all that but 50% it is possible :) Every unit contain 4 magic bytes, 4 bytes unit name, 4 bytes unit lenght, 4 bytes 0xFF, and unit data. Unit data must be 4 bytes aligned, for example if unit data contain 9 bytes in lenght 3 extra bytes must be added at the end 0xFFFFFF. Trim area contain two partitions, one is trim partition and seccond is misc partition. Every partition contain partition header, partition header contain 4 magic bytes, 4 bytes adler32 hash, and 6 extra bytes which contain partition num, partition part and partition number of blocks. Adler32 is calculated on 6 extra bytes after adler32 hash & partition data. Thats all which I know now. Sorry for being offtopic but if this is realy possible we no need any rooting tool and any tadumper, just use flash tool for dump trim area, than unlock bootloader, boot an recovery, install rooting package, dump unlocked trim area, reconstruct unlocked trim area, flash reconstructed trim area back and ooola :)


Sure, but only ~0xA0000 bytes is used, the rest is 0x0 ! In general 15 percent of that 0xA0000 bytes is important, the rest is logs! ;)

Is flashtool able to dump unit 1046B ?
Even with the coming full TA dump, I think spending time to make this work is important for future endeavors - dirtycow is likely to be fixed soon but surely new bugs will appear that will let us grab TA units from the ta daemon through other means :)
 

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,010
18,602
263
São Paulo - SP
Just a quick heads up:
It *is* possible to dirtycow your way to a full TA dump, and barring some cleanups and stability improvements, I'm planning to release a "universal" TA dumper sometime next week.
Don't f*** .... That's amazing! :highfive: Please do it!
If you need some help just let me know. Unfortunately I don't have time enough to keep on this as I'd wish, that's why we need help each other.

That will be epic!!
 

Myself5

Recognized Developer
Mar 17, 2011
3,374
9,636
263
22
myself5.de
Don't f*** .... That's amazing! :highfive: Please do it!

If you need some help just let me know. Unfortunately I don't have time enough to keep on this as I'd wish, that's why we need help each other.



That will be epic!!


He's not kidding. It's working. I tested it on sumire, aries and XP, and diffed the aries and sumire with a dded TA backup, all of them had the same MD5 checksum.

I guess all that is remaining, is cleaning up the tools a bit, as well as writing an automated script to pull the TA.img (which is something that I will force him to accept, bwahhahahaha).


Sent from my iPad using Tapatalk
 

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,010
18,602
263
São Paulo - SP
wtf? I just connected to phone via adb (wi-fi connect) and launch flashtool
Just a message!

He's not kidding. It's working. I tested it on sumire, aries and XP, and diffed the aries and sumire with a dded TA backup, all of them had the same MD5 checksum.

I guess all that is remaining, is cleaning up the tools a bit, as well as writing an automated script to pull the TA.img (which is something that I will force him to accept, bwahhahahaha).

Sent from my iPad using Tapatalk
What can I say? Amazing!! ;)

I can help on script if needed, once again, just let me know!
 

p0kemon

Member
Nov 28, 2016
49
90
0
in oob of the nand memory
Even with the coming full TA dump, I think spending time to make this work is important for future endeavors - dirtycow is likely to be fixed soon but surely new bugs will appear that will let us grab TA units from the ta daemon through other means :)
I must say its done! My research is based on initial research done by @munjeni, it helped me a lot, oshmoun git link helped me for hashing... and thats not all, I found backup of the unit 1046b in block which starts at offset 0x80000 which contain partition header FFFFFFFF00000000000000, its not deleted by unlocking trought .ta file but deleted if you unlock by fastboot :p
 
Last edited:
  • Like
Reactions: serajr

oshmoun

Senior Member
Aug 29, 2012
1,397
1,458
0
¯\_(ツ)_/¯
I must say its done! My research is based on initial research done by @munjeni, it helped me a lot, oshmoun git link helped me for hashing... and thats not all, I found backup of the unit 1046b in block which starts at offset 0x80000 which contain partition header FFFFFFFF00000000000000, its not deleted by unlocking trought .ta file but deleted if you unlock by fastboot :p
done = you can generate a valid ta.img out of the units?
or I'm just too hopeful? :silly:
 

shoey63

Recognized Contributor
Jun 5, 2012
4,003
3,982
253
Somewhere in Oz...
I must say its done! My research is based on initial research done by @munjeni, it helped me a lot, oshmoun git link helped me for hashing... and thats not all, I found backup of the unit 1046b in block which starts at offset 0x80000 which contain partition header FFFFFFFF00000000000000, its not deleted by unlocking trought .ta file but deleted if you unlock by fastboot :p
In that case, the flashtool code can be manipulated so as to only unlock the bootloader without wiping DRM keys. Or am I missing something?
 

oshmoun

Senior Member
Aug 29, 2012
1,397
1,458
0
¯\_(ツ)_/¯
In that case, the flashtool code can be manipulated so as to only unlock the bootloader without wiping DRM keys. Or am I missing something?
depends on whether the bootloader checks if the drm keys still exist when it finds the unlock unit.
If there's no check, then hopefully both can co-exist in TA.
Anyone courageous enough to try? :silly:
 

p0kemon

Member
Nov 28, 2016
49
90
0
in oob of the nand memory
In that case, the flashtool code can be manipulated so as to only unlock the bootloader without wiping DRM keys. Or am I missing something?
No no, drm key is still deleted! If you do ta dump you can see drm key twiced, one is in partition 1 and seccond one is in one block which seems not a partition. If you unlock bootloader drm key is deleted but not from that block (in case unlocking was done by .ta file). Userdata doesn't wiped too. In case unlocking is done with fastboot, booth drm key is deleted and allso userdata is wiped. Thats not all, trim area is strongly modified which is not a case when it is done using .ta unlock method. Thats what I found. I can reconstruct trim area easy if unlocking is done using .ta. I am sorry if this is not a right place speaking about ta... I will need some ta dumps from X to see if things is the same on X before I start making a tool...
 
Last edited:

serajr

Recognized Developer / Recognized Themer
Apr 21, 2011
5,010
18,602
263
São Paulo - SP
No no, drm key is still deleted! If you do ta dump you can see drm key twiced, one is in partition 1 and seccond one is in one block which seems not a partition. If you unlock bootloader drm key is deleted but not from that block (in case unlocking was done by .ta file). Userdata doesn't wiped too. In case unlocking is done with fastboot, booth drm key is deleted and allso userdata is wiped. Thats not all, trim area is strongly modified which is not a case when it is done using .ta unlock method. Thats what I found. I can reconstruct trim area easy if unlocking is done using .ta. I am sorry if this is not a right place speaking about ta... I will need some ta dumps from X to see if things is the same on X before I start making a tool...
Please bro, feel free to use this thread for that purpose!! :good:

Btw, did you see this tool which creates Flashtool's compatible ftf file (flash_dk)?
 
Last edited:
  • Like
Reactions: p0kemon