forked from buihien224/Android-14-Remove-APK-Protection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbhlnk.sh
executable file
·129 lines (106 loc) · 2.77 KB
/
bhlnk.sh
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/bash
dir=$(pwd)
repM="python3 $dir/bin/strRep.py"
get_file_dir() {
if [[ $1 ]]; then
sudo find $dir/ -name $1
else
return 0
fi
}
jar_util()
{
if [[ ! -d $dir/jar_temp ]]; then
mkdir $dir/jar_temp
fi
#binary
bak="java -jar $dir/bin/baksmali.jar d"
sma="java -jar $dir/bin/smali.jar a"
if [[ $1 == "d" ]]; then
echo -ne "====> Patching $2 : "
if [[ $(get_file_dir $2 ) ]]; then
sudo mv $(get_file_dir $2 ) $dir/jar_temp
sudo chown $(whoami) $dir/jar_temp/$2
unzip $dir/jar_temp/$2 -d $dir/jar_temp/$2.out >/dev/null 2>&1
if [[ -d $dir/jar_temp/"$2.out" ]]; then
rm -rf $dir/jar_temp/$2
for dex in $(sudo find $dir/jar_temp/"$2.out" -maxdepth 1 -name "*dex" ); do
if [[ $4 ]]; then
if [[ "$dex" != *"$4"* && "$dex" != *"$5"* ]]; then
$bak $dex -o "$dex.out"
[[ -d "$dex.out" ]] && rm -rf $dex
fi
else
$bak $dex -o "$dex.out"
[[ -d "$dex.out" ]] && rm -rf $dex
fi
done
fi
fi
else
if [[ $1 == "a" ]]; then
if [[ -d $dir/jar_temp/$2.out ]]; then
cd $dir/jar_temp/$2.out
for fld in $(sudo find -maxdepth 1 -name "*.out" ); do
if [[ $4 ]]; then
if [[ "$fld" != *"$4"* && "$fld" != *"$5"* ]]; then
echo $fld
$sma $fld -o $(echo ${fld//.out})
[[ -f $(echo ${fld//.out}) ]] && rm -rf $fld
fi
else
$sma $fld -o $(echo ${fld//.out})
[[ -f $(echo ${fld//.out}) ]] && rm -rf $fld
fi
done
7za a -tzip -mx=0 $dir/jar_temp/$2_notal $dir/jar_temp/$2.out/. >/dev/null 2>&1
#zip -r -j -0 $dir/jar_temp/$2_notal $dir/jar_temp/$2.out/.
zipalign -p -v 4 $dir/jar_temp/$2_notal $dir/jar_temp/$2 >/dev/null 2>&1
if [[ -f $dir/jar_temp/$2 ]]; then
rm -rf $dir/jar_temp/$2.out $dir/jar_temp/$2_notal
#sudo cp -rf $dir/jar_temp/$2 $(get_file_dir $2)
echo "Succes"
else
echo "Fail"
fi
fi
fi
fi
}
repM () {
if [[ $4 == "r" ]]; then
if [[ -f $3 ]]; then
$repM $1 $2 $3
fi
elif [[ $4 == "f" ]]; then
for i in $3; do
$repM $1 $2 $i
done
else
file=$(sudo find -name $3)
if [[ $file ]]; then
$repM $1 $2 $file
fi
fi
}
framework() {
jar_util d 'framework.jar' fw classes4 classes5
repM 'getMinimumSignatureSchemeVersionForTargetSdk' true ApkSignatureVerifier.smali
jar_util a 'framework.jar' fw classes4 classes5
}
services() {
jar_util d "services.jar" fw
repM 'isPlatformSigned' true 'PackageManagerService$PackageManagerInternalImpl.smali'
repM 'isSignedWithPlatformKey' true 'PackageImpl.smali'
jar_util a "services.jar" fw
}
if [[ ! -d $dir/jar_temp ]]; then
mkdir $dir/jar_temp
fi
framework
#services
if [ -f $dir/jar_temp/framework.jar ]; then
sudo cp -rf $dir/jar_temp/*.jar $dir/module/system/framework
else
echo "Fail to copy framework"
fi