Find a file
2016-12-29 15:04:00 -08:00
seldis Update seldis module comments for 5.0.4 2015-12-17 18:36:06 -08:00
win_drivers Add Windows driver for ADB 2016-01-05 20:07:39 -08:00
.gitignore A few cleanups (ignore changed.txt) 2015-12-18 19:07:08 -08:00
build_exe.bat Add py2exe scripts, add some patch checks 2015-12-12 16:00:16 -08:00
changed_blks.py Initial commit. Supports 5.0.3_user_532011220 2015-11-07 11:39:01 -08:00
checkver.py Fix checkver when build.prop is random junk 2015-12-16 18:33:04 -08:00
dd.exe Adding DD 2015-11-24 22:08:06 -05:00
filefrag Initial commit. Supports 5.0.3_user_532011220 2015-11-07 11:39:01 -08:00
handshake.py Start of single script, remove now redundant win handshake/checker script 2015-12-09 01:38:44 -08:00
install_py2exe.bat Improve the instructions in root_aftv2.bat 2015-12-12 23:25:56 -08:00
install_pyserial.bat Improve the instructions in root_aftv2.bat 2015-12-12 23:25:56 -08:00
md5sums.txt Updated md5 for 5.0.4 (TEE2 different on new devices) 2015-12-19 09:34:35 -08:00
partinfo.txt Initial commit. Supports 5.0.3_user_532011220 2015-11-07 11:39:01 -08:00
patch_mmc.bat Clean up patch_mmc.bat a little (also fix some comments) 2015-12-19 09:40:28 -08:00
patch_mmc.py Improve patch_mmc.py 2015-12-08 16:11:08 -08:00
patch_mmc.sh Write patch file with phys addr in name 2015-12-19 00:03:07 -08:00
read32.py Fix read32/write32 (lowercase port variable) 2015-12-04 10:46:51 -08:00
read_mmc.py converted checkver to physaddr, added 0x to addr in patch_mmc.py and merged read_mmc.py 2015-11-29 15:49:48 -05:00
README Add warning about these tools being broken on newer versions 2016-12-29 15:04:00 -08:00
README_WIN.txt A few updates to the README files 2015-12-19 09:51:44 -08:00
root_aftv2.bat updated error check in bat file 2015-12-13 16:49:55 -05:00
root_aftv2.py Remove lastaddr.txt if rooting is successful 2015-12-30 21:49:39 -08:00
root_upgrade.sh Add @aboshi's script to direct upgrade a rooted device 2015-12-30 22:37:34 -08:00
setup.py Add encodings to the py2exe build 2016-01-01 16:37:06 -08:00
version.txt Update version.txt for 5.0.4 2015-12-16 19:04:11 -08:00
write32.py Fix read32/write32 (lowercase port variable) 2015-12-04 10:46:51 -08:00
write_mmc.py Merge write_mmc_win.py and add resume support 2015-11-29 00:27:21 -08:00

*** WARNING: These tools only work on AFTV2 devices running 5.0.5.1 or older ***

http://www.aftvnews.com/software-version-5-2-1-0-blocks-rooting-via-a-to-a-usb-cable-on-fire-tv-2/#comment-280355

=== Patching a Partition ===

sh$ adb reboot ; ./handshake.py

sh$ cmp -l system.orig.img system.root.img > system.diff

sh$ ./patch_mmc.sh 0x00000000058e0000 system.root.img system.diff

NOTE: Cut and restore power to exit the preloader

Once you have root you can just write the file to the partition to restore.

adb$ dd if=system.orig.img of=/dev/block/platform/mtk-msdc.0/by-name/system bs=1m
adb$ sync
adb$ reboot


=== Modifying a File ===

NOTE: system partition @ 0x00000000058e0000

adb$ filefrag -v /system/bin/logcat_log.sh
Filesystem type is: ef53
File size of /system/bin/logcat_log.sh is 587 (1 block of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:     307248..    307248:      1:             last,eof
/system/bin/logcat_log.sh: 1 extent found

adb$ reboot

sh$ ./handshake.py

sh$ ./read_mmc.py $((0x00000000058e0000+(307248*4096))) $((1*4096)) file.out

sh$ <editor> file.out

sh$ ./write_mmc.py $((0x00000000058e0000+(307248*4096))) file.out

NOTE: It's a good idea to keep the original contents backed up

NOTE: The non-zero'd contents should be the same length as the original file
and also the overall file size, (multiple of 4096 normally)

TIP: You can use an invalid read to exit the preloader although you have to
wait for a 5 second timeout before it reboots. EX: ./read32.py 0 1


=== Initial Rooting ===

To run commands on the device as root you need to initially patch a service
script that runs within the init context (others work but you can do less).
One such script is /system/bin/logcat_log.sh. Using the procedure above you
can modify the file to eval an android parameter of your choosing.

eval `getprop debug.log.command`

For the patched logcat_log.sh script above you could run a command using:

adb$ setprop debug.log.command "date > /data/out"
adb$ setprop debug.log.logcat.enable y

To load a kernel module you need to first get the file into a location and
context that the service script can read, for example /data. This is done
using a similar trick to modifying the flash contents in the preloader.

dd if=/dev/block/mmcblk0p15 of=/data/file.ko \
    bs=1 skip=$((66528*4096)) count=128371

NOTE: Here you use the actual file size not the block based size

FYI: I've never had to copy a file with more than 1 extent. Not sure what
would need to change in the procedure for that case.

Once you have the module in /data you simply run "insmod /data/file.ko"

Once SELinux is in permissive mode you can execute su to get a root adb shell.
You will need to first copy the su binary from the SuperSU update zip package.
One copy of su should be named daemonsu and other just su. To then enable su
use the following setup commands:

chown root.root /data/su
chmod 6755 /data/su
chmod 755 /data/daemonsu
/data/daemonsu --auto-daemon &

You can then run /data/su to become root and then run the normal SuperSU update
script. To run the update script you will need to create /tmp and mount it as
tmpfs and also have unzip in your path.

=== References ===

* http://mattboyer.github.io/PYaffs/2014/07/31/Hacklog%233.html
* https://sturmflut.github.io/mediatek/2015/07/04/mediatek-details-partitions-and-preloader/