-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·350 lines (308 loc) · 14.1 KB
/
install.sh
File metadata and controls
executable file
·350 lines (308 loc) · 14.1 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
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
#!/usr/bin/env bash
# ═══════════════════════════════════════════════════════════════════════════════
# HackBot — Universal Installer for Linux & macOS
# ═══════════════════════════════════════════════════════════════════════════════
set -euo pipefail
VERSION="1.2.3"
REPO="yashab-cyber/hackbot"
BOLD='\033[1m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
YELLOW='\033[0;33m'
RED='\033[0;31m'
NC='\033[0m'
banner() {
echo -e "${GREEN}"
echo " ╦ ╦╔═╗╔═╗╦╔═╔╗ ╔═╗╔╦╗"
echo " ╠═╣╠═╣║ ╠╩╗╠╩╗║ ║ ║ "
echo " ╩ ╩╩ ╩╚═╝╩ ╩╚═╝╚═╝ ╩ "
echo -e "${NC}"
echo -e "${CYAN} AI Cybersecurity Assistant — Installer v${VERSION}${NC}"
echo -e " ─────────────────────────────────────────────"
echo -e " ${BOLD}Developed by Yashab Alam${NC}"
echo -e " GitHub: ${CYAN}https://github.com/yashab-cyber${NC}"
echo -e " LinkedIn: ${CYAN}https://www.linkedin.com/in/yashab-alam${NC}"
echo -e " Email: yashabalam707@gmail.com | yashabalam9@gmail.com"
echo -e " ─────────────────────────────────────────────"
echo -e " ${RED}❤️ Support HackBot → https://github.com/yashab-cyber/hackbot/blob/main/DONATE.md${NC}"
echo ""
}
info() { echo -e "${CYAN}[INFO]${NC} $1"; }
success() { echo -e "${GREEN}[OK]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
# ── Detect OS ────────────────────────────────────────────────────────────────
detect_os() {
case "$(uname -s)" in
Linux*) OS="linux";;
Darwin*) OS="macos";;
CYGWIN*|MINGW*|MSYS*) OS="windows";;
*) error "Unsupported OS: $(uname -s)";;
esac
case "$(uname -m)" in
x86_64|amd64) ARCH="amd64";;
aarch64|arm64) ARCH="arm64";;
*) ARCH="$(uname -m)";;
esac
info "Detected: ${OS} (${ARCH})"
}
# ── Check Python ─────────────────────────────────────────────────────────────
check_python() {
if command -v python3 &>/dev/null; then
PYTHON="python3"
elif command -v python &>/dev/null; then
PYTHON="python"
else
error "Python 3.9+ is required. Install it first:
Linux: sudo apt install python3 python3-pip python3-venv
macOS: brew install python3
Or: https://www.python.org/downloads/"
fi
PY_VERSION=$($PYTHON -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
PY_MAJOR=$($PYTHON -c 'import sys; print(sys.version_info.major)')
PY_MINOR=$($PYTHON -c 'import sys; print(sys.version_info.minor)')
if [ "$PY_MAJOR" -lt 3 ] || ([ "$PY_MAJOR" -eq 3 ] && [ "$PY_MINOR" -lt 9 ]); then
error "Python 3.9+ required, found $PY_VERSION"
fi
success "Python $PY_VERSION found ($PYTHON)"
}
# ── Install via pip ──────────────────────────────────────────────────────────
install_pip() {
info "Installing HackBot via pip..."
local EXTRAS="[all]"
if [ "${INSTALL_GUI:-false}" = "true" ]; then
EXTRAS="[all]"
fi
# Try pipx first (isolated install)
if command -v pipx &>/dev/null; then
info "Using pipx for isolated installation..."
pipx install "hackbot${EXTRAS} @ git+https://github.com/${REPO}.git" || {
warn "pipx install failed, falling back to pip..."
$PYTHON -m pip install --user "hackbot${EXTRAS} @ git+https://github.com/${REPO}.git"
}
else
$PYTHON -m pip install --user "hackbot${EXTRAS} @ git+https://github.com/${REPO}.git"
fi
success "HackBot installed!"
}
# ── Install from local source ────────────────────────────────────────────────
install_local() {
info "Installing HackBot from local source..."
# Check if we're in the hackbot repo
if [ -f "pyproject.toml" ] && grep -q "hackbot" pyproject.toml 2>/dev/null; then
if [ "${INSTALL_GUI:-false}" = "true" ]; then
$PYTHON -m pip install --user -e ".[all,dev]"
else
$PYTHON -m pip install --user -e ".[all]"
fi
success "HackBot installed in development mode!"
else
error "Not in the hackbot repository. Run this from the project root."
fi
}
# ── Install security tools ──────────────────────────────────────────────────
install_security_tools() {
echo ""
info "Installing common security tools..."
# Check if we can use sudo (needed for system package managers)
if [ "$(id -u)" -ne 0 ]; then
if ! command -v sudo &>/dev/null; then
warn "sudo not found and not running as root — skipping system packages"
warn "Install manually: nmap nikto hydra john curl wget openssl"
return 0
fi
# Validate sudo access; prompt once so individual commands don't re-ask
info "Root privileges required for system packages (sudo)..."
if ! sudo -v 2>/dev/null; then
warn "Could not obtain sudo privileges — skipping system packages"
warn "Install manually or re-run as root: sudo $0 tools-only"
return 0
fi
else
# Already root — alias sudo to empty so commands work unchanged
sudo() { "$@"; }
fi
if [ "$OS" = "linux" ]; then
if command -v apt-get &>/dev/null; then
sudo apt-get update -qq
sudo apt-get install -y -qq \
nmap nikto dirb hydra john whatweb \
dnsutils whois traceroute netcat-openbsd \
curl wget openssl sslscan \
2>/dev/null || warn "Some packages may not be available"
success "APT packages installed"
elif command -v dnf &>/dev/null; then
sudo dnf install -y \
nmap nikto hydra john \
bind-utils whois traceroute nmap-ncat \
curl wget openssl \
2>/dev/null || warn "Some packages may not be available"
success "DNF packages installed"
elif command -v pacman &>/dev/null; then
sudo pacman -Sy --noconfirm \
nmap nikto hydra john \
bind-tools whois traceroute gnu-netcat \
curl wget openssl \
2>/dev/null || warn "Some packages may not be available"
success "Pacman packages installed"
fi
# Install Go-based tools
if command -v go &>/dev/null; then
info "Installing Go-based security tools..."
go install github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest 2>/dev/null && success "nuclei installed" || warn "nuclei install failed"
go install github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest 2>/dev/null && success "subfinder installed" || warn "subfinder install failed"
go install github.com/projectdiscovery/httpx/cmd/httpx@latest 2>/dev/null && success "httpx installed" || warn "httpx install failed"
go install github.com/ffuf/ffuf/v2@latest 2>/dev/null && success "ffuf installed" || warn "ffuf install failed"
else
warn "Go not found — skipping nuclei, subfinder, httpx, ffuf"
info "Install Go: https://go.dev/dl/"
fi
elif [ "$OS" = "macos" ]; then
if command -v brew &>/dev/null; then
brew install nmap nikto hydra john-jumbo \
curl wget openssl \
2>/dev/null || warn "Some brew packages may not be available"
success "Homebrew packages installed"
else
warn "Homebrew not found. Install from https://brew.sh"
fi
fi
}
# ── Desktop Shortcut ─────────────────────────────────────────────────────────
install_desktop_shortcut() {
if [ "${INSTALL_GUI:-false}" != "true" ]; then
return
fi
if [ "$OS" = "linux" ]; then
info "Creating desktop shortcut..."
# Find the logo — check local repo first, then installed package
LOGO_SRC=""
if [ -f "public/1000023729-removebg-preview.png" ]; then
LOGO_SRC="public/1000023729-removebg-preview.png"
fi
# Install icon
ICON_DIR="$HOME/.local/share/icons/hicolor/256x256/apps"
mkdir -p "$ICON_DIR"
if [ -n "$LOGO_SRC" ]; then
cp "$LOGO_SRC" "$ICON_DIR/hackbot.png"
success "Icon installed to $ICON_DIR/hackbot.png"
fi
# Install .desktop file
DESKTOP_DIR="$HOME/.local/share/applications"
mkdir -p "$DESKTOP_DIR"
cat > "$DESKTOP_DIR/hackbot.desktop" << 'DESKTOP_EOF'
[Desktop Entry]
Version=1.0
Type=Application
Name=HackBot
GenericName=AI Cybersecurity Assistant
Comment=AI-powered pentesting & cybersecurity assistant with Agent, Chat & Planning modes
Exec=hackbot --gui
Icon=hackbot
Terminal=false
Categories=Security;Network;System;Utility;
Keywords=hacking;pentesting;cybersecurity;security;nmap;ai;
StartupNotify=true
StartupWMClass=hackbot
DESKTOP_EOF
chmod +x "$DESKTOP_DIR/hackbot.desktop"
success "Desktop shortcut installed to $DESKTOP_DIR/hackbot.desktop"
# Update desktop database if available
if command -v update-desktop-database &>/dev/null; then
update-desktop-database "$DESKTOP_DIR" 2>/dev/null || true
fi
info "HackBot should now appear in your application menu"
elif [ "$OS" = "macos" ]; then
info "On macOS, launch HackBot GUI with: hackbot --gui"
info "To add to Dock: drag from Applications or create an alias"
fi
}
# ── Post-install ─────────────────────────────────────────────────────────────
post_install() {
echo ""
# Verify installation
if command -v hackbot &>/dev/null; then
success "HackBot is ready! Run 'hackbot' to start."
else
# Add to PATH hint
warn "hackbot not found in PATH. You may need to add these to your shell profile:"
echo ""
echo " # Add to ~/.bashrc or ~/.zshrc:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
echo ""
echo " Then reload: source ~/.bashrc"
fi
echo ""
echo -e "${GREEN}╔══════════════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ HackBot Installation Complete! ║${NC}"
echo -e "${GREEN}╚══════════════════════════════════════════════════╝${NC}"
echo ""
echo " Quick start:"
echo " hackbot # Interactive mode"
echo " hackbot setup <API_KEY> # Set your API key"
echo " hackbot agent <TARGET> # Start security testing"
echo " hackbot chat # Chat mode"
echo " hackbot plan <TARGET> # Plan an assessment"
echo " hackbot tools # Check available tools"
echo " hackbot --gui # Launch web GUI"
echo ""
echo -e " ${YELLOW}⚠️ Only test systems you have explicit authorization to test!${NC}"
echo ""
echo -e " ${BOLD}Developed by Yashab Alam${NC}"
echo -e " GitHub: ${CYAN}https://github.com/yashab-cyber${NC}"
echo -e " LinkedIn: ${CYAN}https://www.linkedin.com/in/yashab-alam${NC}"
echo -e " Email: yashabalam707@gmail.com | yashabalam9@gmail.com"
echo -e " ${RED}❤️ Support: https://github.com/yashab-cyber/hackbot/blob/main/DONATE.md${NC}"
echo ""
}
# ── Main ─────────────────────────────────────────────────────────────────────
main() {
banner
detect_os
check_python
MODE="${1:-pip}"
# Ask about GUI
echo ""
echo -e "${BOLD}Interface preference:${NC}"
echo " 1) CLI only (default)"
echo " 2) CLI + Web GUI"
echo ""
read -rp "Choose [1/2]: " gui_choice
gui_choice=${gui_choice:-1}
if [ "$gui_choice" = "2" ]; then
INSTALL_GUI=true
info "Will install with GUI support (flask)"
else
INSTALL_GUI=false
info "Installing CLI only"
fi
echo ""
case "$MODE" in
pip)
install_pip
;;
local|dev)
install_local
;;
full)
install_pip
install_security_tools
;;
tools-only)
install_security_tools
;;
*)
echo "Usage: $0 [pip|local|full|tools-only]"
echo ""
echo " pip Install HackBot via pip (default)"
echo " local Install from local source (dev mode)"
echo " full Install HackBot + security tools"
echo " tools-only Install only security tools"
exit 1
;;
esac
# Install desktop shortcut if GUI was selected
install_desktop_shortcut
post_install
}
main "$@"