This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathinit
executable file
·192 lines (164 loc) · 4.96 KB
/
init
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/bin/sh
alias cp='cp 2>/dev/null'
alias rm='rm 2>/dev/null'
alias chattr='chattr 2>/dev/null'
alias chown='chown 2>/dev/null'
alias chmod='chmod 2>/dev/null'
ui_reboot() {
ui_print "- Rebooting in 10 seconds..."
reboot -f -d 10
}
# 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 2>/dev/null
}
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"
MODEL=`cat /proc/device-tree/model`
if [ "$MODEL" == "NVIDIA SHIELD" ]; then
MMCDEV=2
SYSTEMPART=4
elif [ "$MODEL" == "Tegra Note 7" ]; then
MMCDEV=0
SYSTEMPART=5
else
ui_print "- Unknown model $MODEL"
ui_print "- Cannot root this device"
ui_reboot
fi
ui_print "\n\n"
ui_print "- Identified $MODEL"
ui_print "\n\n"
ui_print "*****************"
ui_print "SuperSU installer"
ui_print "*****************"
ui_print "- Waiting for partitions to enumerate"
sleep 5
# 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/mmc$MMCDEV\:0001/block/mmcblk?/mmcblk?p$SYSTEMPART/dev |sed 's/:/ /'`
mknod /dev/datapartition b `cat /sys/bus/mmc/devices/mmc$MMCDEV\:0001/block/mmcblk?/mmcblk?p12/dev |sed 's/:/ /'`
if [ ! -b /dev/systempartition -o ! -b /dev/datapartition ]; then
ui_print "- Cannot find system or data partition, aborting..."
ui_reboot
fi
ui_print "- Mounting /system, /data and rootfs"
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/.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/*com.mgyun.shua.su*
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/dalvik-cache/*.oat
rm -f /data/app/com.noshufou.android.su-*
rm -f /data/app/com.koushikdutta.superuser-*
rm -f /data/app/com.mgyun.shua.su-*
rm -f /data/app/eu.chainfire.supersu-*
ui_print "- Creating space"
cp /system/app/Maps.apk /Maps.apk
cp /system/app/GMS_Maps.apk /GMS_Maps.apk
cp /system/app/YouTube.apk /YouTube.apk
rm /system/app/Maps.apk
rm /system/app/GMS_Maps.apk
rm /system/app/YouTube.apk
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
cp $COM/99SuperSUDaemon /system/etc/init.d/99SuperSUDaemon
echo 1 > /system/etc/.installed_su_daemon
ui_print "- Restoring files"
cp /Maps.apk /system/app/Maps.apk
cp /GMS_Maps.apk /system/app/GMS_Maps.apk
cp /YouTube.apk /system/app/YouTube.apk
rm /Maps.apk
rm /GMS_Maps.apk
rm /YouTube.apk
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 0755 /system/xbin/daemonsu
set_perm 0 0 0755 /system/etc/install-recovery.sh
set_perm 0 0 0755 /system/etc/init.d/99SuperSUDaemon
set_perm 0 0 0644 /system/etc/.installed_su_daemon
set_perm 0 0 0644 /system/app/Superuser.apk
set_perm 0 0 0644 /system/app/Maps.apk
set_perm 0 0 0644 /system/app/GMS_Maps.apk
set_perm 0 0 0644 /system/app/YouTube.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/init.d/99SuperSUDaemon
ch_con /system/etc/.installed_su_daemon
ch_con /system/app/Superuser.apk
ch_con /system/app/Maps.apk
ch_con /system/app/GMS_Maps.apk
ch_con /system/app/YouTube.apk
ui_print "- Post-installation script"
/system/xbin/su --install
ui_print "- Unmounting /system and /data"
umount /system
umount /data
ui_print "- Done !"
ui_reboot