::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
::  Motorola universal root script
::  Windows version
::
::  Copyright (C) 2011 Dan Rosenberg (@djrbliss)
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
:: Instructions:
::
::  1. Ensure you have the latest drivers installed from Motorola
::
::  2. Put your device in debugging mode
::
::  3. Attach it via USB
::
::  4. Run this script in the same directory as the rest of the extracted
::     zipfile
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off
cd "%~dp0"

echo [*]
echo [*] Motofail: Universal Motorola Android Root Exploit (Windows version)
echo [*] by Dan Rosenberg (@djrbliss)
echo [*]
echo [*] Tested on Droid 3, Droid Bionic, Droid RAZR, and Droid 4
echo [*]
echo [*] Before continuing, ensure USB debugging is enabled, that you
echo [*] have the latest Motorola drivers installed, and that your phone
echo [*] is connected via USB.
echo [*]
echo [*] Press enter to root your phone...
pause
echo [*] 

echo [*] Waiting for device...
adb wait-for-device

echo [*] Device found.

echo [*] Deploying payload...
adb push motofail /data/local/motofail
adb shell "chmod 755 /data/local/motofail"

echo [*] Owning phone...
adb shell "/data/local/motofail exploit"

echo [*] Rebooting device...
adb reboot

echo [*] Waiting for phone to reboot.
adb wait-for-device

echo [*] Attemping persistence...
adb remount
adb push su /system/bin/su
adb shell "chmod 6755 /system/bin/su"
adb shell "ln -s /system/bin/su /system/xbin/su"
adb push busybox /system/xbin/busybox
adb shell "chmod 755 /system/xbin/busybox"
adb shell "/system/xbin/busybox --install /system/xbin"
adb push Superuser.apk /system/app/Superuser.apk

echo [*] Cleaning up...
adb shell "/data/local/motofail clean"
adb shell "rm /data/local/motofail"

echo [*] Rebooting...
adb reboot
adb wait-for-device

echo [*] Exploit complete!
echo [*] Press any key to exit.
pause
adb kill-server
