Skip to content

Instantly share code, notes, and snippets.

@CommanderAlchemy
Created July 14, 2013 22:59
Show Gist options
  • Select an option

  • Save CommanderAlchemy/5996460 to your computer and use it in GitHub Desktop.

Select an option

Save CommanderAlchemy/5996460 to your computer and use it in GitHub Desktop.
Linux script for rooting Android devices. Conversion from the Easy Rooting toolkit (v16.0) http://forum.xda-developers.com/showthread.php?t=2327472
#!/bin/bash
# Contributors (Linux)
# LoveMyAndroid2010 ADB_check(), pause()
# CommanderAlchemy Script conversion
clear
echo "==========================================================================="
echo "Easy Rooting toolkit (v16.0)"
echo " created by DooMLoRD"
echo " pref_event exploit"
echo " Credits go to all those involved in making this possible!"
echo " Special thanks to: the_laser, Bin4ry, fi01, hiikezoe, [NUT]"
echo " and to all those who are contributing to our git tree!"
echo " Sources: https://github.com/android-rooting-tools"
echo
echo " Linux script conversion by CommanderAlchemy 14.07.2013"
echo " Using ADB_check & pause() from LoveMyAndroid2010"
echo
echo " This version assumes you already have adb installed and"
echo " does not use the tools in the 'files' directory."
echo
echo "==========================================================================="
echo
echo " [*] This script will:"
echo " (1) root ur device using the pref_event exploit"
echo " (2) install Busybox"
echo " (3) install SU files"
echo " [*] Before u begin:"
echo " (1) make sure u have installed adb drivers for ur device"
echo " (2) enable "USB DEBUGGING""
echo " from (Menu\Settings\Developer Options)"
echo " (3) enable "UNKNOWN SOURCES""
echo " from (Menu\Settings\Security)"
echo " (4) connect USB cable to PHONE and then connect to PC"
echo " (5) skip "PC Companion Software" prompt on device"
echo
echo "###########################################################################"
echo "Warning!"
echo "This script is provided as is and no warranty is given that it"
echo "will work as desired. You have been warned!"
echo "###########################################################################"
echo
# This finds a working version of adb. First it assumes you already have the SDK installed
# if not found, it will try the one supplied in the 'stuff' directory.
adb_check() {
ADB=""
for test_adb in "adb" "files/adb"
do
$test_adb "kill-server" > /dev/null
if [[ $? == 0 ]]
then
ADB=$test_adb
break
fi
done
}
# Pause execution
pause() {
if [[ "$1" == "" ]]
then
pause "Press any key to continue."
else
read -s -n1 -p "$1"; echo
fi
return
}
if [[ "$1" == "-test" ]]
then
ADB="echo 'TEST_ADB'"
else
adb_check
if [[ "$ADB" == "" ]]
then
echo "No valid version of adb can be executed. This script needs adb to work properly!"
echo "Make sure adb is set for execution."
echo "--- Quitting..."
exit 1
fi
fi
pause "By pressing any key you have accepted the warning!"
echo
$ADB "wait-for-device"
echo
echo "--- Creating Temp..."
$ADB shell "cd /data/local && mkdir tmp"
echo
echo "--- Cleaning..."
$ADB shell "cd /data/local/tmp/ && rm *"
echo
echo "--- Pushing..."
$ADB push files/doomed.sh /data/local/tmp/doomed.sh
$ADB push files/doomed2 /data/local/tmp/.
$ADB push files/run_root_shell /data/local/tmp/.
$ADB push files/busybox /data/local/tmp/.
$ADB push files/su /data/local/tmp/.
$ADB push files/Superuser.apk /data/local/tmp/.
$ADB shell "chmod 777 /data/local/tmp/doomed.sh"
$ADB shell "/data/local/tmp/doomed.sh"
echo "--- Cleaning..."
$ADB shell "rm /data/local/tmp/*"
echo "--- Rebooting Device..."
$ADB reboot
echo "#################"
echo "Script Finished!"
echo "#################"
exit 0
@CommanderAlchemy
Copy link
Copy Markdown
Author

Results from my Sony Xperia Z (C6603)
firmware (10.3.A.0.423)

===========================================================================                                                                  
Easy Rooting toolkit (v16.0)                                                                                                                 
    created by DooMLoRD"
    pref_event exploit"
        Credits go to all those involved in making this possible!"
        Special thanks to: the_laser, Bin4ry, fi01, hiikezoe, [NUT]"
        and to all those who are contributing to our git tree!"
    Sources: https://github.com/android-rooting-tools"

    Linux script conversion by CommanderAlchemy 14.07.2013"
           Using ADB_check & pause() from LoveMyAndroid2010"

        This version assumes you already have adb installed and"
        does not use the tools in the 'files' directory."

===========================================================================                                                                   

  [*] This script will:                                                                                                                      
      (1) root ur device using the pref_event exploit                                                                                        
      (2) install Busybox                                                                                                                    
      (3) install SU files                                                                                                                   
  [*] Before u begin:                                                                                                                        
      (1) make sure u have installed adb drivers for ur device                                                                               
      (2) enable USB DEBUGGING                                                                                                               
            from (Menu\Settings\Developer Options)                                                                                           
      (3) enable UNKNOWN SOURCES                                                                                                             
            from (Menu\Settings\Security)                                                                                                    
      (4) connect USB cable to PHONE and then connect to PC                                                                                  
      (5) skip PC Companion Software prompt on device                                                                                        

###########################################################################                                                                  
Warning!                                                                                                                                     
This script is provided as is and no warranty is given that it                                                                               
will work as desired. You have been warned!                                                                                                  
###########################################################################                                                                  

By pressing any key you have accepted the warning!                                                                                           
* daemon not running. starting it now on port 5037 *                                                                                         
* daemon started successfully *                                                                                                              

--- Creating Temp...                                                                                                                       
mkdir failed for tmp, File exists                                                                                                            

--- Cleaning...                                                                                                                            
rm failed for *, No such file or directory                                                                                                   

--- Pushing...                                                                                                                             
7 KB/s (326 bytes in 0.041s)                                                                                                                 
38 KB/s (1578 bytes in 0.040s)                                                                                                               
642 KB/s (26268 bytes in 0.039s)                                                                                                             
5107 KB/s (853044 bytes in 0.163s)                                                                                                           
3695 KB/s (96260 bytes in 0.025s)                                                                                                            
4884 KB/s (1500495 bytes in 0.299s)                                                                                                          
--- DooMing device!                                                                                                                          
--- Correcting permissions                                                                                                                   
--- Running exploit                                                                                                                          


run_root_shell v6.0                                                                                                                          
Based on pref_event exploit                                                                                                                  

Modified for auto-rooting by DooMLoRD                                                                                                        
Part of Easy Rooting Toolkit                                                                                                                 

Devices Supported:                                                                                                                           
Xperia Z       (C6602/3)    - 10.1.1.A.1.253/307                                                                                             
Xperia Z       (C6602/3)    - 10.3.A.0.423                                                                                                   
Xperia ZL      (C6502/3/6)  - 10.3.A.0.423                                                                                                   
Tablet Z       (SGP321)     - 10.1.1.A.1.307                                                                                                 
Tablet Z       (SGP311/2)   - 10.1.C.0.370                                                                                                   
Xperia ZR      (C5502/3)    - 10.1.1.A.1.310                                                                                                 
Xperia SP      (C5302/3/6)  - 12.0.A.1.211/257/284                                                                                           
Xperia T       (LT30p)      - 9.1.A.1.141/142                                                                                                
Xperia TX      (LT29i)      - 9.1.B.1.67                                                                                                     
Xperia V       (LT25i)      - 9.1.A.1.140/142/145                                                                                            
Xperia S       (LT26i)      - 6.2.B.0.200/211                                                                                                
Xperia SL      (LT26ii)     - 6.2.B.0.211                                                                                                    
Xperia Acro S  (LT26w)      - 6.2.B.0.200/211                                                                                                
Xperia Ion     (LT28h)      - 6.2.B.0.211                                                                                                    
Xperia P       (LT22i)      - 6.2.A.1.100                                                                                                    
Xperia Go      (ST27i/a)    - 6.2.A.1.100                                                                                                    
Xperia AX      (SO-01E)     - 9.1.C.0.473                                                                                                    
Xperia Z       (SO-02E)     - 10.1.D.0.343                                                                                                   
Tablet Z       (SO-03E)     - 10.1.E.0.265/269                                                                                               
Xperia GX      (SO-04D)     - 7.0.D.1.137                                                                                                    
Xperia A       (SO-04E)     - 10.1.1.D.0.179                                                                                                 
Xperia A       (SO-04E)     - 10.1.1.D.2.26                                                                                                  
Xperia SX      (SO-05D)     - 7.0.D.1.137                                                                                                    
Xperia SX      (SO-05D)     - 9.1.C.0.475                                                                                                    
Xperia VL      (SOL21)      - 9.0.F.0.226                                                                                                    
Xperia VL      (SOL21)      - 9.1.D.0.395/401                                                                                                
Xperia UL      (SOL22)      - 10.2.F.3.43                                                                                                    
Google Nexus 4              - JDQ39                                                                                                          
Google Nexus                - JOP40C/JZO54K                                                                                                  
LG Optimus G E975           - v10e                                                                                                           


Changelog is posted here: http://bit.ly/ert_log                                                                                              



Device detected: C6603 (10.3.A.0.423)                                                                                                        

Attempt perf_swevent exploit...                                                                                                              
writing address is 8e49                                                                                                                      
Launching auto-root script!                                                                                                                  
---------------------------------------------------------------                                                                              
Launching final rooting process...                                                                                                           
---------------------------------------------------------------                                                                              
--- Rooting!                                                                                                                                 
--- Remounting rootfs                                                                                                                        
--- Killing RIC service (specific for new Xperia devices)                                                                                    
Unable to chmod /system/bin/ric: No such file or directory                                                                                   
--- Installing busybox                                                                                                                       
--- Remounting /system                                                                                                                       
--- copying busybox to /system/xbin/                                                                                                         
1666+1 records in                                                                                                                            
1666+1 records out                                                                                                                           
853044 bytes transferred in 0.071 secs (12014704 bytes/sec)                                                                                  
--- correcting ownership                                                                                                                     
--- correcting permissions                                                                                                                   
--- installing busybox                                                                                                                       
--- pushing SU binary                                                                                                                        
rm failed for /system/xbin/su, No such file or directory                                                                                     
188+1 records in                                                                                                                             
188+1 records out                                                                                                                            
96260 bytes transferred in 0.005 secs (19252000 bytes/sec)                                                                                   
--- correcting ownership                                                                                                                     
--- correcting permissions                                                                                                                   
--- correcting symlinks                                                                                                                      
rm failed for /system/bin/su, No such file or directory                                                                                      
--- pushing Superuser app
2930+1 records in
2930+1 records out
1500495 bytes transferred in 0.100 secs (15004950 bytes/sec)
--- correcting permissions
--- DONE!
***** Cleaning...
***** Rebooting Device...
#################
Script Finished!
#################

Works OK but needs some tweaking since it cannot create the folder if its already there and cannot remove for some reason.

Phone reboots correctly and rootchecker shows that it has access to root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment