-
Notifications
You must be signed in to change notification settings - Fork 2
/
patch.sh
executable file
·69 lines (50 loc) · 1.31 KB
/
patch.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
#!/bin/sh
# Script to patch away the screenshot detection in a Snapchat apk; it
# should work as long as Snapchat doesn't drastically change the
# detection mechanism
set -ue
if [ "$#" -ne 1 ]; then
echo "Usage: $0: <file-to-patch.apk>"
exit 1
fi
in_file="$1"
out_file=snapchat-patched.apk
echo "[*] Using '$in_file' as apk to patch"
scratch_dir="$(mktemp -d -t snapchat-patch-XXXXXXXX)"
echo "[*] Using '$scratch_dir' as scratch directory"
echo "[*] decoding apk to scratch directory with apktool"
apktool decode "$in_file" --output "$scratch_dir" --force
detection_file="$(grep -RIl WhatsApp "$scratch_dir")"
echo "[*] Patching file '$detection_file'"
patched_src="$(awk '
BEGIN {
out = 1
sget_count = 0
}
/apply/ {
out = 0
print
print " .locals 0"
print ""
}
/sget-object/ {
sget_count += 1
if (sget_count == 2) {
out = 1
}
}
{
if (out) {
print
}
}
' "$detection_file")"
printf '%s' "$patched_src" > "$detection_file"
echo "[*] Rebuilding apk"
apktool build "$scratch_dir" --output "$out_file"
echo "[*] Removing scratch directory"
rm -rf "$scratch_dir"
echo "[*] Signing apk"
echo 'aaaaaa' \
| jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore \
my-release-key.keystore "$out_file" alias_name