Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Switch root on / off
#!/system/bin/sh
if [ -f /system/xbin/su_ ]; then
# grant permission for changing & executing files (copy from ota survival program)
/system/xbin/supolicy --live "allow init system_file file { write setattr relabelfrom rename }"
/system/xbin/supolicy --live "allow init install_recovery_exec file { setattr relabelfrom relabelto rename }"
/system/xbin/supolicy --live "allow init zygote_exec lnk_file { unlink } "
mount -o rw,remount /system
mv /system/xbin/su_ /system/xbin/su
mv /system/xbin/daemonsu_ /system/xbin/daemonsu
mv /system/bin/.ext_ /system/bin/.ext
rm /system/bin/app_process
rm /system/bin/app_process_ro
ln -s /system/xbin/daemonsu /system/bin/app_process
if [ -f /system/bin/app_process64 ]; then
mv /system/bin/app_process64 /system/bin/app_process64_original
rm /system/bin/app_process64_ro
ln -s /system/xbin/daemonsu /system/bin/app_process64
else
mv /system/bin/app_process32 /system/bin/app_process32_original
rm /system/bin/app_process32_ro
ln -s /system/xbin/daemonsu /system/bin/app_process32
fi
reboot
fi
stop ct_monitor
#!/system/bin/sh
if [ -f /data/su.img ]; then
# systemless root
if [[ -f /data/su_.img ]] && [[ -f /su/etc/.dirty ]]; then
echo su.img is clean, do nothing
else
mv /data/su.img /data/su_.img
cp /data/su_.img /data/su.img
chmod 644 /data/su.img
touch /su/etc/.dirty
fi
if [ -d /su/bin ]; then
mv /su/bin /su/bin2
fi
if [ -d /su/xbin_bind ]; then
umount /system/xbin
fi
SELINUX=`getenforce`
if [ "$SELINUX" == "Permissive" ]; then
touch /data/.reset_selinux
setenforce 1
fi
else
# traditional root
if [ -f /system/xbin/su ]; then
mount -o rw,remount /system
mv /system/xbin/su /system/xbin/su_
mv /system/xbin/daemonsu /system/xbin/daemonsu_
mv /system/bin/.ext /system/bin/.ext_
mv /system/bin/app_process /system/bin/app_process_ro
if [ -L /system/bin/app_process64 ]; then
ln -s app_process64 /system/bin/app_process
mv /system/bin/app_process64 /system/bin/app_process64_ro
mv /system/bin/app_process64_original /system/bin/app_process64
else
ln -s app_process32 /system/bin/app_process
mv /system/bin/app_process32 /system/bin/app_process32_ro
mv /system/bin/app_process32_original /system/bin/app_process32
fi
MODEL=`getprop ro.product.model`
# ZE500KL / ZE601KL / ZE550KL / ZD551KL
if [ "$MODEL" == "ASUS_Z00ED" ] || [ "$MODEL" == "ASUS_Z00UD" ] || [ "$MODEL" == "ASUS_Z00LD" ] || [ "$MODEL" == "ASUS_Z011D" ]; then
cp /data/data/com.corner23.android.rootswitch/files/qrngd /system/bin/qrngd
chmod 755 /system/bin/qrngd
chcon u:object_r:system_file:s0 /system/bin/qrngd
# ZE550ML / ZE551ML / A500CG / A600CG
elif [ "$MODEL" == "ASUS_Z00AD" ] || [ "$MODEL" == "ASUS_Z008D" ] || [ "$MODEL" == "ASUS_T00F" ] || [ "$MODEL" == "ASUS_T00G" ]; then
cp /data/data/com.corner23.android.rootswitch/files/ct_monitor /system/bin/ct_monitor
chmod 755 /system/bin/ct_monitor
chcon u:object_r:system_file:s0 /system/bin/ct_monitor
fi
mount -o ro,remount /system
setenforce 1
fi
fi
#!/system/bin/sh
if [ -f /data/su.img ]; then
# systemless root
if [ -d /su/bin2 ]; then
mv /su/bin2 /su/bin
fi
if [ -d /su/xbin_bind ]; then
mount -o bind /su/xbin_bind /system/xbin
fi
if [ -f /data/.reset_selinux ]; then
rm /data/.reset_selinux
setenforce 0
fi
else
# traditional root
if [ -f /system/xbin/su_ ]; then
mount -o rw,remount /system
mv /system/xbin/su_ /system/xbin/su
mv /system/xbin/daemonsu_ /system/xbin/daemonsu
mv /system/bin/.ext_ /system/bin/.ext
rm /system/bin/app_process
mv /system/bin/app_process_ro /system/bin/app_process
if [ -f /system/bin/app_process64 ]; then
mv /system/bin/app_process64 /system/bin/app_process64_original
mv /system/bin/app_process64_ro /system/bin/app_process64
else
mv /system/bin/app_process32 /system/bin/app_process32_original
mv /system/bin/app_process32_ro /system/bin/app_process32
fi
mount -o ro,remount /system
setenforce 0
fi
fi
#!/system/bin/sh
if [ -f /system/xbin/su_ ]; then
/system/xbin/supolicy --live "allow init system_file file { write }"
mount -o rw,remount /system
mv /system/xbin/su_ /system/xbin/su
mv /system/xbin/daemonsu_ /system/xbin/daemonsu
mv /system/bin/.ext_ /system/bin/.ext
rm /system/bin/app_process
rm /system/bin/app_process_ro
ln -s /system/xbin/daemonsu /system/bin/app_process
if [ -f /system/bin/app_process64 ]; then
mv /system/bin/app_process64 /system/bin/app_process64_original
rm /system/bin/app_process64_ro
ln -s /system/xbin/daemonsu /system/bin/app_process64
else
mv /system/bin/app_process32 /system/bin/app_process32_original
rm /system/bin/app_process32_ro
ln -s /system/xbin/daemonsu /system/bin/app_process32
fi
reboot
fi
stop qrngd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.