-
Notifications
You must be signed in to change notification settings - Fork 11
/
install.sh
executable file
·301 lines (224 loc) · 6.44 KB
/
install.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
#!/bin/bash
GoRockPath="gorock"
CurrPath=$(pwd)
# Colors used in printing
Green="\033[0;32m"
Blue="\033[0;34m"
Bold="\033[1m"
Red="\033[0;31m"
NC="\033[0m" # No Color
# use -e flag in print functions to allow backslash escape
print_succeed() {
echo -e "- * - ${Green}${1}${NC}"
}
print_status() {
echo -e "- * - ${Blue}${1}${NC}"
}
print_fail() {
echo -e "- * - ${Red}${1}${NC}"
}
print_indicate() {
echo -e "- * - ${Bold}${1}${NC}"
}
isFileExist() {
[ -f $1 ];
}
isDirExist() {
[ -d "$1" ]
}
isCommandExist() {
# return true if the command exist
[ ! -z $(command -v $1) ]
}
isMac() {
[[ "$OSTYPE" == "darwin"* ]]
}
isDebian() {
isFileExist "/etc/debian_version"
}
isRedhat() {
isFileExist "/etc/redhat-release"
}
isArch() {
isFileExist "/etc/arch-release"
}
InstallUsingAPT() {
apt update -y &>/dev/null
apt install python3 python3-dev python3-pip build-essential gcc -y &>/dev/null
}
InstallUsingYum() {
yum groupinstall "Development Tools" -y &>/dev/null
yum install python3 python3-pip python3-devel gcc -y &>/dev/null
}
InstallUsingPacman() {
pacman -Sy install python python-pip base-devel gcc -y &>/dev/null
}
InstallUsingBrew() {
if brew --version &>/dev/null; then
print_indicate "Brew is already installed"
else
print_status "Try to install brew "
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew update &>/dev/null
brew install bash coreutils python python3-dev gcc &>/dev/null
}
SetupEssentialPackages() {
print_status "Setup essential packages"
if isDebian; then
InstallUsingAPT
elif isRedhat; then
InstallUsingYum
elif isArch; then
InstallUsingPacman
elif isMac; then
InstallUsingBrew
fi
}
InstallGolang() {
rm -rf /usr/local/go
if isMac; then
wget https://go.dev/dl/go1.17.8.darwin-amd64.tar.gz -O golang.tar.gz &>/dev/null
else
wget https://go.dev/dl/go1.17.8.linux-amd64.tar.gz -O golang.tar.gz &>/dev/null
fi
tar -C /usr/local -xzf golang.tar.gz &>/dev/null
rm golang.tar.gz
ln -sf /usr/local/go/bin/go /usr/local/bin/
}
AddGoToProfile() {
user=$(who am i | awk '{print $1}')
home=$(eval echo ~$user)
profile=".$(basename $(echo $SHELL))rc"
export GOROOT=/usr/local/go
export GOPATH=$home/go
export PATH=$GOPATH/bin:$GOROOT/bin:$home/.local/bin:$PATH
cat <<- EOF >> $home/$profile
# Golang vars
export GOROOT=/usr/local/go
export GOPATH=\$HOME/go
export PATH=\$GOPATH/bin:\$GOROOT/bin:\$HOME/.local/bin:\$PATH
EOF
}
SetupGoIfDoesNotExist() {
if ! isCommandExist "go"; then
print_fail "Golang does not exist !!"
print_status "Install Golang"
InstallGolang
if isCommandExist "go"; then
print_succeed "Golang installed successfully"
AddGoToProfile
print_succeed "Golang added to bash profile"
else
print_fail "Golang install Failed !!"
print_indicate "Please try to install golang manual and reinstall again"
exit 1
fi
else
print_indicate "Golang Already installed"
fi
}
SetupSublist3r() {
print_status "Setup sublist3r Dependencies and Libraries"
cd "core/recon/subenum/sublist3r/"
pip3 install -r requirements.txt &>/dev/null
print_succeed "Sublist3r Setup completed successfully"
cd "$CurrPath"
}
SetupPyDependencies() {
print_status "Setup WebRock Dependencies and Libraries"
pip3 install -r requirements.txt &>/dev/null
print_succeed "Setup completed successfully"
}
IsRockRawlerExtInstalled() {
isFileExist "$GoRockPath/ext/RockRawler.a" || isFileExist "$GoRockPath/ext/RockRawler.h"
}
BuildRockRawler() {
print_status "Build RockRawler"
if ! IsRockRawlerExtInstalled; then
cd "$GoRockPath/src/RockRawler"
go build -o ../../ext -buildmode=c-archive RockRawler.go &>/dev/null
cd "$CurrPath"
if IsRockRawlerExtInstalled; then
print_succeed "RockRawler built successfully"
else
print_fail "RockRawler Build Failed"
exit 1
fi
else
print_indicate "RockRawler has already been built before"
fi
}
IsSubFinderExtInstalled() {
isFileExist "$GoRockPath/ext/subfinder.a" || isFileExist "$GoRockPath/ext/subfinder.h"
}
BuildSubFinder() {
print_status "Build SubFinder"
if ! IsSubFinderExtInstalled; then
cd "$GoRockPath/src/subfinder"
go build -o ../../ext -buildmode=c-archive subfinder.go &>/dev/null
cd "$CurrPath"
if IsSubFinderExtInstalled; then
print_succeed "SubFinder built successfully"
else
print_fail "SubFinder Build Failed"
exit 1
fi
else
print_indicate "SubFinder has already been built before"
fi
}
IsFuzzerExtInstalled() {
isFileExist "$GoRockPath/ext/ffuf.a" || isFileExist "$GoRockPath/ext/ffuf.h"
}
BuildFuzzer() {
print_status "Build Fuzzer"
if ! IsFuzzerExtInstalled; then
cd "$GoRockPath/src/ffuf"
go get &>/dev/null
go build -o ../../ext -buildmode=c-archive &>/dev/null
cd "$CurrPath"
if IsFuzzerExtInstalled; then
print_succeed "Fuzzer built successfully"
else
print_fail "Fuzzer Build Failed"
exit 1
fi
else
print_indicate "Fuzzer has already been built before"
fi
}
SetupGoRockExtensions() {
print_status "Setup GoRock Framework Extensions"
if ! isDirExist "$GoRockPath/build"; then
cd $GoRockPath
python3 setup.py install &>/dev/null
cd "$CurrPath"
if isDirExist "$GoRockPath/build"; then
print_succeed "GoRock Framework built successfully"
else
print_fail "an error occured"
print_indicate "Please reinstall or run 'cd $GoRockPath; python3 setup.py install'"
exit 1
fi
else
print_indicate "GoRock Extensions Already installed"
fi
}
BuildGoRockFramework() {
print_status "Build GoRock Framework"
BuildRockRawler
BuildSubFinder
BuildFuzzer
SetupGoRockExtensions
}
if [ "$EUID" -ne 0 ]; then
print_fail "Please run as root"
exit 1
fi
SetupEssentialPackages
SetupGoIfDoesNotExist
SetupPyDependencies
BuildGoRockFramework
SetupSublist3r
print_succeed "WebRock setup completed successfully"