forked from Map-A-Droid/MAD-ATV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
16mad
273 lines (257 loc) · 14.3 KB
/
16mad
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#!/system/bin/sh
#This is for update_mad version
uver="4.0"
#This is for pingreboot version
pver="2.0"
#This is for nfs install script
nver="1.2"
# mad rom version
madver="1.3.7"
#magisk version / url
mver="20.3"
murl="https://github.com/Map-A-Droid/MAD-ATV/raw/master/Magisk-v20.3.zip"
msum="959e46971c2eb500b91a053b2f1c1a8c"
/system/bin/sh /system/bin/pingreboot.sh &
until ping -c1 8.8.8.8 >/dev/null 2>/dev/null; do sleep 10 ;done
rm -rf /sdcard/TWRP
useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3"
download(){
# $1 = url
# $2 = local path
# lets see that curl exits successfully
until /system/bin/curl -s -k -L -A "$useragent" -o "$2" "$1" ;do
sleep 15
done
}
if [ ! -f /system/priv-app/RemoteGpsController.apk ]; then
until [[ $(pm list packages com.mad.pogodroid) ]]; do
download https://raw.githubusercontent.com/Map-A-Droid/MAD-ATV/master/16mad /etc/init.d/16mad && chmod +x /etc/init.d/16mad
download "https://www.maddev.eu/apk/PogoDroid.apk" "/sdcard/pogodroid.apk"
/system/bin/chmod 644 /sdcard/pogodroid.apk
/system/bin/pm install /sdcard/pogodroid.apk
/system/bin/rm /sdcard/pogodroid.apk
sleep 1
done
download "https://raw.githubusercontent.com/Map-A-Droid/MAD/master/APK/RemoteGpsController.apk" "/system/priv-app/RemoteGpsController.apk"
/system/bin/chmod 644 /system/priv-app/RemoteGpsController.apk
/system/bin/chown root:root /system/priv-app/RemoteGpsController.apk
fi
madmodel="$(grep ro.product.board /system/build.prop |awk -F'=' '{print $2}'|tr '[:upper:]' '[:lower:]')"
if [[ "$madmodel" == s905w ]] ;then
if grep ro.build.description /system/build.prop |grep -q p281; then
if grep ro.build.display.id /system/build.prop |grep -q v2H ;then
madmodel="t95s1"
elif grep ro.build.display.id /system/build.prop |grep -q v2FF ;then
madmodel="s905w"
else
unset madmodel
fi
else
unset madmodel
fi
elif [[ "$madmodel" == s905x ]] ;then
if grep ro.build.description /system/build.prop |grep -q q201; then
madmodel="s912"
elif grep ro.build.description /system/build.prop |grep -q p212 ;then
madmodel="s905x"
else
unset madmodel
fi
elif [[ "$madmodel" == s912lp ]] ;then
if grep ro.build.description /system/build.prop |grep -q q201; then
madmodel="s912lp"
else
unset madmodel
fi
else
unset madmodel
fi
[[ "$madmodel" ]] && [[ "$madmodel" != "t95s1" ]] && madrom=1
download_smali(){
[[ "$madmodel" ]] && download "https://github.com/Map-A-Droid/MAD-ATV/raw/master/smali/smali-${madmodel}.zip" /sdcard/smali.zip
}
install_magisk(){
if [[ "$madrom" ]] ;then
download "$murl" /sdcard/magisk.zip
mkdir -p /cache/recovery
touch /cache/recovery/command
echo '--update_package=/sdcard/magisk.zip' >> /cache/recovery/command
download_smali
echo '--update_package=/sdcard/smali.zip' >> /cache/recovery/command
echo '--wipe_cache' >> /cache/recovery/command
reboot recovery
elif [[ "$madmodel" == "t95s1" ]]; then
download "$murl" /sdcard/magisk.zip
download_smali
fi
}
if [ -f /sbin/magiskhide ]; then
/sbin/magiskhide --add com.nianticlabs.pokemongo
[[ -f /sdcard/magisk.zip ]] && rm /sdcard/magisk.zip
[[ -f /sdcard/smali.zip ]] && rm /sdcard/smali.zip
#make sure rgc and pogodroid and shell have su root
puser=$(ls -la /data/data/com.mad.pogodroid/|head -n2|tail -n1|awk '{print $3}' 2>/dev/null)
puid=$(id -u "$puser")
ruser=$(ls -la /data/data/de.grennith.rgc.remotegpscontroller/|head -n2|tail -n1|awk '{print $3}')
ruid=$(id -u "$ruser")
suid=$(id -u shell)
pol=$(sqlite3 /data/adb/magisk.db "select policy from policies where package_name='de.grennith.rgc.remotegpscontroller'")
if [[ "$pol" != 2 ]] ;then
sqlite3 /data/adb/magisk.db "DELETE from policies WHERE package_name='de.grennith.rgc.remotegpscontroller'"
sqlite3 /data/adb/magisk.db "INSERT INTO policies (uid,package_name,policy,until,logging,notification) VALUES($ruid,'de.grennith.rgc.remotegpscontroller',2,0,1,1)"
fi
pol=$(sqlite3 /data/adb/magisk.db "select policy from policies where package_name='com.mad.pogodroid'")
if [[ "$pol" != 2 ]] ;then
sqlite3 /data/adb/magisk.db "DELETE from policies WHERE package_name='com.mad.pogodroid'"
sqlite3 /data/adb/magisk.db "INSERT INTO policies (uid,package_name,policy,until,logging,notification) VALUES($puid,'com.mad.pogodroid',2,0,1,1)"
fi
pol=$(sqlite3 /data/adb/magisk.db "select policy from policies where package_name='com.android.shell'")
if [[ "$pol" != 2 ]] ;then
sqlite3 /data/adb/magisk.db "DELETE from policies WHERE package_name='com.android.shell'"
sqlite3 /data/adb/magisk.db "INSERT INTO policies (uid,package_name,policy,until,logging,notification) VALUES($suid,'com.android.shell',2,0,1,1)"
fi
if [[ "$madrom" ]] && ! magisk -c|grep -q "$mver" ;then
touch /sdcard/madupdating
install_magisk
elif [ -f /sdcard/madupdating ] ;then
pm uninstall com.topjohnwu.magisk
rm /sdcard/madupdating
fi
else
install_magisk
fi
# Back to smali, lets disable mocking.
pdconf="/data/data/com.mad.pogodroid/shared_prefs/com.mad.pogodroid_preferences.xml"
if grep 'switch_enable_mock_location_patch' "$pdconf"|grep -q true ;then
sed -i 's,"switch_enable_mock_location_patch" value="true","switch_enable_mock_location_patch" value="false",g' "$pdconf"
chmod 660 "$pdconf"
puser=$(ls -la /data/data/com.mad.pogodroid/|head -n2|tail -n1|awk '{print $3}' 2>/dev/null)
chown "$puser":"$puser" "$pdconf"
fi
# install smali if its not installed and download_smali exits success
# we trick t95s1 into downloading but not using the file with this
if [[ "$madmodel" ]] && ! ls -lL /sbin/.magisk/img | grep -q smali && download_smali && [[ "$madrom" ]] ;then
mkdir -p /cache/recovery/
echo '--update_package=/sdcard/smali.zip' > /cache/recovery/command
echo '--wipe_cache' >> /cache/recovery/command
reboot recovery
fi
#cec says that turning off cec helps... i guess he was too turned on?
! [[ $(settings get global hdmi_control_enabled) == "0" ]] && settings put global hdmi_control_enabled 0
[[ "$(/system/bin/getprop persist.sys.app.rotation)" != "middle_port" ]] && /system/bin/setprop persist.sys.app.rotation middle_port
! [[ $(settings get global stay_on_while_plugged_in) == 3 ]] && settings put global stay_on_while_plugged_in 3
[ "$(/system/bin/appops get de.grennith.rgc.remotegpscontroller android:mock_location)" = "No operations." ] && /system/bin/appops set de.grennith.rgc.remotegpscontroller android:mock_location allow
! settings get secure location_providers_allowed|grep -q gps && settings put secure location_providers_allowed +gps
if ! dumpsys package com.nianticlabs.pokemongo|grep ACCESS_FINE_LOCATION|grep granted|grep -q 'granted=true' ;then
pm grant com.nianticlabs.pokemongo android.permission.ACCESS_FINE_LOCATION
pm grant com.nianticlabs.pokemongo android.permission.ACCESS_COARSE_LOCATION
pm grant com.nianticlabs.pokemongo android.permission.CAMERA
pm grant com.nianticlabs.pokemongo android.permission.GET_ACCOUNTS
fi
if ! dumpsys package com.mad.pogodroid |grep READ_EXTERNAL_STORAGE|grep granted|grep -q 'granted=true' ;then
pm grant com.mad.pogodroid android.permission.READ_EXTERNAL_STORAGE
pm grant com.mad.pogodroid android.permission.WRITE_EXTERNAL_STORAGE
fi
if ! dumpsys package de.grennith.rgc.remotegpscontroller|grep ACCESS_FINE_LOCATION|grep granted|grep -q 'granted=true' ;then
pm grant de.grennith.rgc.remotegpscontroller android.permission.ACCESS_FINE_LOCATION
pm grant de.grennith.rgc.remotegpscontroller android.permission.READ_EXTERNAL_STORAGE
pm grant de.grennith.rgc.remotegpscontroller android.permission.ACCESS_COARSE_LOCATION
pm grant de.grennith.rgc.remotegpscontroller android.permission.WRITE_EXTERNAL_STORAGE
fi
echo "$madver" > /sdcard/madversion
! grep -q "version $uver" /system/bin/update_mad.sh && download https://raw.githubusercontent.com/Map-A-Droid/MAD-ATV/master/update_mad.sh /system/bin/update_mad.sh && chmod +x /system/bin/update_mad.sh
! grep -q "version $pver" /system/bin/pingreboot.sh && download https://raw.githubusercontent.com/Map-A-Droid/MAD-ATV/master/pingreboot.sh /system/bin/pingreboot.sh && chmod +x /system/bin/pingreboot.sh
! grep -q "version $nver" /system/bin/nfs_install.sh && download https://raw.githubusercontent.com/Map-A-Droid/MAD-ATV/master/nfs_install.sh /system/bin/nfs_install.sh && chmod +x /system/bin/nfs_install.sh
# Fix for a95xf1 eth0 mac address issue. Also a tool for people who wish to control their MAC
# To fix a95xf1 we will save our random mac in /sdcard/madmac and if the user wants to change it they may
if [[ -e /sdcard/madmac ]] ;then
newmac=$(cat /sdcard/madmac)
ifconfig eth0 down
ifconfig eth0 hw ether "$newmac"
ifconfig eth0 up
elif [[ "$(ifconfig eth0|awk '/HWaddr/{print $5}')" == "00:15:18:01:81:31" ]] ;then
newmac=$(xxd -l 6 -p /dev/urandom |sed 's/../&:/g;s/:$//')
ifconfig eth0 down
until ifconfig eth0 hw ether "$newmac" 2>/dev/null; do
newmac=$(xxd -l 6 -p /dev/urandom |sed 's/../&:/g;s/:$//')
done
ifconfig eth0 up
echo "$newmac" > /sdcard/madmac
fi
#In case you want to set mac on wifi interface
if [[ -e /sdcard/madmac2 ]] ;then
newmac=$(cat /sdcard/madmac2)
ifconfig wlan0 down
ifconfig wlan0 hw ether "$newmac"
ifconfig wlan0 up
fi
until ping -c1 8.8.8.8 >/dev/null 2>/dev/null; do sleep 10 ;done
#enable autoupdates of pogo, pogodroid, and rgc:
# This checks if your madmin wizard has an updated version of pogo. If it does then it updates pogo.
! [[ -f /sdcard/disableautopogoupdate ]] && /system/bin/update_mad.sh -p
! [[ -f /sdcard/disableautopogodroidupdate ]] && /system/bin/update_mad.sh -wd
! [[ -f /sdcard/disableautorgcupdate ]] && /system/bin/update_mad.sh -wr
# this stuff should check for a USB stick and if there is one it looks for:
# madorigin.txt - put nothing in this file except the origin to configure for pogo/rgc
# com.mad.pogodroid_preferences.xml - config file from the first working box which you setup by hand. do not edit, get it from:
## /data/data/com.mad.pogodroid/shared_prefs/com.mad.pogodroid_preferences.xml
# de.grennith.rgc.remotegpscontroller_preferences.xml - config file from the first working box which you setup by hand. do not edit, get it from:
## /data/data/de.grennith.rgc.remotegpscontroller/shared_prefs/de.grennith.rgc.remotegpscontroller_preferences.xml
pdconf="/data/data/com.mad.pogodroid/shared_prefs/com.mad.pogodroid_preferences.xml"
usbfile="$(find /mnt/media_rw/ -name com.mad.pogodroid_preferences.xml|head -n1)"
usbofile="$(find /mnt/media_rw/ -name madorigin.txt|head -n1)"
if [[ "$usbfile" != "" ]] && [ -d /data/data/com.mad.pogodroid ] ;then
if ! [ -f "$pdconf" ] || [[ $(awk -F'>' '/"post_destination"/{print $2}' "$pdconf"|cut -d'<' -f1) == "" ]] ;then
newserial="$(getprop|awk '/serialno/{print $2}'|head -n1|sed -e 's,\[,,' -e 's,\],,')"
[[ "$newserial" == "" ]] && newserial="$(ifconfig wlan0|grep -q inet && ifconfig wlan0|awk '/HWaddr/{print $5}')"
[[ "$newserial" == "" ]] && newserial="$(ifconfig eth0|grep -q inet && ifconfig eth0|awk '/HWaddr/{print $5}')"
oldserial="$(awk -F'>' '/auth_id/{print $2}' "$usbfile"|cut -d'<' -f1)"
oldorigin="$(awk -F'>' '/post_origin/{print $2}' "$usbfile"|cut -d'<' -f1)"
injtime="$(awk -F'>' '/last_time_injected/{print $2}' "$usbfile"|cut -d'<' -f1)"
sessionid="$(awk -F'>' '/session_id/{print $2}' "$usbfile"|cut -d'<' -f1)"
[ -f "$usbofile" ] && neworigin=$(sed -n -e 1p -e 's,\n,,' -e 's,\r,,' "$usbofile") || neworigin=""
pdir="/data/data/com.mad.pogodroid/shared_prefs"
puser=$(ls -la /data/data/com.mad.pogodroid/|head -n2|tail -n1|awk '{print $3}')
! [ -d "$pdir" ] && mkdir "$pdir" && chmod 771 "$pdir" && chown "$puser":"$puser" "$pdir"
sed -e "s,$oldserial,$newserial,g" -e "s,$sessionid,,g" -e "s,$injtime,,g" -e "s,$oldorigin,$neworigin,g" "$usbfile" > "$pdconf"
chmod 660 "$pdconf" && chown "$puser":"$puser" "$pdconf"
/system/bin/update_mad.sh -p && sleep 10 && reboot
fi
fi
rgcconf="/data/data/de.grennith.rgc.remotegpscontroller/shared_prefs/de.grennith.rgc.remotegpscontroller_preferences.xml"
usbfile="$(find /mnt/media_rw/ -name de.grennith.rgc.remotegpscontroller_preferences.xml|head -n1)"
if [[ "$usbfile" != "" ]] && [ -d /data/data/de.grennith.rgc.remotegpscontroller ];then
if ! [ -f "$rgcconf" ] || [[ $(awk -F'>' '/websocket_uri/{print $2}' "$rgcconf"|cut -d'<' -f1) == "ws://" ]] ;then
oldorigin="$(awk -F'>' '/origin/{print $2}' "$usbfile"|cut -d'<' -f1)"
[ -f "$usbofile" ] && neworigin=$(sed -n -e 1p -e 's,\n,,' -e 's,\r,,' "$usbofile") || neworigin=""
pdir="/data/data/de.grennith.rgc.remotegpscontroller/shared_prefs"
puser=$(ls -la /data/data/de.grennith.rgc.remotegpscontroller/|head -n2|tail -n1|awk '{print $3}')
! [ -d "$pdir" ] && mkdir "$pdir" && chmod 771 "$pdir" && chown "$puser":"$puser" "$pdir"
sed -e "s,$oldorigin,$neworigin,g" "$usbfile" > "$rgcconf"
chmod 660 "$rgcconf" && chown "$puser":"$puser" "$rgcconf"
fi
fi
if [[ -f "$pdconf" ]] ;then
origin="$(awk -F'>' '/post_origin/{print $2}' "$pdconf"|cut -d'<' -f1)"
pduser="$(grep -v raw "$pdconf"|awk -F'>' '/auth_username/{print $2}'|awk -F'<' '{print $1}')"
pdpass="$(grep -v raw "$pdconf"|awk -F'>' '/auth_password/{print $2}'|awk -F'<' '{print $1}')"
pdauth="$pduser:$pdpass"
pdserver="$(grep -v raw "$pdconf"|awk -F'>' '/post_destination/{print $2}'|awk -F'<' '{print $1}')"
if [[ "$origin" ]] && [[ "$(/system/bin/curl -s -k -L -o /dev/null -w "%{http_code}" --user "$pdauth" -H "origin: $origin" "${pdserver}/autoconfig/mymac")" == "200" ]] ;then
all_macs="$(/system/bin/curl -s -k -L --user "$pdauth" -H "origin: $origin" "${pdserver}/autoconfig/mymac")"
interface="$(sed -n 1p <<< "$all_macs")"
mac="$(sed -n 2p <<< "$all_macs")"
if ifconfig|grep -A5 wlan0|grep -q inet ;then
current_mac=$(ifconfig wlan0|awk '/HWaddr/{print $5}')
elif ifconfig|grep -A5 eth0|grep -q inet ;then
current_mac=$(ifconfig eth0|awk '/HWaddr/{print $5}')
fi
echo "MAD-assigned MAC: \"$mac\""
echo "Current MAC: \"$current_mac\""
if ! [[ "$mac" ]] && [[ "$current_mac" ]] ;then
/system/bin/curl -s -k -L --user "$pdauth" -H 'Content-Type: text/html' -H "origin: $origin" "${pdserver}/autoconfig/mymac" -d "$current_mac"
fi
else
echo "After you change branches to 64bit_autoconf this will set your MAC in madmin"
fi
fi