forked from linux-shield/shield-root
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit
More file actions
executable file
·128 lines (112 loc) · 3.47 KB
/
Copy pathinit
File metadata and controls
executable file
·128 lines (112 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/sh
# Try to stay as close to SuperSU's script as possible
BIN=/rootkit
COM=/rootkit
ch_attr() {
[ -e $1 ] && chattr -i $1
}
ui_print() {
echo -n -e "$1\n" > /dev/tty1
}
set_perm() {
chown $1:$2 $4
chmod $3 $4
}
ch_con() {
/sbin/setfattr -n security.selinux -v u:object_r:system_file:s0 $1
}
inst() {
cp $1 $2
chmod $3 $2
}
# Prepare a basic working system
mkdir /proc
mkdir /sys
mkdir /d
/bin/mount /proc
/bin/mount /sys
echo /sbin/mdev >/proc/sys/kernel/hotplug
mdev -s
ui_print "\n\n\n\n\n"
ui_print "*****************"
ui_print "SuperSU installer"
ui_print "*****************"
ui_print "- Waiting for partitions to enumerate"
sleep 5
ui_print "- Mounting /system, /data and rootfs"
# emmc device number will change depending on whether the SD card is inserted or not.
# Create the device with the right minor number and mount it
mknod /dev/systempartition b `cat /sys/bus/mmc/devices/mmc2\:0001/block/mmcblk?/mmcblk?p4/dev |sed 's/:/ /'`
mknod /dev/datapartition b `cat /sys/bus/mmc/devices/mmc2\:0001/block/mmcblk?/mmcblk?p12/dev |sed 's/:/ /'`
mkdir -p /system
mount -text4 /dev/systempartition /system
mkdir -p /data
mount -text4 /dev/datapartition /data
ui_print "- Disabling OTA survival"
ch_attr /system/xbin/su
ch_attr /system/bin/.ext/.su
ch_attr /system/xbin/daemonsu
ch_attr /system/etc/install-recovery.sh
ui_print "- Removing old files"
rm -f /system/bin/su
rm -f /system/xbin/su
rm -f /system/xbin/daemonsu
rm -f /system/bin/.ext/.su
rm -f /system/etc/install-recovery.sh
rm -f /system/etc/init.d/99SuperSUDaemon
rm -f /system/etc/.has_su_daemon
rm -f /system/etc/.installed_su_daemon
rm -f /system/app/Superuser.apk
rm -f /system/app/Superuser.odex
rm -f /system/app/SuperUser.apk
rm -f /system/app/SuperUser.odex
rm -f /system/app/superuser.apk
rm -f /system/app/superuser.odex
rm -f /system/app/Supersu.apk
rm -f /system/app/Supersu.odex
rm -f /system/app/SuperSU.apk
rm -f /system/app/SuperSU.odex
rm -f /system/app/supersu.apk
rm -f /system/app/supersu.odex
rm -f /data/dalvik-cache/*com.noshufou.android.su*
rm -f /data/dalvik-cache/*com.koushikdutta.superuser*
rm -f /data/dalvik-cache/*Superuser.apk*
rm -f /data/dalvik-cache/*SuperUser.apk*
rm -f /data/dalvik-cache/*superuser.apk*
rm -f /data/dalvik-cache/*eu.chainfire.supersu*
rm -f /data/dalvik-cache/*Supersu.apk*
rm -f /data/dalvik-cache/*SuperSU.apk*
rm -f /data/dalvik-cache/*supersu.apk*
rm -f /data/app/com.noshufou.android.su-*
rm -f /data/app/com.koushikdutta.superuser-*
rm -f /data/app/eu.chainfire.supersu-*
ui_print "- Placing files"
mkdir -p /system/bin/.ext
cp $BIN/su /system/xbin/daemonsu
cp $BIN/su /system/xbin/su
cp $BIN/su /system/bin/.ext/.su
cp $COM/Superuser.apk /system/app/Superuser.apk
cp $COM/install-recovery.sh /system/etc/install-recovery.sh
echo 1 > /system/etc/.has_su_daemon
echo 1 > /system/etc/.installed_su_daemon
ui_print "- Setting permissions"
set_perm 0 0 0777 /system/bin/.ext
set_perm 0 0 06755 /system/bin/.ext/.su
set_perm 0 0 06755 /system/xbin/su
set_perm 0 0 06755 /system/xbin/daemonsu
set_perm 0 0 0755 /system/etc/install-recovery.sh
set_perm 0 0 0644 /system/etc/.has_su_daemon
set_perm 0 0 0644 /system/etc/.installed_su_daemon
set_perm 0 0 0644 /system/app/Superuser.apk
ch_con /system/bin/.ext/.su
ch_con /system/xbin/su
ch_con /system/xbin/daemonsu
ch_con /system/etc/install-recovery.sh
ch_con /system/etc/.has_su_daemon
ch_con /system/etc/.installed_su_daemon
ch_con /system/app/Superuser.apk
# Cleanup and reboot
umount /data
umount /system
ui_print "- Rebooting in 10 seconds..."
reboot -f -d 10