#!/bin/sh
# This can't be run from Terminal Emulator, but it can be used on a Linux or
# Mac system to run the root, assuming you've got adb installed.
#
echo "---           Samsung i545 VRUEMJ7 Root               ---"
echo "--- Based on the CVE-2013-6282 exploit by cubeundcube ---"
echo ""
echo "Waiting for device..."
echo "Watch your phone. Unlock it and give permission for the install to run."
adb wait-for-device
echo "Sending files to your device..."
adb push files/getroot /data/local/tmp/
adb push files/su /data/local/tmp/
adb push files/Superuser.apk /data/local/tmp/
adb push files/busybox /data/local/tmp/
adb push files/install-recovery.sh /data/local/tmp/
adb shell "chmod 0755 /data/local/tmp/getroot"
adb shell "chmod 0755 /data/local/tmp/busybox"
echo ""
echo "Starting rooting program."
adb shell /data/local/tmp/getroot
echo ""
echo "Removing temporary files..."
adb shell "rm /data/local/tmp/getroot"
adb shell "rm /data/local/tmp/su"
adb shell "rm /data/local/tmp/Superuser.apk"
adb shell "rm /data/local/tmp/busybox"
adb shell "rm /data/local/tmp/install-recovery.sh"
echo ""
echo "Rebooting...Please wait."
adb reboot
echo "Waiting for device to re-appear..."
adb wait-for-device
sleep 30
echo "Unlock your phone, and when prompted, give SuperSU permission for"
echo "'ADB shell' to run."
adb wait-for-device
adb shell "su -c sleep 1"
adb wait-for-device
adb shell "su -c sleep 1"
adb wait-for-device
adb shell "su -c sleep 1"
adb wait-for-device
adb shell "su -c sleep 1"
adb wait-for-device
adb shell "su -c sleep 1"
adb wait-for-device
adb shell "su -c sleep 1"
adb wait-for-device
adb shell "su -c sleep 1"
echo "Installing busybox"
adb shell "su -c mount -o remount,rw /system"
adb shell "su -c chmod 6755 /system/xbin/su"
adb shell "su -c chmod 6755 /system/xbin/daemonsu"
adb shell "su -c /system/xbin/busybox --install -s /system/xbin"
adb shell sleep 15
adb shell "su -c mount -o remount,ro /system"
echo ""
echo "--- All Finished ---"
