-
Notifications
You must be signed in to change notification settings - Fork 56
/
setup.sh
executable file
·130 lines (104 loc) · 3.99 KB
/
setup.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
129
130
#! /bin/bash
function log(){
echo "[+]" $1;
}
function error(){
echo "[-] " $1;
}
function die(){
error $1;
exit 1;
}
# Guess SHELLrc file
SHELL_NAME=$(echo $SHELL | awk -F"/" '{print $NF}');
SHELL_RC=$HOME/.$SHELL_NAME"rc";
function install(){
log "Installing Dependencies";
ORIGINAL_PWD=$(pwd)
# install jd-cli
if [ ! -x "$(command -v jd-cli)" ]; then
curl -L -o /tmp/jdcli.zip https://github.com/kwart/jd-cmd/releases/download/jd-cmd-0.9.2.Final/jd-cli-0.9.2-dist.zip
unzip /tmp/jdcli.zip /usr/local/share/jd-cli
ln -s /usr/local/share/jd-cli/jd-cli /usr/local/bin/jd-cli
ln -s /usr/local/share/jd-cli/jd-cli.jar /usr/local/bin/jd-cli.jar
rm -rf /tmp/jdcli.zip
fi
# install apktool
if [ ! -x "$(command -v apktool)" ]; then
mkdir /usr/local/share/apktool
curl -L -o /usr/local/share/apktool/apktool https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/osx/apktool
curl -L -o /usr/local/share/apktool/apktool.jar https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.3.3.jar
chmod +x /usr/local/share/apktool /usr/local/share/apktool/apktool.jar
ln -s /usr/local/share/apktool /usr/local/bin/apktool
ln -s /usr/local/share/apktool.jar /usr/local/bin/apktool.jar
fi
# install dex2jar
if [ ! -x "$(command -v d2j-dex2jar.sh)" ]; then
curl -L -o /tmp/d2j.zip https://github.com/pxb1988/dex2jar/files/1867564/dex-tools-2.1-SNAPSHOT.zip
unzip /tmp/d2j.zip -d /tmp/d2j
dirname=$(ls --color=none /tmp/d2j)
mv /tmp/d2j/$dirname /usr/local/share/d2j-dex2jar
ln -s /usr/local/share/d2j-dex2jar/d2j-dex2jar.sh /usr/local/bin/d2j-dex2jar.sh
ln -s /usr/local/share/d2j-dex2jar/d2j-apk-sign.sh /usr/local/bin/d2j-apk-sign.sh
rm -rf /tmp/d2j.zip
fi
if [ ! -x "$(command -v d2j-dex2jar)" ]; then
ln -s $(command -v d2j-dex2jar.sh) /usr/local/bin/d2j-dex2jar
fi
# install adb
if [ ! -x "$(command -v adb)" ]; then
curl -L -o /tmp/platform-tools.zip https://dl.google.com/android/repository/platform-tools-latest-$1.zip
unzip /tmp/platform-tools.zip -d /tmp/pt
mv /tmp/pt/platform-tools /usr/local/share/
ln -s /usr/local/share/platform-tools/adb /usr/local/bin/adb
ln -s /usr/local/share/platform-tools/fastboot /usr/local/bin/fastboot
fi
if [[ "$2" == 'Linux' ]]; then
# install ldid
if [ ! -x "$(command -v ldid)" ]; then
git clone https://github.com/daeken/ldid.git /tmp/ldid
cd /tmp/ldid
./make.sh
mv ldid /usr/local/bin/
cd /tmp
rm -rf /tmp/ldid
fi
# install jtool
if [ ! -x "$(command -v jtool)" ]; then
curl -L -o /tmp/jtool.tar http://www.newosxbook.com/tools/jtool.tar
mkdir /tmp/jtool
tar xvf /tmp/jtool.tar -C /tmp/jtool
mv /tmp/jtool/jtool.ELF64 /usr/local/bin/jtool
rm -rf /tmp/jtool.tar /tmp/jtool
fi
# install other dependencies
apt update
apt install libimobiledevice libusbmuxd-tools usbutils
if [ ! -x "$(command -v java)" ]; then
apt install openjdk-10-jdk
fi
elif [[ "$2" == 'Darwin' ]]; then
# checks if brew exists
command -v brew || die "Could not find 'brew' to install dependencies"
brew update
# iproxy, ldid
brew install libimobiledevice ldid
# lsusb
brew tap jlhonora/lsusb
brew install lsusb
# otool
log "Installing and accepting Xcode - Will require password"
sudo xcode-select --install
sudo xcodebuild -license accept
fi
cd $ORIGINAL_PWD;
}
function update_shrc(){
log "Checking if /usr/local/bin in PATH"
if [[ ! $PATH = *"/usr/local/bin"* ]]; then
log "Adding /usr/local/bin to PATH on $1"
echo "PATH=$PATH:/usr/local/bin" >> $1
fi
}
install $(uname)
update_shrc $SHELL_RC