-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkey2debug
More file actions
executable file
·84 lines (59 loc) · 2.12 KB
/
key2debug
File metadata and controls
executable file
·84 lines (59 loc) · 2.12 KB
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
#!/bin/bash
#
# title : key2debug
# description : Convert any Android keystore to a debug keystore.
# author : Intellex
# date : 20150902
# version : 0.0.1
# usage : key2debug <path_to_the_keystore>
#===============================================================================
# Definitions {
# Colors
RED=$(tput setaf 1)
CLEAR=$(tput sgr0)
#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ }
# Macros {
# Error handling
ERROR() {
echo "${RED}ERROR: $1${CLEAR}" >&2
exit 2
}
#~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ }
# Get the keystore
KEYSTORE=$1
# Validate keystore
if [ "${KEYSTORE}" = "" ]; then
echo; echo "Usage: keystore2debug <path_to_the_keystore>"; echo "Script will generate additional keystore, it will NOT overwrite exiting one."; echo;
exit 1;
elif [ ! -f "${KEYSTORE}" ]; then
ERROR "Unable to find supplied keystore"
fi
# Create a debug file
DEBUG="${KEYSTORE}.debug"
cp "${KEYSTORE}" "${DEBUG}"
if [ ! $? -eq 0 ]; then
ERROR "Unable to write to ${DEBUG}"
fi
# Read {
# Passphrase
printf "Original passphrase: ";
read PASSPHRASE
# Alias
printf "Original alias: "
read ALIAS
# Alias password
printf "Original alias password: "
read PASSWORD
# }
# Change debug data
# Set new passphrase to 'android'
printf "${PASSPHRASE}\nandroid\nandroid" | keytool -storepasswd -keystore "${DEBUG}" >/dev/null 2>/dev/null
if [ ! $? -eq 0 ]; then ERROR "Unable to unlock the keystore with supplied passphrase"; fi
# Change the alias
printf "android\n${PASSWORD}" | keytool -changealias -keystore ${DEBUG} -alias ${ALIAS} -destalias androiddebugkey >/dev/null 2>/dev/null
if [ ! $? -eq 0 ]; then ERROR "Unable to unlock the keystore with supplied passphrase or bad alias"; fi
# Set new password for alias
printf "android\n${PASSWORD}\nandroid\nandroid" | keytool -keypasswd -keystore "${DEBUG}" -alias androiddebugkey >/dev/null 2>/dev/null
if [ ! $? -eq 0 ]; then ERROR "Bad alias or alias password"; fi
# Print message
echo; echo "Success! Debug keystore saved as ${DEBUG}"; echo;