#!/usr/bin/env bash # NeuroSploit install script # Usage: ./install.sh set -euo pipefail cd "$(cd "$(dirname "$0")" && pwd)" info(){ printf '\033[36m[*]\033[0m %s\n' "$*"; } ok(){ printf '\033[32m[+]\033[0m %s\n' "$*"; } warn(){ printf '\033[33m[!]\033[0m %s\n' "$*"; } die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; } rand(){ head -c 24 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 24; } # ── Environment setup ────────────────────────────────────────────────── if [ ! -f .env ]; then info "Creating .env from template..." cp .env.example .env ok ".env created" fi # Normalize CRLF if present grep -q $'\r' .env 2>/dev/null && sed -i.bak 's/\r$//' .env && rm -f .env.bak && ok ".env converted CRLF → LF" set_env(){ local key="$1" value="$2" tmp tmp="$(mktemp)" awk -v k="$key" -v v="$value" ' $0 ~ "^" k "=" { print k "=" v; found=1; next } { print } END { if (!found) print k "=" v } ' .env > "$tmp" chmod --reference=.env "$tmp" 2>/dev/null || true mv "$tmp" .env } # Generate secrets if not set if ! grep -q '^POSTGRES_PASSWORD=[^[:space:]]' .env 2>/dev/null; then PG_PASS="$(rand)" set_env POSTGRES_PASSWORD "$PG_PASS" ok "POSTGRES_PASSWORD generated" fi if ! grep -q '^NS_JWT_SECRET=[^[:space:]]' .env 2>/dev/null; then set_env NS_JWT_SECRET "$(rand)" ok "NS_JWT_SECRET generated" fi # Generate default login password if ! grep -q '^NS_DEFAULT_PASSWORD=[^[:space:]]' .env 2>/dev/null; then DEFAULT_PASS="$(rand)" set_env NS_DEFAULT_PASSWORD "$DEFAULT_PASS" ok "Default login: neurosploit / $DEFAULT_PASS" echo "" printf '\033[1;33m ╔══════════════════════════════════════════════╗\033[0m\n' printf '\033[1;33m ║ \033[1;37mDefault Login Credentials\033[1;33m ║\033[0m\n' printf '\033[1;33m ║ \033[0;36mUsername: \033[1;37mneurosploit\033[1;33m ║\033[0m\n' printf '\033[1;33m ║ \033[0;36mPassword: \033[1;37m%-24s\033[1;33m ║\033[0m\n' "$DEFAULT_PASS" printf '\033[1;33m ║ \033[0;33mChange after first login!\033[1;33m ║\033[0m\n' printf '\033[1;33m ╚══════════════════════════════════════════════╝\033[0m\n' echo "" else info "NS_DEFAULT_PASSWORD already set" fi # ── Docker check ─────────────────────────────────────────────────────── COMPOSE_CMD="" if command -v docker >/dev/null 2>&1; then if docker compose version >/dev/null 2>&1; then COMPOSE_CMD="docker compose" elif command -v docker-compose >/dev/null 2>&1; then COMPOSE_CMD="docker-compose" fi fi if [ -z "$COMPOSE_CMD" ]; then die "Docker Compose not found. Install Docker: https://docs.docker.com/get-docker/" fi ok "Docker Compose: $COMPOSE_CMD" # ── Build ────────────────────────────────────────────────────────────── # Order is load-bearing: the console image is FROM neurosploit-kali:local, so # the toolbox has to exist before the second build can resolve its base. info "Building the Kali toolbox image (first run pulls ~2GB, takes a while)..." $COMPOSE_CMD --profile build-only build kali-base info "Building the console on top of it..." $COMPOSE_CMD build neurosploit ok "Images built" # ── Start ────────────────────────────────────────────────────────────── info "Starting PostgreSQL and the console..." $COMPOSE_CMD up -d postgres neurosploit # Wait for healthy info "Waiting for PostgreSQL..." for i in $(seq 1 30); do if $COMPOSE_CMD exec -T postgres pg_isready -U "${POSTGRES_USER:-neurosploit}" >/dev/null 2>&1; then ok "PostgreSQL ready" break fi sleep 1 done info "Waiting for the console..." PORT="$(grep -E '^NS_PORT=' .env 2>/dev/null | cut -d= -f2)" PORT="${PORT:-8787}" for _ in $(seq 1 30); do if curl -fsS "http://127.0.0.1:${PORT}/api/auth/status" >/dev/null 2>&1; then ok "Console ready" break fi sleep 1 done echo "" ok "NeuroSploit is running — console, harness and toolbox in one Kali container." echo "" printf '\033[1;36m Web console: \033[1;37mhttp://localhost:%s\033[0m\n' "$PORT" printf '\033[1;36m Login: \033[1;37mneurosploit / (shown above, or in .env)\033[0m\n' printf '\033[1;36m Database: \033[1;37mPostgreSQL on 127.0.0.1:5432 (volume pgdata)\033[0m\n' echo "" printf '\033[0;33m Commands:\033[0m\n' printf ' docker compose logs -f neurosploit # watch logs\n' printf ' docker compose exec neurosploit bash # shell inside Kali\n' printf ' docker compose down # stop (keeps the database)\n' printf ' docker compose up -d # start again\n' echo ""