-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsetup_linux.sh
executable file
·410 lines (352 loc) · 15 KB
/
setup_linux.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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#!/bin/bash
# shree_hari
# Usecase : setup your device to run anveshan without any errors.
# Usage: Run `bash setup_linux.sh`. [if you have bash shell]
# Usage: Run `zsh setup_linux.sh`. [if you have zsh shell]
# Logs: Logs actions and errors to setup_log.txt
# Current version
current_version="v1.2.0"
# colors
blue=$'\e[34m'
cyan=$'\e[36m'
red=$'\e[91m'
green=$'\e[92m'
yellow=$'\e[93m'
magenta=$'\e[95m'
reset=$'\e[0m'
# print logo
logo() {
echo -e "${green} , ${reset}"
echo -e "${green} ███▓▄,,▄▄▄▓█████▓▄▄, ${reset}"
echo -e "${green} ██████████▀ \`█████████▌_ ${reset}"
echo -e "${green} █████████ ███████████ ${reset}"
echo -e "${green} \"▀▀▀▀\` ████████████ ${reset}"
echo -e "${green} ,,▄▄,,__ ▄████████████ ${reset}"
echo -e "${green} ▄███████████████████████████ ${reset}"
echo -e "${green} ████████████${red}φ▓▓▓▓▓╚${green}██████████ ${reset}"
echo -e "${green} ███████████${red}╫ ╫${green}█████████ ${reset}"
echo -e "${green} ╫██████████${red}▒ ,▓${green}█████████▌ ${reset}"
echo -e "${green} ▀████████ ${red}╬█▄▄╔╔φ${green}████████████ ${reset}"
echo -e "${green} ▀█████${red}╬█${green}████████████████████ ${reset}"
echo -e "${green} ${red}╙▀${green}▀▀▀▀▀▀\`\@hackersthan/█▀ setup_version : ${current_version} ${reset}"
}
# log file to check errors
log_file="setup_log.txt"
exec > >(tee -a "$log_file") 2>&1
logo
# check for latest version
check_for_updates() {
echo -e "${yellow}Checking for updates...${reset}"
local latest_file_version
latest_file_version=$(curl -s https://raw.githubusercontent.com/hackersthan/anveshan/main/setup_linux.sh | grep 'current_version\=' | cut -d '=' -f2 | tr -d ' "')
# Compare versions
if [ "$latest_file_version" != "$current_version" ]; then
if printf '%s\n' "$latest_file_version" "$current_version" | sort -V | head -n1 | grep -q "$current_version"; then
echo -e "${red}A newer version ($latest_file_version) is available!${reset}"
read -p "${red}Would you like to update? [y/n]: ${reset}" update_choice
if [[ "$update_choice" == [Yy] ]]; then
curl -o "$0" https://raw.githubusercontent.com/hackersthan/anveshan/main/setup_linux.sh
echo -e "${green}Updated to version $latest_file_version. Please re-run the script.${reset}"
exit 0
else
echo -e "${yellow}Proceeding with the current version.${reset}"
fi
else
echo -e "${green}You are using the latest version: $current_version${reset}"
echo
fi
else
echo -e "${green}You are using the latest version: $current_version${reset}"
echo
fi
}
check_for_updates
# screen clear
scrclr() {
clear && logo && echo
}
#adding help section
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]]; then
echo "Usage:"
echo -e "${green} bash setup_linux.sh${reset}"
echo "Options:"
echo -e "${green} --help Show this help message${reset}"
exit 0
fi
#* run with sudo
if [ "$(whoami)" != 'root' ]; then
printf "${red}[!] Manually enter your password when asked.${reset}\n"
fi
# function to check golang installed or not
if ! command -v go &>/dev/null; then
printf "${red}[!] GO language is not installed. Installing via apt.${reset}\n"
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt install golang-go
fi
#check GOPATH abd GOROOT
if [ -f ~/.bashrc ]; then
if ! grep -q "export GOPATH=" ~/.bashrc && ! grep -q "export GOROOT=" ~/.bashrc; then
echo "export GOROOT=/usr/local/go" >>~/.bashrc
echo "export GOPATH=\$HOME/go" >>~/.bashrc
echo "export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin" >>~/.bashrc
fi
source ~/.bashrc
elif [ -f ~/.zshrc ]; then
if ! grep -q "export GOPATH=" ~/.zshrc && ! grep -q "export GOROOT=" ~/.zshrc; then
echo "export GOROOT=/usr/local/go" >>~/.zshrc
echo "export GOPATH=\$HOME/go" >>~/.zshrc
echo "export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin" >>~/.zshrc
fi
source ~/.zshrc
else
echo "~/.bashrc or ~/.zshrc not found"
fi
# creating anveshan directory
if [[ -d $HOME/anveshan ]]; then
cd "$HOME/anveshan"
else
mkdir "$HOME/anveshan" && cd "$HOME/anveshan"
fi
# Creating a virtual python environment
sudo apt install -y python3 python3-pip python3-venv || {
echo -e "${red} Failed to install python3-venv. Exiting${reset}"
exit 1
}
VENV_PATH="$HOME/anveshan/venv"
python3 -m venv "$VENV_PATH"
source "$VENV_PATH/bin/activate"
echo "[+] Upgrading pip in the virtual environment..."
pip3 install --upgrade pip
# Check if --break-system-packages is required or not
if pip3 install --help | grep -q -- '--break-system-packages'; then
bsp="--break-system-packages"
else
bsp=""
fi
#Fix `urllib3` and `six` package errors
read -p "removing 'urllib3' and 'six' packages from apt and installing from pip, Confirm? (Y/n): " confirm_uninstall
if [[ "$confirm_uninstall" == "y" || "$confirm_uninstall" == "Y" ]]; then
echo "Uninstalling 'urllib3' and 'six' from apt..."
sudo apt remove -y python3-urllib3 python3-six
echo "Uninstalling 'urllib3' and 'six' from pip3..."
sudo pip3 uninstall -y urllib3 six $bsp
echo "Installing 'urllib3' and 'six' from pip3"
sudo pip3 install urllib3 six $bsp
echo "Packages uninstalled and reinstalled successfully."
else
echo "Skipping uninstallation and installation of urllib3 and six."
fi
# function to upgrade pip packages
echo -e "${magenta}You have $(pip3 list --outdated | grep '[0-9\.[0-9]' | wc -l) outdated pip packages.${reset}"
read -p "${yellow}Do you want to upgrade all of them? (Y/n): ${reset}" answer
if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
printf "${green}[*] Upgrading all pip packages${reset}\n"
pip3 list --outdated | grep "[0-9\.[0-9]" | cut -d " " -f1 | xargs pip3 install --upgrade $bsp
else
printf "${red}[*] Not upgrading.${reset}\n"
fi
# installing basic tools
scrclr
printf "${green}[*] apt update, upgrade and basic tools${reset}\n"
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install pv curl net-tools build-essential
sudo apt -y install python3 python3-pip python3-setuptools python3-dnspython python-dev-is-python3
sudo apt -y install software-properties-common nmap npm parallel ruby-full rename findutils
sudo apt -y install libpcap-dev libcurl4-openssl-dev libxml2 libxml2-dev libxslt1-dev ruby-dev libgmp-dev zlib1g-dev libssl-dev libffi-dev libldns-dev
sudo apt -y install jq git chromium-bsu
#\\\\\\ installing tools //////#
scrclr
printf "${magenta}[*] Installing tools ${reset}\n" | pv -qL 23
sleep 2
#basics
pip3 install uro pipx urless $bsp
go install -v github.com/tomnomnom/anew@latest
#subdomains
pip3 install bbot git+https://github.com/guelfoweb/knock.git $bsp
go install github.com/tomnomnom/assetfinder@latest
go install -v github.com/owasp-amass/amass/v4/...@master
#findomain
if ! command -v findomain &>/dev/null; then
curl -LO https://github.com/findomain/findomain/releases/latest/download/findomain-linux.zip
unzip findomain-linux.zip
chmod +x findomain
sudo mv findomain /usr/bin/findomain
else
echo "[*] findomain is already installed."
fi
#subdomainator
pipx install git+https://github.com/RevoltSecurities/Subdominator
#shrewdeye
if [ ! -d "shrewdeye-bash" ]; then
git clone https://github.com/tess-ss/shrewdeye-bash.git
cd shrewdeye-bash
chmod +x shrewdeye.sh
cd ../
else
echo -e "${red}[*] shrewdeye already installed ${reset}"
fi
#dnsvalidator
if ! command -v dnsvalidator &>/dev/null; then
git clone https://github.com/vortexau/dnsvalidator.git
cd dnsvalidator
pip3 install -r requirements.txt $bsp
python3 setup.py install
cd ../
else
echo -e "${red}[*] dnsvalidator is already installed ${reset}"
fi
#puredns
go install github.com/d3mondev/puredns/v2@latest
#cf-check
go install github.com/dwisiswant0/cf-check@latest
#massdns
if ! command -v massdns &>/dev/null; then
git clone https://github.com/blechschmidt/massdns.git
cd massdns
sudo make
sudo make install
cd ../
else
echo -e "${red}[*] massdns is already installed.${reset}"
fi
#chrome
if ! command -v google-chrome &>/dev/null; then
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb -y
rm google-chrome-stable_current_amd64.deb
else
echo "[*] Chrome is already installed."
fi
#urls
pip3 install waymore $bsp
pip3 install xnLinkFinder $bsp
go install github.com/003random/getJS/v2@latest
go install github.com/hakluke/hakrawler@latest
go install github.com/jaeles-project/gospider@latest
go install github.com/projectdiscovery/katana/cmd/katana@latest
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
go install -v github.com/projectdiscovery/naabu/v2/cmd/naabu@latest
go install github.com/dwisiswant0/cf-check@latest
#paramspider
if [ ! -d "ParamSpider" ]; then
git clone https://github.com/0xKayala/ParamSpider.git
cd ParamSpider
pip3 install -r requirements.txt $bsp
cd ../
else
echo -e "${red}[*] ParamSpider already installed ${reset}"
fi
#nuclei
go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest
nuclei -ut
#trufflehog
if ! command -v google-chrome &>/dev/null; then
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sudo sh -s -- -b /usr/local/bin
else
echo "[*] trufflehog is already installed."
fi
#updating some golang tools
~/go/bin/httpx -up
nuclei -up
katana -up
#\\\\\\\\\\ wordlists /////////#
scrclr
mkdir "wordlists" && cd "wordlists"
# Download wordlists if they don't exist
download_ifnotexist() {
local file="$1"
local url="$2"
if [ ! -f "$file" ]; then
echo -e "${green}[+] Downloading $file ${reset}"
wget -q -O "$file" "$url"
else
echo -e "${red}[*] $file already exists, skipping download. ${reset}"
fi
}
download_ifnotexist "trickest-resolvers.txt" "https://raw.githubusercontent.com/trickest/resolvers/refs/heads/main/resolvers.txt"
download_ifnotexist "six2dez.txt" "https://gist.githubusercontent.com/six2dez/a307a04a222fab5a57466c51e1569acf/raw"
download_ifnotexist "n0kovo-huge-subdomains.txt" "https://raw.githubusercontent.com/n0kovo/n0kovo_subdomains/refs/heads/main/n0kovo_subdomains_huge.txt"
download_ifnotexist "dnscan-top10k.txt" "https://raw.githubusercontent.com/rbsec/dnscan/refs/heads/master/subdomains-10000.txt"
download_ifnotexist "best-dns-wordlist.txt" "https://wordlists-cdn.assetnote.io/data/manual/best-dns-wordlist.txt"
download_ifnotexist "assetfinder-httparchive-subdomains.txt" "https://wordlists-cdn.assetnote.io/data/automated/httparchive_subdomains_2024_05_28.txt"
# Create DNS files if they don't exist
if [ ! -f "dns.txt" ]; then
echo -e "${green} [*] Creating dns.txt ${reset}"
cat best-dns-wordlist.txt six2dez.txt dnscan-top10k.txt | anew dns.txt
else
echo -e "${red}[*] dns.txt already exists, skipping download. ${reset}"
fi
if [ ! -f "dns2.txt" ]; then
echo -e "${green} [*] Creating dns2.txt ${reset}"
cat six2dez.txt dnscan-top10k.txt | anew dns2.txt
else
echo -e "${red}[*] dns2.txt already exists, skipping download. ${reset}"
fi
# save
echo "dns.txt contains best-dns-wordlist.txt, six2dez.txt, and dnscan-top10k.txt." >>readme
echo "dns2.txt contains six2dez.txt and dnscan-top10k.txt." >>readme
rm -f best-dns-wordlist.txt six2dez.txt dnscan-top10k.txt
#\\ downloading config files //#
AMASS_CONFIG_DIR="$HOME/anveshan/.config/amass"
WAYMORE_CONFIG_DIR="$HOME/anveshan/.config/waymore"
# Create directories if they don't exist
mkdir -p "$AMASS_CONFIG_DIR"
mkdir -p "$WAYMORE_CONFIG_DIR"
# Function to download configuration files if they don't exist
download_ifconfignotexist() {
local configfile="$1"
local configurl="$2"
if [ ! -f "$configfile" ]; then
echo -e "${green} [+] Downloading $(basename "$configfile") ${reset}"
wget -q -O "$configfile" "$configurl"
else
echo -e "${red}[*] $(basename "$configfile") already exists, skipping download. ${reset}"
fi
}
download_ifconfignotexist "$AMASS_CONFIG_DIR/datasources.yaml" "https://raw.githubusercontent.com/owasp-amass/amass/refs/heads/master/examples/datasources.yaml"
download_ifconfignotexist "$AMASS_CONFIG_DIR/config.yaml" "https://raw.githubusercontent.com/owasp-amass/amass/refs/heads/master/examples/config.yaml"
download_ifconfignotexist "$WAYMORE_CONFIG_DIR/config.yml" "https://raw.githubusercontent.com/xnl-h4ck3r/waymore/refs/heads/main/config.yml"
#\\\\\\ getting resolvers /////#
scrclr
printf "${magenta}[*] getting fresh resolvers in 120 seconds ${reset}\n" | pv -qL 23
timeout 120 dnsvalidator -tL trickest-resolvers.txt -threads 25 -o resolvers.txt
printf "${yellow}[$] we got $(cat resolvers.txt | wc -l) fresh resolvers${reset}\n" | pv -qL 23
cd ../
sleep 2
#\\\\\\\\\ screen clear ///////#
scrclr
printf "${magenta}You need to add API Keys for [AMASS] [BBOT] [SUBDOMINATOR] in these config files${reset}\n"
printf "${yellow}amass: $HOME/anveshan/.config/amass/datasources.yaml${reset}\n"
printf "${yellow}bbot: $HOME/.config/bbot/secrets.yml${reset}\n"
printf "${yellow}subdominator: $HOME/.config/Subdominator/provider-config.yaml${reset}\n"
echo
printf "${magenta}Also add VIRUSTOTAL and URLSCAN API Keys in waymore config file to get more urls.${reset}\n"
printf "${yellow}waymore: $HOME/anveshan/.config/waymore/config.yml${reset}\n"
echo
read -p "${red}You want to open these files in notepad? [Y/n] ${reset} " apianswer
if [[ "$apianswer" == [Yy] ]]; then
if command -v notepad &>/dev/null; then
editor="notepad"
elif command -v gedit &>/dev/null; then
editor="gedit"
elif command -v nano &>/dev/null; then
editor="nano"
else
printf "${red}No text editor found. Please open these API config files manually.${reset}\n"
exit 1
fi
$editor "$HOME/anveshan/.config/amass/datasources.yaml" \
"$HOME/.config/bbot/secrets.yml" \
"$HOME/.config/Subdominator/provider-config.yaml" \
"$HOME/anveshan/.config/waymore/config.yml"
else
:
fi
echo
printf "${red} script : setup.sh executed succesfully. ${reset}\n"
printf "${yellow} check 'cd $HOME/anveshan' folder.${reset}\n"
printf "${red} [&] Happy Hacking ;D${reset}\n"
#deactivating the python virtual envirnment
deactivate
#iti