mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-12-05 18:44:48 +01:00
Merge pull request #123 from JoasASantos/feat/kali-native-console
feat(docker): run the console on the Kali toolbox image
This commit is contained in:
4 files changed
+126
-47
No files matched your search
@@ -0,0 +1,44 @@
|
||||
# Keep the build context small. Without this it is ~19GB, nearly all of it
|
||||
# Rust build artefacts that the builder stage recompiles anyway.
|
||||
|
||||
# Rust build output (18GB)
|
||||
neurosploit-rs/target/
|
||||
target/
|
||||
|
||||
# Engagement data — never belongs in an image
|
||||
runs/
|
||||
evidence/
|
||||
*.log
|
||||
|
||||
# VCS and local tooling
|
||||
.git/
|
||||
.github/
|
||||
.gitignore
|
||||
.claude/
|
||||
|
||||
# Node modules are installed inside the image
|
||||
node_modules/
|
||||
web/node_modules/
|
||||
|
||||
# Secrets and local config
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
*.pem
|
||||
*.key
|
||||
mcp.servers.json
|
||||
creds.json
|
||||
|
||||
# Editor and OS noise
|
||||
.vscode/
|
||||
.idea/
|
||||
.DS_Store
|
||||
*.swp
|
||||
|
||||
# Docs and scratch. Only root-level docs — agents_md/ is the skill catalogue
|
||||
# and must reach the image.
|
||||
/README.md
|
||||
/CHANGELOG.md
|
||||
/CLAUDE.md
|
||||
docs/
|
||||
bench/
|
||||
+35
-15
@@ -1,5 +1,16 @@
|
||||
# NeuroSploit — main application image
|
||||
# Multi-stage: build Rust binary + bundle Node web console
|
||||
#
|
||||
# The console, the harness and the toolbox share one Kali container. Running the
|
||||
# web tier on the same image as the tools means an agent calls nmap or sqlmap
|
||||
# directly instead of spawning a sibling container for every command, which is
|
||||
# where most of the per-tool latency used to go. `--sandbox` still spawns an
|
||||
# isolated container when an engagement wants tools kept off this host.
|
||||
#
|
||||
# Build order matters: this image derives from the toolbox image, so build that
|
||||
# first. `./install.sh` does both in order.
|
||||
#
|
||||
# docker build -t neurosploit-kali:local -f Dockerfile.kali .
|
||||
# docker build -t neurosploit:local -f Dockerfile .
|
||||
|
||||
# ── Rust build ──────────────────────────────────────────────────────────
|
||||
FROM rust:1.83-bookworm AS rust-build
|
||||
@@ -9,30 +20,39 @@ RUN cargo build --release --bin neurosploit \
|
||||
&& strip target/release/neurosploit \
|
||||
&& cp target/release/neurosploit /out-neurosploit
|
||||
|
||||
# ── Runtime ─────────────────────────────────────────────────────────────
|
||||
FROM debian:bookworm-slim
|
||||
# ── Runtime: the Kali toolbox image, plus the console ───────────────────
|
||||
FROM neurosploit-kali:local
|
||||
|
||||
USER root
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates curl nodejs npm docker.io jq git; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
nodejs npm; \
|
||||
apt-get clean; \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Rust binary
|
||||
COPY --from=rust-build /out-neurosploit /usr/local/bin/neurosploit
|
||||
|
||||
# Web console
|
||||
COPY web/ /app/web/
|
||||
RUN cd /app/web && npm ci --omit=dev 2>/dev/null || true
|
||||
|
||||
# Agent skills (markdown)
|
||||
COPY agents_md/ /app/agents_md/
|
||||
|
||||
# DB schema
|
||||
COPY db/ /app/db/
|
||||
|
||||
RUN set -eux; \
|
||||
cd /app/web; \
|
||||
if [ -f package-lock.json ]; then npm ci --omit=dev; else npm install --omit=dev; fi; \
|
||||
npm cache clean --force; \
|
||||
mkdir -p /app/runs; \
|
||||
chown -R 10001:10001 /app
|
||||
|
||||
USER 10001:10001
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
EXPOSE 8787
|
||||
|
||||
# Start the web console (which spawns the harness as needed)
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD node -e "require('http').get('http://127.0.0.1:8787/api/auth/status',r=>process.exit(r.statusCode===200?0:1)).on('error',()=>process.exit(1))"
|
||||
|
||||
CMD ["node", "/app/web/server.js"]
|
||||
+21
-17
@@ -1,10 +1,13 @@
|
||||
# NeuroSploit — Docker Compose infrastructure
|
||||
# Usage: cp .env.example .env && ./install.sh && docker compose up -d
|
||||
# Usage: ./install.sh (generates .env, builds in order, starts everything)
|
||||
#
|
||||
# Services:
|
||||
# postgres — persistent storage (findings, runs, assets, skills)
|
||||
# neurosploit — web console + API + harness orchestrator
|
||||
# kali-worker — isolated Kali container for running tools (nmap, sqlmap, ffuf, nuclei…)
|
||||
# kali-base — the pentest toolbox image; builds only, never runs
|
||||
# neurosploit — console + API + harness, running ON the Kali toolbox image
|
||||
#
|
||||
# neurosploit derives FROM kali-base, so kali-base must be built first.
|
||||
# install.sh enforces that order; `docker compose build` alone does not.
|
||||
|
||||
x-logging: &default-logging
|
||||
driver: json-file
|
||||
@@ -33,10 +36,22 @@ services:
|
||||
logging: *default-logging
|
||||
restart: unless-stopped
|
||||
|
||||
# The toolbox image. Built, never started — neurosploit derives from it, and
|
||||
# `--sandbox` runs it directly when an engagement wants tools isolated.
|
||||
kali-base:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.kali
|
||||
image: neurosploit-kali:local
|
||||
profiles:
|
||||
- build-only
|
||||
logging: *default-logging
|
||||
|
||||
neurosploit:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: neurosploit:local
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
@@ -59,9 +74,9 @@ services:
|
||||
NS_JWT_SECRET: ${NS_JWT_SECRET:?Set NS_JWT_SECRET in .env}
|
||||
NS_DEFAULT_USER: ${NS_DEFAULT_USER:-neurosploit}
|
||||
NS_DEFAULT_PASSWORD: ${NS_DEFAULT_PASSWORD:-}
|
||||
# Worker
|
||||
NS_WORKER_IMAGE: neurosploit-kali:local
|
||||
NS_SANDBOX: ${NS_SANDBOX:-required}
|
||||
# The toolbox is on PATH in this image, so a run with sandbox "host"
|
||||
# executes tools here. Picking an image in the UI still spawns an
|
||||
# isolated sibling container via the mounted docker socket.
|
||||
ports:
|
||||
- "${NS_BIND_ADDR:-127.0.0.1}:${NS_PORT:-8787}:8787"
|
||||
volumes:
|
||||
@@ -75,16 +90,5 @@ services:
|
||||
logging: *default-logging
|
||||
restart: unless-stopped
|
||||
|
||||
kali-worker:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.kali
|
||||
image: neurosploit-kali:local
|
||||
# Not started directly — the harness creates per-task instances.
|
||||
# This service only builds the image so it's ready for `docker run`.
|
||||
profiles:
|
||||
- build-only
|
||||
logging: *default-logging
|
||||
|
||||
volumes:
|
||||
pgdata:
|
||||
+26
-15
@@ -78,20 +78,18 @@ fi
|
||||
ok "Docker Compose: $COMPOSE_CMD"
|
||||
|
||||
# ── Build ──────────────────────────────────────────────────────────────
|
||||
info "Building images (this may take a few minutes on first run)..."
|
||||
# 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
|
||||
|
||||
# Build the Kali worker image first
|
||||
info "Building Kali worker image..."
|
||||
$COMPOSE_CMD build kali-worker 2>&1 | tail -5
|
||||
|
||||
# Build the main app
|
||||
info "Building NeuroSploit..."
|
||||
$COMPOSE_CMD build neurosploit 2>&1 | tail -5
|
||||
info "Building the console on top of it..."
|
||||
$COMPOSE_CMD build neurosploit
|
||||
|
||||
ok "Images built"
|
||||
|
||||
# ── Start ──────────────────────────────────────────────────────────────
|
||||
info "Starting services..."
|
||||
info "Starting PostgreSQL and the console..."
|
||||
$COMPOSE_CMD up -d postgres neurosploit
|
||||
|
||||
# Wait for healthy
|
||||
@@ -104,14 +102,27 @@ for i in $(seq 1 30); do
|
||||
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!"
|
||||
ok "NeuroSploit is running — console, harness and toolbox in one Kali container."
|
||||
echo ""
|
||||
printf '\033[1;36m Web Console: \033[1;37mhttp://localhost:${NS_PORT:-8787}\033[0m\n'
|
||||
printf '\033[1;36m Login: \033[1;37mneurosploit / (see above or .env)\033[0m\n'
|
||||
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 # watch logs\n'
|
||||
printf ' docker compose down # stop\n'
|
||||
printf ' docker compose up -d # start\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 ""
|
||||
Reference in new issue
Block a user