-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
238 lines (209 loc) · 9.43 KB
/
Copy pathsetup.sh
File metadata and controls
238 lines (209 loc) · 9.43 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
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
#!/bin/bash
# ============================================================
# setup.sh - Automated Installer for Recon Tool
# CS4240/6240 - Johan Zapata & Nathan Kitchens
# ============================================================
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
# BUG FIX 1: Removed spaces around = (ERRORS = 0 is invalid bash)
ERRORS=0
print_banner() {
echo -e "${CYAN}"
echo " ____ _____ _ "
echo " | _ \ ___ ___ ___ _ __ |_ _|__ ___ | |"
echo " | |_) / _ \/ __/ _ \| '_ \ | |/ _ \ / _ \| |"
echo " | _ < __/ (_| (_) | | | | | | (_) | (_) | |"
echo " |_| \_\___|\___\___/|_| |_| |_|\___/ \___/|_|"
echo ""
echo " Automated Reconnaissance Tool Installer"
echo -e "${NC}"
}
# ── Helpers ──────────────────────────────────────────────────
ok() { echo -e "${GREEN} [✔] $1${NC}"; }
warn() { echo -e "${YELLOW} [!] $1${NC}"; }
fail() { echo -e "${RED} [✘] $1${NC}"; ERRORS=$((ERRORS + 1)); }
info() { echo -e "${CYAN} [*] $1${NC}"; }
run() {
local DESC=$1; shift
info "$DESC"
if eval "$@" >> /tmp/recon_setup.log 2>&1; then
ok "$DESC"
else
fail "$DESC - check /tmp/recon_setup.log for details"
fi
}
check_root() {
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}[✘] Please run as root: sudo ./setup.sh${NC}"
exit 1
fi
}
# ── Installation Steps ────────────────────────────────────────
step_system_update() {
echo -e "\n${YELLOW}── Step 1: System Update ──────────────────────────${NC}"
run "Updating apt package lists" apt update -y
run "Upgrading installed packages" apt upgrade -y
}
step_core_dependencies() {
echo -e "\n${YELLOW}── Step 2: Core Dependencies ──────────────────────${NC}"
run "Installing core dependencies" apt install -y \
curl git python3 python3-pip \
perl libnet-ssleay-perl openssl libssl-dev \
libjson-perl libxml-writer-perl \
libpango-1.0-0 libpangoft2-1.0-0 libharfbuzz0b \
smbclient python3-impacket python3-ldap3
}
step_nmap() {
echo -e "\n${YELLOW}── Step 3: Nmap ────────────────────────────────────${NC}"
run "Installing Nmap" apt install -y nmap
}
step_nikto() {
echo -e "\n${YELLOW}── Step 4: Nikto ───────────────────────────────────${NC}"
if [ -d "/opt/nikto" ]; then
warn "Nikto already installed at /opt/nikto — skipping clone"
else
run "Cloning Nikto from GitHub" \
git clone https://github.com/sullo/nikto.git /opt/nikto
fi
ALIAS_LINE='alias nikto="perl /opt/nikto/program/nikto.pl"'
if ! grep -q "nikto" /etc/bash.bashrc; then
echo "$ALIAS_LINE" >> /etc/bash.bashrc
ok "Nikto alias added to /etc/bash.bashrc"
else
warn "Nikto alias already exists — skipping"
fi
}
step_gobuster() {
echo -e "\n${YELLOW}── Step 5: Gobuster ────────────────────────────────${NC}"
run "Installing Gobuster" apt install -y gobuster
}
step_exploitdb() {
echo -e "\n${YELLOW}── Step 6: ExploitDB / Searchsploit ────────────────${NC}"
if [ -d "/opt/exploitdb" ]; then
warn "ExploitDB already installed at /opt/exploitdb — skipping clone"
else
run "Cloning ExploitDB from GitLab" \
git clone https://gitlab.com/exploit-database/exploitdb.git /opt/exploitdb
fi
if [ -f "/opt/exploitdb/searchsploit" ]; then
ln -sf /opt/exploitdb/searchsploit /usr/local/bin/searchsploit
chmod +x /opt/exploitdb/searchsploit
ok "Searchsploit symlinked to /usr/local/bin"
else
fail "searchsploit binary not found in /opt/exploitdb"
fi
}
step_enum4linux() {
echo -e "\n${YELLOW}── Step 7: enum4linux-ng ───────────────────────────${NC}"
if [ -d "/opt/enum4linux-ng" ]; then
warn "enum4linux-ng already installed — skipping clone"
else
run "Cloning enum4linux-ng from GitHub" \
git clone https://github.com/cddmp/enum4linux-ng.git /opt/enum4linux-ng
fi
run "Installing enum4linux-ng Python requirements" \
pip3 install -r /opt/enum4linux-ng/requirements.txt --break-system-packages
ln -sf /opt/enum4linux-ng/enum4linux-ng.py /usr/local/bin/enum4linux-ng 2>/dev/null
chmod +x /opt/enum4linux-ng/enum4linux-ng.py
ok "enum4linux-ng symlinked to /usr/local/bin"
}
step_python_packages() {
echo -e "\n${YELLOW}── Step 8: Python Packages ─────────────────────────${NC}"
run "Installing Jinja2 and Weasyprint" \
pip3 install jinja2 weasyprint --break-system-packages
}
step_wordlist() {
echo -e "\n${YELLOW}── Step 9: Wordlists ───────────────────────────────${NC}"
# Try apt first
if ! dpkg -l dirb &>/dev/null; then
run "Installing dirb wordlists" apt install -y dirb
fi
# Check both possible locations Ubuntu 24.04 uses
WORDLIST_PATHS=(
"/usr/share/wordlists/dirb/common.txt"
"/usr/share/dirb/wordlists/common.txt"
)
FOUND=0
for PATH_CHECK in "${WORDLIST_PATHS[@]}"; do
if [ -f "$PATH_CHECK" ]; then
ok "Wordlist found at $PATH_CHECK"
FOUND=1
break
fi
done
# BUG FIX 2: curl fallback now correctly places the file and
# verifies it was actually downloaded before marking ok
if [ "$FOUND" -eq 0 ]; then
warn "Wordlist not found via apt — downloading directly..."
mkdir -p /usr/share/wordlists/dirb
curl -sL https://raw.githubusercontent.com/v0re/dirb/master/wordlists/common.txt \
-o /usr/share/wordlists/dirb/common.txt >> /tmp/recon_setup.log 2>&1
if [ -f "/usr/share/wordlists/dirb/common.txt" ]; then
ok "Wordlist downloaded to /usr/share/wordlists/dirb/common.txt"
else
fail "Wordlist download failed — check /tmp/recon_setup.log"
fi
fi
}
step_permissions() {
echo -e "\n${YELLOW}── Step 11: Setting Permissions ────────────────────${NC}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
chmod +x "$SCRIPT_DIR/recon.sh"
chmod +x "$SCRIPT_DIR/modules/"*.sh
ok "Executable permissions set on recon.sh and all modules"
}
# ── Verification ──────────────────────────────────────────────
step_verify() {
echo -e "\n${YELLOW}── Step 10: Verifying Installations ────────────────${NC}"
verify_tool() {
local NAME=$1
local CMD=$2
if eval "$CMD" >> /tmp/recon_setup.log 2>&1; then
ok "$NAME"
else
fail "$NAME — not working correctly"
fi
}
verify_tool "Nmap" "nmap --version"
verify_tool "Nikto" "perl /opt/nikto/program/nikto.pl -Version"
verify_tool "Gobuster" "gobuster version"
# BUG FIX 3: searchsploit -h exits non-zero by design, use || true to prevent false failure
verify_tool "Searchsploit" "searchsploit -h || true"
verify_tool "enum4linux-ng" "python3 /opt/enum4linux-ng/enum4linux-ng.py --help"
verify_tool "Python3" "python3 --version"
verify_tool "Jinja2" "python3 -c 'import jinja2'"
verify_tool "Weasyprint" "python3 -c 'import weasyprint'"
# BUG FIX 4: Removed stray backslash after closing quote, fixed multiline into single string
verify_tool "Wordlist" "test -f /usr/share/wordlists/dirb/common.txt || test -f /usr/share/dirb/wordlists/common.txt"
}
# ── Summary ───────────────────────────────────────────────────
print_summary() {
echo ""
echo -e "${CYAN}════════════════════════════════════════════════════${NC}"
if [ "$ERRORS" -eq 0 ]; then
echo -e "${GREEN} ✔ All tools installed successfully!${NC}"
echo -e "${GREEN} You are ready to run: sudo ./recon.sh -t <TARGET_IP>${NC}"
else
echo -e "${RED} ✘ Setup completed with $ERRORS error(s).${NC}"
echo -e "${YELLOW} Check /tmp/recon_setup.log for details.${NC}"
fi
echo -e "${CYAN}════════════════════════════════════════════════════${NC}\n"
}
# ── Main ──────────────────────────────────────────────────────
print_banner
check_root
step_system_update
step_core_dependencies
step_nmap
step_nikto
step_gobuster
step_exploitdb
step_enum4linux
step_python_packages
step_wordlist
step_verify
step_permissions
print_summary