-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautozerocert
52 lines (49 loc) · 2.18 KB
/
autozerocert
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
#!/bin/bash
wget 127.0.0.1:8080/cert
mv cert cacert.der
openssl x509 -inform DER -in cacert.der -out cacert.pem
c=$(openssl x509 -inform PEM -subject_hash_old -in cacert.pem | head -1)
mv cacert.pem $c.0
#method mount 1
adb remount
adb shell 'su root -c mount -o rw,remount /system'
adb push $c.0 /data/local/tmp/
adb shell "chmod 644 /data/local/tmp/$c.0 && su root -c mv /data/local/tmp/$c.0 /system/etc/security/cacerts/"
check='if [ -f "/system/etc/security/cacerts/'$c'.0" ]; then echo lol;fi'
check2=$(adb shell $check)
if [ "$check2" = "lol" ]; then
echo "certificate successfully installed"
else
#method mount 2
echo "certificate failed to install with method-1, trying method-2 ... "
d=$(adb shell "cat /proc/mounts | grep system | grep -v magisk" | awk '{print $3}')
e=$(adb shell "cat /proc/mounts | grep system | grep -v magisk" | awk '{print $2}')
f=$(adb shell "cat /proc/mounts | grep system | grep -v magisk" | awk '{print $1}')
adb shell su root -c mount -o rw,remount -t $d $f $e
adb push $c.0 /data/local/tmp/
adb shell "chmod 644 /data/local/tmp/$c.0 && su root -c mv /data/local/tmp/$c.0 /system/etc/security/cacerts/"
check='if [ -f "/system/etc/security/cacerts/'$c'.0" ]; then echo lol;fi'
check2=$(adb shell $check)
if [ "$check2" = "lol" ]; then
echo "certificate successfully installed"
else
#method mount 3
echo "certificate failed to install with method-2, trying method-3 ... "
adb shell 'mkdir /sdcard/tesdodol'
adb push $c.0 /sdcard/tesdodol/$c.0
adb shell "su root cp /system/etc/security/cacerts/* /sdcard/tesdodol/"
adb shell "su root mount -t tmpfs tmpfs /system/etc/security/cacerts"
adb shell "su root mv /sdcard/tesdodol/* /system/etc/security/cacerts/"
adb shell "su root chown root:root /system/etc/security/cacerts/*"
adb shell "su root chmod 644 /system/etc/security/cacerts/*"
adb shell "su root chcon u:object_r:system_file:s0 /system/etc/security/cacerts/*"
adb shell "su root rm -r /sdcard/tesdodol/"
check='if [ -f "/system/etc/security/cacerts/'$c'.0" ]; then echo lol;fi'
check2=$(adb shell $check)
if [ "$check2" = "lol" ]; then
echo "certificate successfully installed"
else
echo "certificate failed to installed"
fi
fi
fi