-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwapk
executable file
·97 lines (77 loc) · 2.16 KB
/
wapk
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
#!/bin/bash
####
#### Copyright (C) 2019 wuseman <[email protected]> - All Rights Reserved
#### Created: 2019-02-19
####
usage() {
cat << EOF
wadb-extractor.sh is a tool for facialiate the work with apk files from command-line
where:
-c|--compress | Repack your modded apk files
-e|--extract | Extract any APK file
-h|--help | Print this help and exit
-s|--sign | Sign APK file
EOF
}
key() {
if [[ ! -f $HOME/.wapk/wapk.keystore ]]; then
printf "You must create a key to sign the apk..\n"
mkdir -p ~/.andrid/
keytool -genkey -v -keystore wapk.keystore -alias wapk -keyalg RSA -keysize 4096 -validity 10000
fi
}
extractapk() {
key
read -p "APK To extract: " apk
if [[ -z $apk ]]; then
printf "You must provide a real .apk file..\n"
else
printf "Extracting $apk, please wait\n"
apktool d -r -s $apk &> /dev/null
printf "Extracted $(echo $apk | sed 's/.apk//g') successfully..\n"
fi
}
compressapk() {
read -p "Path to compress: " apkcompress
if [[ -z $apkcompress ]]; then
printf "You must provide a path name..\n"
else
printf "Compressing $apkcompress, please wait\n"
apktool b -f -d $apkcompress &> /dev/null
printf "Compressed $(echo $apkcompress | sed 's/.apk//g') successfully..\n"
printf "You can sign $apkcompress.apk now.."
fi
mv $apkcompress/dist/*.apk .
}
signapk() {
read -p "APK To Sign: " apksign
printf "Please wait, trying to sign $apksign\n"
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore wuseman.keystore $apksign wuseman
if [[ $? -eq 0 ]]; then
printf "\nSuccessfully signed $apksign\n\n"
read -p "Do you want to install $apksign (y/n): " installapk
if [[ $installapk = "y" ]]; then
echo "Please wait, installing $apksign\n"
adb install $installapk
printf "Successfully installed $installapk\n"
exit
else
sleep 0
fi
fi
}
key
if [[ -z $1 ]]; then
usage
fi
while getopts ":ecshv" getopt; do
case $getopt in
-c) compressapk ;;
-e) extractapk ;;
-s) signapk ;;
-h) usage ;;
-v) echo Version: $version ;;
-*) echo "Duh! $OPTARG is not a valid option" ;;
esac
done
shift $((OPTIND-1))