Anything you do, is at your own risk. While this guide is especially written to not have any risk of bricking your phone, there is no guarantee.
This is a tutorial for perma-temp rooting your phone.
Perma-Temp root will allow you to root your phone, without altering the system structure in a permanent way. This is useful if you wish to have root privileges on your android, without the danger of bricking it. This process 99% risk free (read the disclaimer) and to reverse only a reboot is required. To totally remove, you simply need to delete a few files; as such you won’t void your phones warranty (at least they won’t know).
Compared to normal root procedures, Perma-Temp root stops after running the root exploit i.e. the procedure does not rewrite the current working operating system to gain permanent root status.
Android devices use a special technique to prevent any permanent alterations to the file system. (S-OFF and S-ON). As such, even when gaining root privileges, no permanent alterations can be made – all changes made will be lost after a reboot.
Often in the rooting process, busybox will be installed in /system/xbin. Several programs, such as Anti, depend on having the busybox tools installed here.
/system/xbin will be overridden after a reboot, leaving the user running in non-rooted mode without busybox and bash. While less functional, there is definitely an advantage to having a proper shell an the proper tools installed, even if you don’t have root.
The /data/local/tmp directory seems to be the one directory however in which one can store data, which does not get wiped on reboot.
We will take the approach that even if /system/xbin if overridden, the user will still be able to access their shell and tools, as it will be also installed in /data/local/tmp.To this extent ,we will create scripts to initiate and (re)-setup the environment each time the root exploit has been run.
Installation of the Perma-Temp root thus works as follows:
- Copy the programs (busybox, su, SuperUser, bash) to the phone
- Create and copy the root and initialization scripts to the phone
- Execute the script to root your phone
- Execute the post-root script to initiate the environment.
Once you have completed these steps, each time you wish to gain root access,
you need to:
- Execute the script to root your phone
- Execute the post-root script to initiate the environment.
For this tutorial , I’m assuming you’re using some android 2.2 -2.3 phone.
To facilitate this, we need to download and install the adb tool.
- Download android sdk
- Follow step 4 to install platform-tools such as to get adb
Furthermore, we also need to:
- Download the zergRush root exploit
- Download busybox
- Download Superuser tool
- Download bash
- Download and install jackpal’s Android Terminal Emulator (android market).
We are now ready to start the installation process:
- On you phone go to Settings-> Applications->Development->USB Debugging
- On you phone go to Settings-> Applications->Unknown Sources
- Plug in your usb cable and set the connection type to charge only
- Run the following adb commands from the command line:
adb push zergRush /data/local/tmp/
adb push Superuser-3.0.6-efgh-signed/system/bin/su /data/local/tmp/
adb push busybox /data/local/tmp/
adb push bash /data/local/tmp/
adb install Superuser-3.0.6-efgh-signed/system/app/Superuser.apk
We now need to create 3 scripts: The scripts will:
- Run the local root exploit correctly
- Initialize the environment
- Ensure graceful failover if the system is not rooted.
The first script we need to create, is really just to run the zergRush exploit, and clean up after it. The zergRush exploit creates files that need to be deleted after it executes, before it can be ran again.
As such, we have
#!/system/bin/sh
rm /data/local/tmp/sh
rm /data/local/tmp/boomsh
/data/local/tmp/./zergRush
Save this file on you computer as root.sh
Now for the second script, which needs to (re)initialize the environment.
What I mean by this is:
- Install BusyBox in the /data/local/tmp/bin directory
- Copy the correct su and sh (bash) files to the bin directory, overriding the busybox one’s.
- Remount all the directories to be writable, suid
For this script,the tricky bit is to find the device paths for your phone.
You need to locate both device paths for the system and the data partitions, e.g. /dev/block/mmcblk0p25 would be my “system” device path.
Run adb shell mount and search for the dev and mount path of both system and data, e.g. “/dev/block/mmcblk0p25 /system ext3 ro,relatime”
Replace these device paths in the following script, and save the script as postRoot.sh
#!/data/local/tmp/bash
mount -o remount,suid /dev/block/mmcblk0p25 /system
mount -o rw,remount rootfs /
mount -o remount,suid /dev/block/mmcblk0p26 /data
mkdir /data/local/tmp/bin >/dev/null 2>&1
/data/local/tmp/./busybox --install -s /data/local/tmp/bin/
/data/local/tmp/./busybox --install -s /system/xbin/
/data/local/tmp/./busybox cp /data/local/tmp/su /data/local/tmp/bin
/data/local/tmp/./busybox cp /data/local/tmp/su /system/xbin/
/data/local/tmp/./busybox cp /data/local/tmp/shell /data/local/tmp/bin/sh
chown root.shell /data/local/tmp/bin/su
chown root.shell /data/local/tmp/bin/sh
chmod 6555 /data/local/tmp/bin/su
chmod 6555 /data/local/tmp/bin/sh
sync
/data/local/tmp/bin/sh
Lastly we need to create a shell initialization script, that will
attempt to escalate to root, and if not successful, still fall back to
bash. This script will also set the correct environmental settings.
Create and save this file as ‘shell’
#!/data/local/tmp/bash
export PATH=/data/local/tmp/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export HOME=/data/local/tmp/
if [[ $EUID -ne 0 ]]
then
echo “Becoming ROOT!”
/data/local/tmp/su -c $0
/data/local/tmp/bash
fi
exec /data/local/tmp/bash
We now need to copy over these scripts, and to do so run
adb push root.sh /data/local/tmp/
adb push postRoot.sh /data/local/tmp/
adb push shell /data/local/tmp/
adb chmod 777 /data/local/tmp/*
Lastly, we need to open the terminal emulator and change its shell settings:
- Navigate to Menu -> More -> Preferences
- Change the command line setting to
/data/local/tmp/sh
We are now done with the setup.
To gain perm-temp root each time, run:
adb shell /data/local/tmp/./root.sh
adb shell /data/local/tmp/./postRoot.sh
You should see something like:
[**] Zerg rush – Android 2.2/2.3 local root
[**] (C) 2011 Revolutionary. All rights reserved.[**] Parts of code from Gingerbreak, (C) 2010-2011 The Android Exploid Crew.
[+] Found a GingerBread ! 0x00015118
[*] Scooting …
[*] Sending 149 zerglings …[+] Zerglings found a way to enter ! 0x10
[+] Overseer found a path ! 0x000151e0
[*] Sending 149 zerglings …
[+] Zerglings caused crash (good news): 0x401219d4 0x0054
[*] Researching Metabolic Boost …
[+] Speedlings on the go ! 0xafd25711 0xafd395bf
[*] Popping 24 more zerglings
[*] Sending 173 zerglings …[+] Rush did it ! It’s a GG, man !
[+] Killing ADB and restarting as root… enjoy!
bash-4.1#
Open up the terminal on your phone, and you should see a the root prompt.
The nice thing about the setup is even if you don’t have root, you can still use the
busy box commands.
While the loss of root on restart this is not as much fun as perma-root, however this is a no-risk solution.
Update: I had a report that the keyboard on the Samsung Galaxy II’s hangs after running the zergRush exploit. Exploits have a known history of making the exploited system unstable. As the perma-temp strategy depends on the system running the exploit each time to obtain root it is important to find the right exploit for your system.
Else perma-root may be you only option.