chore(setup): one-step installers (CLI / web / all) and install docs

This commit is contained in:
CyberSecurityUP committed 2026-12-01 18:58:31 -03:00
1 parent 84634ceb54
commit 0b69e54a6b
4 files changed
+976 -399

No files matched your search

+11 -6
View File
@@ -41,11 +41,15 @@ recon ─▶ select agents ─▶ exploit in parallel ─▶ wire-check ─▶ c
## Install
```bash
# Linux / macOS (x64 & arm64)
curl -fsSL https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/setup.sh | bash
The installers work on a machine with nothing set up: they ask whether you want the **CLI**, the **web console + CLI**, or **everything** (CLI, web console, recon tools), then install what is missing (git, build tools, Node.js ≥ 18, nmap, typst…), put `neurosploit` and `neurosploit-web` on your PATH and set `NEUROSPLOIT_BASE`. Re-run them to update; config and runs are kept.
# Windows (PowerShell)
```bash
# Linux / macOS / WSL (x64 & arm64)
curl -fsSL https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/setup.sh | bash
./setup.sh --web --yes # unattended; also --cli / --all, --build, --service, --help
# Windows: double-click setup.bat, or
setup.bat web /y
irm https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/install.ps1 | iex
# From source
@@ -69,7 +73,7 @@ neurosploit whitebox /path/to/repo --subscription --model anthropic:claude-opus-
neurosploit host 10.0.0.5 --subscription --model anthropic:claude-opus-4-8 -v
# Web console:
cd web && npm start # → http://localhost:3000
neurosploit-web --open # → http://localhost:4173 (from a checkout: cd web && npm start)
```
---
@@ -201,7 +205,8 @@ Multi-model voting: `--model anthropic:claude-opus-4-8 --model openai:gpt-5.1 --
## Web Console
```bash
cd web && npm start # → http://localhost:3000
neurosploit-web --open # installed by setup.sh / setup.bat → http://localhost:4173
cd web && npm start # from a source checkout
```
- **Attack graph** — host → service → finding → credential → impact, with clickable filters
+332 -127
View File
@@ -1,143 +1,348 @@
# NeuroSploit installer for Windows (PowerShell) — by Joas A Santos & Red Team Leaders
#
# irm https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/install.ps1 | iex
# & ([scriptblock]::Create((irm https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/install.ps1))) -Mode web -Yes
# .\install.ps1 -Mode web -Yes
# setup.bat web /y
#
# Downloads the prebuilt neurosploit.exe + agent library, installs them, and sets
# your User PATH + NEUROSPLOIT_BASE so you can run `neurosploit` from ANY folder —
# no need to cd into the repo. Falls back to building from source if needed.
# Env: NEUROSPLOIT_DIR (install dir), NEUROSPLOIT_REF (release tag),
# NEUROSPLOIT_BUILD=1 (force source build).
$ErrorActionPreference = "Stop"
# Works on a fresh machine: installs what is missing with winget (Git, Node.js LTS,
# Nmap, VC++ build tools only when compiling), downloads the prebuilt binary (or
# builds it), deploys the web console, adds `neurosploit` / `neurosploit-web` to
# your User PATH and sets NEUROSPLOIT_BASE. Safe to re-run: config (.neurosploit\)
# and runs (runs\) are kept.
#
# Parameters (env equivalents for `irm | iex`):
# -Mode cli|web|all NEUROSPLOIT_MODE what to install (asks when omitted)
# -Yes NEUROSPLOIT_YES=1 no questions
# -Dir PATH NEUROSPLOIT_DIR default %LOCALAPPDATA%\NeuroSploit
# -Ref TAG NEUROSPLOIT_REF default: latest release
# -Build NEUROSPLOIT_BUILD=1 build from source
# -Port N NEUROSPLOIT_WEB_PORT default 4173
# -NoDeps NEUROSPLOIT_NO_DEPS=1 skip winget installs
# -Run NEUROSPLOIT_RUN=1 launch when done
param(
[ValidateSet('', 'cli', 'web', 'all')][string]$Mode = $env:NEUROSPLOIT_MODE,
[switch]$Yes,
[string]$Dir = $env:NEUROSPLOIT_DIR,
[string]$Ref = $env:NEUROSPLOIT_REF,
[switch]$Build,
[int]$Port = 0,
[switch]$NoDeps,
[switch]$Run
)
# 'Continue' so native tools writing to stderr (git, cargo, winget) do not throw
# under Windows PowerShell 5.1; web/file cmdlets opt into -ErrorAction Stop.
$ErrorActionPreference = 'Continue'
$ProgressPreference = 'SilentlyContinue' # Invoke-WebRequest -UseBasicParsing -ErrorAction Stop is 10x faster without the progress bar
try { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 } catch { }
function Say($m) { Write-Host " > $m" -ForegroundColor Magenta }
function Ok ($m) { Write-Host " + $m" -ForegroundColor Green }
function Warn($m){ Write-Host " ! $m" -ForegroundColor Yellow }
$Slug = 'JoasASantos/NeuroSploit'
$FallbackRef = 'v4.5.0'
$NodeMin = 18
if ($env:NEUROSPLOIT_YES -eq '1') { $Yes = $true }
if ($env:NEUROSPLOIT_BUILD -eq '1') { $Build = $true }
if ($env:NEUROSPLOIT_NO_DEPS -eq '1') { $NoDeps = $true }
if ($env:NEUROSPLOIT_RUN -eq '1') { $Run = $true }
if (-not $Dir) { $Dir = Join-Path $env:LOCALAPPDATA 'NeuroSploit' }
if ($Port -le 0) { $Port = if ($env:NEUROSPLOIT_WEB_PORT) { [int]$env:NEUROSPLOIT_WEB_PORT } else { 4173 } }
$script:Step = 0
function Step($m) { $script:Step++; Write-Host ""; Write-Host "[$script:Step] $m" -ForegroundColor White }
function Say($m) { Write-Host " > $m" -ForegroundColor Magenta }
function Ok($m) { Write-Host " + $m" -ForegroundColor Green }
function Warn($m) { Write-Host " ! $m" -ForegroundColor Yellow }
function Die($m) { throw [System.Exception]::new("NS: $m") }
function Have($c) { [bool](Get-Command $c -ErrorAction SilentlyContinue) }
$Interactive = (-not $Yes) -and [Environment]::UserInteractive -and -not [Console]::IsInputRedirected
function Ask($q, $def) {
if (-not $Interactive) { return ($def -eq 'y') }
$hint = if ($def -eq 'y') { '[Y/n]' } else { '[y/N]' }
$a = (Read-Host " ? $q $hint").Trim().ToLower()
if (-not $a) { $a = $def }
return ($a -in @('y', 'yes', 's', 'sim'))
}
function Refresh-Path {
$m = [Environment]::GetEnvironmentVariable('Path', 'Machine'); $u = [Environment]::GetEnvironmentVariable('Path', 'User')
$env:Path = (@($m, $u) | Where-Object { $_ }) -join ';'
foreach ($p in @("$HOME\.cargo\bin", (Join-Path $Dir 'runtime\node'), $Dir, (Join-Path $Dir 'bin'))) {
if ((Test-Path $p) -and ($env:Path -notlike "*$p*")) { $env:Path = "$p;$env:Path" }
}
}
function Winget-Install($id, $label) {
if ($NoDeps) { Warn "$label missing (winget installs skipped)"; return $false }
if (-not (Have winget)) { Warn "$label missing and winget is unavailable — install it manually"; return $false }
Say "installing $label (winget $id)..."
& winget install -e --id $id --silent --accept-source-agreements --accept-package-agreements --disable-interactivity *> $null
Refresh-Path
return $true
}
Write-Host ""
Write-Host " NeuroSploit installer (Windows) — v4.4.2" -ForegroundColor Cyan
Write-Host " NeuroSploit installer (Windows) — CLI + web console" -ForegroundColor Cyan
Write-Host " by Joas A Santos & Red Team Leaders" -ForegroundColor DarkGray
# arch → asset arch (only x64 prebuilt today; arm64 falls back to source)
$rawArch = $env:PROCESSOR_ARCHITECTURE
$arch = if ($rawArch -match 'ARM64') { "arm64" } else { "x64" }
Say "Platform: Windows / $arch"
$Arch = if ($rawArch -match 'ARM64') { 'arm64' } else { 'x64' }
$slug = "JoasASantos/NeuroSploit"
$dir = if ($env:NEUROSPLOIT_DIR) { $env:NEUROSPLOIT_DIR } else { Join-Path $env:LOCALAPPDATA "NeuroSploit" }
$ref = $env:NEUROSPLOIT_REF
# Local checkout next to this script → reuse its sources (agents, web console).
$LocalSrc = $null
if ($PSScriptRoot -and (Test-Path (Join-Path $PSScriptRoot 'web\server.js')) -and (Test-Path (Join-Path $PSScriptRoot 'neurosploit-rs\Cargo.toml'))) { $LocalSrc = $PSScriptRoot }
# resolve latest release tag unless pinned
if (-not $ref) {
try { $ref = (Invoke-RestMethod "https://api.github.com/repos/$slug/releases/latest").tag_name } catch { }
}
if (-not $ref) { $ref = "v4.4.2" }
Say "Release: $ref"
New-Item -ItemType Directory -Force -Path $dir | Out-Null
$installed = $false
# ---- try the prebuilt asset (no Rust needed; x64 only) ----
if ($env:NEUROSPLOIT_BUILD -ne "1" -and $arch -eq "x64") {
$asset = "neurosploit-$ref-windows-x64.zip"
$url = "https://github.com/$slug/releases/download/$ref/$asset"
$tmp = Join-Path $env:TEMP "ns-dl"
Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
try {
Say "Downloading prebuilt binary: $asset"
Invoke-WebRequest $url -OutFile (Join-Path $tmp "a.zip")
Expand-Archive -Path (Join-Path $tmp "a.zip") -DestinationPath $tmp -Force
$exe = Get-ChildItem -Path $tmp -Recurse -Filter neurosploit.exe | Select-Object -First 1
if (-not $exe) { throw "no neurosploit.exe in archive" }
$srcdir = $exe.DirectoryName
Copy-Item (Join-Path $srcdir "neurosploit.exe") (Join-Path $dir "neurosploit.exe") -Force
Remove-Item -Recurse -Force (Join-Path $dir "agents_md") -ErrorAction SilentlyContinue
Copy-Item (Join-Path $srcdir "agents_md") (Join-Path $dir "agents_md") -Recurse -Force
Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
$installed = $true
Ok "Downloaded & unpacked -> $dir"
} catch {
Warn "Prebuilt download failed ($($_.Exception.Message)) — building from source."
}
}
# ---- build from source (needs git + Rust) ----
if (-not $installed) {
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { throw "git is required to build from source (install Git for Windows)." }
if (-not (Get-Command cargo -ErrorAction SilentlyContinue)) {
Say "Rust not found — installing rustup..."
if (Get-Command winget -ErrorAction SilentlyContinue) {
winget install -e --id Rustlang.Rustup --accept-source-agreements --accept-package-agreements
} else {
$ri = Join-Path $env:TEMP "rustup-init.exe"
Invoke-WebRequest "https://win.rustup.rs/$rawArch" -OutFile $ri
& $ri -y --default-toolchain stable --profile minimal
}
$env:Path = "$HOME\.cargo\bin;$env:Path"
}
Ok ("Rust: " + (cargo --version))
$src = Join-Path $dir "src"
if (Test-Path (Join-Path $src ".git")) {
Say "Updating $src..."; git -C $src fetch --depth 1 origin $ref; git -C $src checkout -q FETCH_HEAD
} else {
Say "Cloning to $src..."; git clone --depth 1 --branch $ref "https://github.com/$slug.git" $src
}
Say "Building release binary (first build downloads crates)..."
Push-Location (Join-Path $src "neurosploit-rs"); cargo build --release; Pop-Location
Copy-Item (Join-Path $src "neurosploit-rs\target\release\neurosploit.exe") (Join-Path $dir "neurosploit.exe") -Force
Remove-Item -Recurse -Force (Join-Path $dir "agents_md") -ErrorAction SilentlyContinue
Copy-Item (Join-Path $src "agents_md") (Join-Path $dir "agents_md") -Recurse -Force
Ok "Built -> $dir"
}
$exePath = Join-Path $dir "neurosploit.exe"
if (-not (Test-Path $exePath)) { throw "install did not produce $exePath" }
# ---- set User PATH + NEUROSPLOIT_BASE (so it runs from any folder) ----
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$dir*") {
[Environment]::SetEnvironmentVariable("Path", "$userPath;$dir", "User")
Ok "Added $dir to your User PATH."
}
[Environment]::SetEnvironmentVariable("NEUROSPLOIT_BASE", $dir, "User")
Ok "Set NEUROSPLOIT_BASE=$dir (User)."
# make it work in THIS session too
$env:Path = "$dir;$env:Path"; $env:NEUROSPLOIT_BASE = $dir
Ok ("Version: " + (& $exePath --version))
# ---- dependencies: install what winget can (best-effort, never fatal) ----
if ($env:NEUROSPLOIT_NO_DEPS -ne "1") {
Say "Checking dependencies..."
$have = { param($c) [bool](Get-Command $c -ErrorAction SilentlyContinue) }
$deps = @(
@{ cmd = "node"; id = "OpenJS.NodeJS"; why = "web console" },
@{ cmd = "nmap"; id = "Insecure.Nmap"; why = "recon (optional)" },
@{ cmd = "git"; id = "Git.Git"; why = "source build / updates" }
)
foreach ($d in $deps) {
if (& $have $d.cmd) { Ok ("{0} present" -f $d.cmd) }
elseif (Get-Command winget -ErrorAction SilentlyContinue) {
Say ("installing {0} ({1})..." -f $d.cmd, $d.why)
try { winget install -e --id $d.id --accept-source-agreements --accept-package-agreements | Out-Null; Ok ("{0} installed" -f $d.cmd) }
catch { Warn ("could not install {0} automatically — install it manually" -f $d.cmd) }
} else { Warn ("{0} missing (winget unavailable) — install manually for: {1}" -f $d.cmd, $d.why) }
}
if (& $have cargo) {
if (-not (& $have typst)) { Say "installing typst (cargo, PDF reports)..."; try { cargo install typst-cli | Out-Null; Ok "typst installed" } catch { Warn "typst optional — skipped" } }
}
if (-not $Mode) {
if ($Interactive) {
Write-Host ""
Write-Host " What do you want to install?" -ForegroundColor White
Write-Host " 1 CLI only terminal agent: neurosploit run / REPL"
Write-Host " 2 Web console + CLI browser UI on http://localhost:$Port (needs Node.js)"
Write-Host " 3 Everything web console + CLI + recon tools (nmap, typst, ...)"
$c = Read-Host " ? Choice [3]"
$Mode = switch ($c.Trim()) { '1' { 'cli' } 'cli' { 'cli' } '2' { 'web' } 'web' { 'web' } default { 'all' } }
} else { $Mode = 'all' }
}
$WantWeb = $Mode -ne 'cli'
Write-Host ""
Ok "Installed. Open a NEW terminal, then from ANY folder:"
Write-Host " neurosploit # interactive session"
Write-Host " neurosploit run http://testphp.vulnweb.com/ --subscription --model anthropic:claude-opus-4-8 -v"
Write-Host " neurosploit --help"
Warn "Update later: just re-run this script."
Write-Host " Plan windows-$Arch · mode $Mode -> $Dir"
if ($LocalSrc) { Write-Host " local checkout $LocalSrc" }
# ---- optionally launch now (NEUROSPLOIT_RUN=1, or confirm when interactive) ----
$runNow = $env:NEUROSPLOIT_RUN
if (-not $runNow -and [Environment]::UserInteractive) {
$ans = Read-Host "`n Launch the interactive session now? [y/N]"
if ($ans -match '^(y|yes)$') { $runNow = "1" }
$Tmp = Join-Path $env:TEMP ("neurosploit-" + [guid]::NewGuid().ToString('N').Substring(0, 8))
New-Item -ItemType Directory -Force -Path $Tmp, $Dir | Out-Null
Refresh-Path
try {
# --------------------------------------------------------------- base ------
Step 'Base prerequisites'
if (Have winget) { Ok 'winget' } else { Warn 'winget not found (install "App Installer" from the Microsoft Store) — tools will not be auto-installed' }
if (-not (Have git)) { [void](Winget-Install 'Git.Git' 'Git') }
if (Have git) { Ok 'git' } else { Warn 'git missing — needed only for source builds' }
if (-not $Ref) {
try { $Ref = (Invoke-RestMethod -UseBasicParsing -ErrorAction Stop "https://api.github.com/repos/$Slug/releases/latest" -TimeoutSec 20).tag_name } catch { }
if (-not $Ref) { $Ref = $FallbackRef }
}
if ($runNow -eq "1") { Say "Starting NeuroSploit..."; & $exePath }
$script:SrcTree = $null
function Get-SourceTree {
if ($script:SrcTree) { return $script:SrcTree }
if ($LocalSrc) { $script:SrcTree = $LocalSrc; return $LocalSrc }
$co = Join-Path $Dir 'src'
if (Have git) {
if (Test-Path (Join-Path $co '.git')) {
Say "updating source checkout ($Ref)..."
git -C $co fetch -q --depth 1 origin $Ref 2>$null; if ($LASTEXITCODE -eq 0) { git -C $co checkout -q FETCH_HEAD 2>$null }
} else {
Say "cloning $Slug ($Ref)..."
git clone -q --depth 1 --branch $Ref "https://github.com/$Slug.git" $co 2>$null
if ($LASTEXITCODE -ne 0) { git clone -q --depth 1 "https://github.com/$Slug.git" $co }
}
$script:SrcTree = $co; return $co
}
Say "downloading source archive ($Ref)..."
$zip = Join-Path $Tmp 'src.zip'
Invoke-WebRequest -UseBasicParsing -ErrorAction Stop "https://codeload.github.com/$Slug/zip/$Ref" -OutFile $zip
Expand-Archive -ErrorAction Stop $zip -DestinationPath (Join-Path $Tmp 'src') -Force
$script:SrcTree = (Get-ChildItem (Join-Path $Tmp 'src') -Directory | Select-Object -First 1).FullName
return $script:SrcTree
}
# --------------------------------------------------------------- CLI -------
Step "NeuroSploit CLI ($Ref)"
$Exe = Join-Path $Dir 'neurosploit.exe'
function Exe-Works { try { $env:NEUROSPLOIT_BASE = $Dir; & $Exe --version *> $null; return ($LASTEXITCODE -eq 0) } catch { return $false } }
$installed = $false
if (-not $Build -and $Arch -eq 'x64') {
$asset = "neurosploit-$Ref-windows-x64.zip"
try {
Say "downloading $asset..."
Invoke-WebRequest -UseBasicParsing -ErrorAction Stop "https://github.com/$Slug/releases/download/$Ref/$asset" -OutFile (Join-Path $Tmp 'bin.zip')
Expand-Archive -ErrorAction Stop (Join-Path $Tmp 'bin.zip') -DestinationPath (Join-Path $Tmp 'bin') -Force
$f = Get-ChildItem (Join-Path $Tmp 'bin') -Recurse -Filter neurosploit.exe | Select-Object -First 1
if (-not $f) { throw 'no neurosploit.exe in the archive' }
Copy-Item $f.FullName $Exe -Force
$agents = Join-Path $f.DirectoryName 'agents_md'
if (Test-Path $agents) { Remove-Item -Recurse -Force (Join-Path $Dir 'agents_md') -ErrorAction SilentlyContinue; Copy-Item $agents (Join-Path $Dir 'agents_md') -Recurse -Force }
if (Exe-Works) { $installed = $true; Ok 'prebuilt binary installed' } else { Warn 'prebuilt binary does not run here — building from source' }
} catch { Warn "no prebuilt binary for windows-$Arch ($Ref) — building from source" }
}
if (-not $installed) {
if (-not (Have cargo)) {
if (-not (Winget-Install 'Rustlang.Rustup' 'Rust (rustup)')) {
Say 'downloading rustup-init...'
$ri = Join-Path $Tmp 'rustup-init.exe'
Invoke-WebRequest -UseBasicParsing -ErrorAction Stop "https://win.rustup.rs/$(if ($Arch -eq 'arm64') { 'aarch64' } else { 'x86_64' })" -OutFile $ri
& $ri -y --default-toolchain stable --profile minimal *> $null
}
Refresh-Path
}
if (-not (Have cargo)) { Die 'Rust is not available — install it from https://rustup.rs and re-run' }
& rustup default stable *> $null
# The MSVC linker comes with the VS Build Tools (C++ workload).
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
$hasVC = (Test-Path $vswhere) -and (& $vswhere -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath)
if (-not $hasVC) {
if (-not $NoDeps -and (Have winget) -and (Ask 'Compiling needs the Visual Studio C++ Build Tools (~2 GB). Install them?' 'y')) {
Say 'installing Visual Studio Build Tools (this takes a while)...'
& winget install -e --id Microsoft.VisualStudio.2022.BuildTools --silent --accept-source-agreements --accept-package-agreements `
--override '--quiet --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' *> $null
} else { Warn 'no MSVC build tools found — the build will likely fail' }
}
Ok (cargo --version)
$src = Get-SourceTree
Say 'compiling (first build downloads crates, takes a few minutes)...'
Push-Location (Join-Path $src 'neurosploit-rs')
$log = Join-Path $Tmp 'build.log'
cmd /c "cargo build --release > `"$log`" 2>&1"
$rc = $LASTEXITCODE
Pop-Location
if ($rc -ne 0) { Get-Content $log | Select-String '^error' -Context 0, 6 | Select-Object -First 8 | ForEach-Object { Write-Host " $_" }; Die 'cargo build failed' }
Copy-Item (Join-Path $src 'neurosploit-rs\target\release\neurosploit.exe') $Exe -Force
Remove-Item -Recurse -Force (Join-Path $Dir 'agents_md') -ErrorAction SilentlyContinue
Copy-Item (Join-Path $src 'agents_md') (Join-Path $Dir 'agents_md') -Recurse -Force
if (-not (Exe-Works)) { Die 'the built binary does not run' }
Ok 'built from source'
}
$env:NEUROSPLOIT_BASE = $Dir
$Version = (& $Exe --version 2>$null | Select-Object -First 1)
Ok "$Version -> $Exe"
# --------------------------------------------------------------- web -------
$NodeExe = $null
function Node-Ok($n) { try { $v = (& $n -v 2>$null).TrimStart('v').Split('.')[0]; return ([int]$v -ge $NodeMin) } catch { return $false } }
if ($WantWeb) {
Step "Node.js (>= $NodeMin, for the web console)"
$local = Join-Path $Dir 'runtime\node\node.exe'
if ((Test-Path $local) -and (Node-Ok $local)) { $NodeExe = $local }
elseif ((Have node) -and (Node-Ok (Get-Command node).Source)) { $NodeExe = (Get-Command node).Source }
else {
if (Have node) { Warn "node $(node -v) is too old" }
[void](Winget-Install 'OpenJS.NodeJS.LTS' 'Node.js LTS')
if ((Have node) -and (Node-Ok (Get-Command node).Source)) { $NodeExe = (Get-Command node).Source }
else {
# Portable Node from nodejs.org (no admin), checksum-verified.
try {
$line = 'latest-v22.x'; $na = if ($Arch -eq 'arm64') { 'arm64' } else { 'x64' }
$sums = (Invoke-WebRequest -UseBasicParsing -ErrorAction Stop "https://nodejs.org/dist/$line/SHASUMS256.txt").Content
$m = [regex]::Match($sums, "([0-9a-f]{64})\s+(node-v[0-9.]+-win-$na\.zip)")
if (-not $m.Success) { throw 'no Windows build listed' }
$file = $m.Groups[2].Value; $zip = Join-Path $Tmp $file
Say "downloading $file from nodejs.org..."
Invoke-WebRequest -UseBasicParsing -ErrorAction Stop "https://nodejs.org/dist/$line/$file" -OutFile $zip
if ((Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() -ne $m.Groups[1].Value) { throw 'checksum mismatch' }
Expand-Archive -ErrorAction Stop $zip -DestinationPath (Join-Path $Tmp 'node') -Force
Remove-Item -Recurse -Force (Join-Path $Dir 'runtime\node') -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force (Join-Path $Dir 'runtime') | Out-Null
Move-Item (Join-Path $Tmp "node\$($file -replace '\.zip$','')") (Join-Path $Dir 'runtime\node')
if (Node-Ok $local) { $NodeExe = $local }
} catch { Warn "portable Node.js failed: $($_.Exception.Message)" }
}
}
if (-not $NodeExe) { Die "could not get Node.js >= $NodeMin — install it from https://nodejs.org and re-run" }
Ok "node $(& $NodeExe -v) -> $NodeExe"
Step 'Web console'
$src = Get-SourceTree
if (-not (Test-Path (Join-Path $src 'web\server.js'))) { Die "web console not found in $src" }
$web = Join-Path $Dir 'web'
Remove-Item -Recurse -Force $web -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force $web | Out-Null
foreach ($i in 'server.js', 'package.json', 'public') { Copy-Item (Join-Path $src "web\$i") $web -Recurse -Force }
New-Item -ItemType Directory -Force (Join-Path $Dir 'runs'), (Join-Path $Dir '.neurosploit') | Out-Null
Ok "deployed -> $web (config and runs are kept between updates)"
$binDir = Join-Path $Dir 'bin'
New-Item -ItemType Directory -Force $binDir | Out-Null
$launcher = @"
@echo off
REM NeuroSploit web console launcher (written by install.ps1).
REM neurosploit-web [port] [--open] binds to 127.0.0.1
setlocal
set "NEUROSPLOIT_BASE=$Dir"
set "NEUROSPLOIT_BIN=$Exe"
set "PATH=$Dir;%PATH%"
if not defined NEUROSPLOIT_WEB_HOST set "NEUROSPLOIT_WEB_HOST=127.0.0.1"
if not defined NEUROSPLOIT_WEB_PORT set "NEUROSPLOIT_WEB_PORT=$Port"
set "OPEN="
:args
if "%~1"=="" goto run
if /i "%~1"=="--open" (set "OPEN=1") else (set "NEUROSPLOIT_WEB_PORT=%~1")
shift
goto args
:run
if defined OPEN start "" /b powershell -NoProfile -WindowStyle Hidden -Command "Start-Sleep -Seconds 2; Start-Process 'http://localhost:%NEUROSPLOIT_WEB_PORT%'"
cd /d "$web"
"$NodeExe" server.js
"@
Set-Content -Path (Join-Path $binDir 'neurosploit-web.cmd') -Value $launcher -Encoding ASCII
Ok "launcher -> $binDir\neurosploit-web.cmd"
$lnk = Join-Path ([Environment]::GetFolderPath('Programs')) 'NeuroSploit Web Console.lnk'
try {
$sh = New-Object -ComObject WScript.Shell
$s = $sh.CreateShortcut($lnk); $s.TargetPath = Join-Path $binDir 'neurosploit-web.cmd'; $s.Arguments = '--open'
$s.WorkingDirectory = $Dir; $s.Description = 'NeuroSploit web console'; $s.Save()
Ok 'Start menu shortcut: NeuroSploit Web Console'
} catch { }
}
# --------------------------------------------------------------- tools -----
Step 'Testing tools'
if (Have nmap) { Ok 'nmap' } else { [void](Winget-Install 'Insecure.Nmap' 'Nmap'); if (Have nmap) { Ok 'nmap installed' } }
if ($Mode -eq 'all') {
if (-not (Have jq)) { [void](Winget-Install 'jqlang.jq' 'jq') }
if (-not (Have python) -and -not (Have py)) { [void](Winget-Install 'Python.Python.3.12' 'Python 3') }
if (-not (Have ffuf)) { [void](Winget-Install 'ffuf.ffuf' 'ffuf') }
}
if (Have typst) { Ok 'typst (PDF reports)' } else {
[void](Winget-Install 'Typst.Typst' 'typst (PDF reports)')
if (Have typst) { Ok 'typst installed' } else { Warn 'typst optional — HTML/Markdown reports still work' }
}
foreach ($c in 'claude', 'codex', 'gemini') { if (Have $c) { Ok "$c CLI found (subscription login)" } }
# --------------------------------------------------------------- env -------
Step 'Environment'
$userPath = [Environment]::GetEnvironmentVariable('Path', 'User')
$parts = @($userPath -split ';' | Where-Object { $_ })
foreach ($p in @($Dir, (Join-Path $Dir 'bin'))) {
if ((Test-Path $p) -and ($parts -notcontains $p)) { $parts += $p; Ok "added $p to your User PATH" }
}
[Environment]::SetEnvironmentVariable('Path', ($parts -join ';'), 'User')
[Environment]::SetEnvironmentVariable('NEUROSPLOIT_BASE', $Dir, 'User')
Ok "NEUROSPLOIT_BASE=$Dir"
Refresh-Path
# --------------------------------------------------------------- done ------
Write-Host ""
Write-Host " NeuroSploit is installed ($Version, mode: $Mode)" -ForegroundColor Green
Write-Host " Open a NEW terminal so PATH updates apply, then:"
Write-Host ""
Write-Host " CLI" -ForegroundColor White
Write-Host " neurosploit interactive session"
Write-Host " neurosploit run https://target -v one-shot test"
if ($WantWeb) {
Write-Host ""
Write-Host " Web console" -ForegroundColor White
Write-Host " neurosploit-web --open http://localhost:$Port (or Start menu > NeuroSploit Web Console)"
}
Write-Host ""
Write-Host " AI access: one API key (web console settings, or ANTHROPIC_API_KEY / OPENAI_API_KEY),"
Write-Host " or a logged-in CLI subscription (claude, codex, gemini)."
Write-Host " Update later: re-run this installer." -ForegroundColor DarkGray
$launch = $null
if ($Run) { $launch = if ($WantWeb) { 'web' } else { 'cli' } }
elseif ($Interactive) {
if ($WantWeb) { if (Ask 'Open the web console now?' 'y') { $launch = 'web' } }
elseif (Ask 'Start an interactive session now?' 'n') { $launch = 'cli' }
}
if ($launch -eq 'web') { Say 'starting the web console (Ctrl+C to stop)...'; & (Join-Path $Dir 'bin\neurosploit-web.cmd') --open }
elseif ($launch -eq 'cli') { Say 'starting NeuroSploit...'; & $Exe }
}
catch {
$script:Failed = $true
Write-Host (" x " + ($_.Exception.Message -replace '^NS: ', '')) -ForegroundColor Red
}
finally {
Remove-Item -Recurse -Force $Tmp -ErrorAction SilentlyContinue
}
# Exit code only when run as a file — under `irm | iex` an exit would close the shell.
if ($script:Failed -and $PSCommandPath) { exit 1 }
+66 -21
View File
@@ -1,40 +1,85 @@
@echo off
REM NeuroSploit installer for Windows (CMD) — by Joas A Santos & Red Team Leaders
REM NeuroSploit installer for Windows (CMD) - by Joas A Santos & Red Team Leaders
REM
REM Double-click setup.bat, or run it from a terminal. It bootstraps the
REM PowerShell installer (install.ps1), which detects the platform, installs
REM Rust if missing, downloads or builds the binary, finds and installs
REM dependencies (Node, Nmap, Git, typst), configures PATH + NEUROSPLOIT_BASE,
REM and can launch NeuroSploit at the end.
REM Double-click setup.bat and pick CLI, Web console or Everything, or run:
REM setup.bat cli | web | all [/y] [/build] [/nodeps] [/run]
REM
REM Env (optional): NEUROSPLOIT_REF, NEUROSPLOIT_DIR, NEUROSPLOIT_BUILD=1,
REM NEUROSPLOIT_NO_DEPS=1, NEUROSPLOIT_RUN=1
setlocal
REM It runs install.ps1 (next to this file, or the published copy), which
REM installs what a fresh machine is missing with winget (Git, Node.js LTS,
REM Nmap, typst, build tools when compiling), downloads or builds the binary,
REM deploys the web console and sets PATH + NEUROSPLOIT_BASE for your user.
setlocal EnableExtensions
title NeuroSploit installer
echo.
echo NeuroSploit installer (Windows) v4.4.2
echo --------------------------------------
echo NeuroSploit installer (Windows)
echo -------------------------------
where powershell >nul 2>&1
if errorlevel 1 (
echo [x] PowerShell not found. Install PowerShell, or use WSL with setup.sh.
exit /b 1
echo [x] Windows PowerShell not found. Install PowerShell, or use WSL with setup.sh.
goto :fail
)
REM Prefer the install.ps1 sitting next to this file; fall back to the published one.
set "ARGS="
:parse
if "%~1"=="" goto :run
set "A=%~1"
if /i "%A%"=="cli" set "ARGS=%ARGS% -Mode cli"
if /i "%A%"=="--cli" set "ARGS=%ARGS% -Mode cli"
if /i "%A%"=="web" set "ARGS=%ARGS% -Mode web"
if /i "%A%"=="--web" set "ARGS=%ARGS% -Mode web"
if /i "%A%"=="all" set "ARGS=%ARGS% -Mode all"
if /i "%A%"=="--all" set "ARGS=%ARGS% -Mode all"
if /i "%A%"=="/y" set "ARGS=%ARGS% -Yes"
if /i "%A%"=="--yes" set "ARGS=%ARGS% -Yes"
if /i "%A%"=="/build" set "ARGS=%ARGS% -Build"
if /i "%A%"=="--build" set "ARGS=%ARGS% -Build"
if /i "%A%"=="/nodeps" set "ARGS=%ARGS% -NoDeps"
if /i "%A%"=="--no-deps" set "ARGS=%ARGS% -NoDeps"
if /i "%A%"=="/run" set "ARGS=%ARGS% -Run"
if /i "%A%"=="--run" set "ARGS=%ARGS% -Run"
if /i "%A%"=="/?" goto :help
if /i "%A%"=="-h" goto :help
if /i "%A%"=="--help" goto :help
shift
goto :parse
:run
REM Prefer the install.ps1 next to this file; otherwise download it to %TEMP% and run it as a file.
set "PS1=%~dp0install.ps1"
if exist "%PS1%" (
echo Running local installer: %PS1%
powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%"
) else (
if not exist "%PS1%" (
echo Fetching installer from GitHub...
powershell -NoProfile -ExecutionPolicy Bypass -Command "irm https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/install.ps1 | iex"
set "PS1=%TEMP%\neurosploit-install.ps1"
powershell -NoProfile -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/install.ps1' -OutFile $env:TEMP\neurosploit-install.ps1"
if errorlevel 1 (
echo [x] Could not download install.ps1 - check your internet connection.
goto :fail
)
)
powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%" %ARGS%
set "RC=%ERRORLEVEL%"
echo.
if "%RC%"=="0" (
echo [ok] Done. Open a NEW terminal, then run: neurosploit
echo [ok] Done. Open a NEW terminal, then run: neurosploit or neurosploit-web --open
) else (
echo [x] Installer exited with code %RC%.
)
REM Keep the window open when launched by double-click.
echo %CMDCMDLINE% | find /i "/c" >nul && pause
endlocal & exit /b %RC%
:help
echo.
echo setup.bat [cli^|web^|all] [/y] [/build] [/nodeps] [/run]
echo cli CLI only
echo web web console + CLI
echo all everything (web console, CLI, recon tools) [default]
echo /y no questions
echo /build build from source instead of downloading
echo /nodeps do not install anything with winget
echo /run launch when done
endlocal & exit /b 0
:fail
echo %CMDCMDLINE% | find /i "/c" >nul && pause
endlocal & exit /b 1
+567 -245
View File
@@ -1,309 +1,631 @@
#!/usr/bin/env bash
# NeuroSploit installer — by Joas A Santos & Red Team Leaders
# NeuroSploit installer (macOS / Linux / WSL) — by Joas A Santos & Red Team Leaders
#
# curl -fsSL https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/setup.sh | bash
# ./setup.sh # interactive: pick CLI, Web console, or everything
# ./setup.sh --web --yes # unattended
#
# Downloads the prebuilt `neurosploit` binary + agent library, installs them, and
# sets up PATH + NEUROSPLOIT_BASE so you can run `neurosploit` from ANY folder —
# no need to cd into the repo. Falls back to building from source if no prebuilt
# asset fits (or NEUROSPLOIT_BUILD=1). Safe to re-run (idempotent). Honors:
# NEUROSPLOIT_DIR install dir (default: ~/.neurosploit-app)
# NEUROSPLOIT_REF release tag/branch (default: latest release)
# NEUROSPLOIT_BUILD 1 = build from source instead of downloading
# PREFIX bin symlink dir (default: ~/.local/bin)
# Works on a fresh machine: installs what is missing (git, curl, build tools,
# Node.js >= 18, recon tools), downloads the prebuilt binary (or builds it from
# source), deploys the web console, puts `neurosploit` / `neurosploit-web` on
# PATH and sets NEUROSPLOIT_BASE. Safe to re-run: it updates in place and keeps
# your config (.neurosploit/) and runs (runs/).
#
# Options (each has an env equivalent for `curl | bash`):
# --cli | --web | --all what to install NEUROSPLOIT_MODE=cli|web|all
# -y, --yes no questions, use defaults NEUROSPLOIT_YES=1
# --dir PATH install dir NEUROSPLOIT_DIR (~/.neurosploit-app)
# --prefix PATH where commands are linked PREFIX (~/.local/bin)
# --ref TAG release tag or branch NEUROSPLOIT_REF (latest release)
# --build build from source NEUROSPLOIT_BUILD=1
# --port N web console port NEUROSPLOIT_WEB_PORT (4173)
# --service start the web console at login (systemd user / launchd)
# --no-deps skip system packages NEUROSPLOIT_NO_DEPS=1
# --run launch when done NEUROSPLOIT_RUN=1
# -h, --help
set -euo pipefail
REPO_SLUG="JoasASantos/NeuroSploit"
REPO="https://github.com/${REPO_SLUG}.git"
REPO_URL="https://github.com/${REPO_SLUG}.git"
FALLBACK_REF="v4.5.0"
NODE_MIN=18
NODE_LINE="latest-v22.x" # used only when the system cannot provide Node >= 18
MODE="${NEUROSPLOIT_MODE:-}"
YES="${NEUROSPLOIT_YES:-0}"
DIR="${NEUROSPLOIT_DIR:-$HOME/.neurosploit-app}"
PREFIX="${PREFIX:-$HOME/.local/bin}"
REF="${NEUROSPLOIT_REF:-}"
BUILD="${NEUROSPLOIT_BUILD:-0}"
WEB_PORT="${NEUROSPLOIT_WEB_PORT:-4173}"
SERVICE="${NEUROSPLOIT_SERVICE:-}"
NO_DEPS="${NEUROSPLOIT_NO_DEPS:-0}"
RUN_NOW="${NEUROSPLOIT_RUN:-}"
c() { printf '\033[%sm%s\033[0m\n' "$1" "$2"; }
say(){ c '1;35' " ▌ $*"; }
ok() { c '1;32' " ✓ $*"; }
warn(){ c '1;33' " ! $*"; }
die(){ c '1;31' " ✗ $*"; exit 1; }
usage() {
if [ -f "${BASH_SOURCE[0]:-}" ]; then sed -n '2,26p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
else echo "Options: --cli | --web | --all, --yes, --dir, --prefix, --ref, --build, --port, --service, --no-deps, --run"; fi
exit 0
}
while [ $# -gt 0 ]; do
case "$1" in
--cli) MODE=cli ;;
--web) MODE=web ;;
--all|--both) MODE=all ;;
-y|--yes) YES=1 ;;
--dir) DIR="$2"; shift ;;
--prefix) PREFIX="$2"; shift ;;
--ref) REF="$2"; shift ;;
--build) BUILD=1 ;;
--port) WEB_PORT="$2"; shift ;;
--service) SERVICE=1 ;;
--no-service) SERVICE=0 ;;
--no-deps) NO_DEPS=1 ;;
--run) RUN_NOW=1 ;;
-h|--help) usage ;;
*) printf 'Unknown option: %s (see --help)\n' "$1" >&2; exit 2 ;;
esac
shift
done
# ---------------------------------------------------------------- output ----
if [ -t 1 ]; then B=$'\033[1m'; D=$'\033[2m'; R=$'\033[0m'; P=$'\033[1;35m'; G=$'\033[1;32m'; Y=$'\033[1;33m'; E=$'\033[1;31m'
else B=; D=; R=; P=; G=; Y=; E=; fi
STEP=0
step() { STEP=$((STEP + 1)); printf '\n%s[%s] %s%s\n' "$B" "$STEP" "$*" "$R"; }
say() { printf ' %s›%s %s\n' "$P" "$R" "$*"; }
ok() { printf ' %s✓%s %s\n' "$G" "$R" "$*"; }
warn() { printf ' %s!%s %s\n' "$Y" "$R" "$*"; }
die() { printf ' %s✗ %s%s\n' "$E" "$*" "$R" >&2; exit 1; }
have() { command -v "$1" >/dev/null 2>&1; }
# Questions read from the terminal even under `curl | bash`.
TTY=0
if [ "$YES" != "1" ] && [ -r /dev/tty ] && { exec 3</dev/tty; } 2>/dev/null; then TTY=1; fi
ask() { # ask <prompt> <default y|n> → 0 for yes
local def="$2" ans=""
if [ "$TTY" != "1" ]; then [ "$def" = "y" ]; return; fi
printf ' %s?%s %s %s ' "$P" "$R" "$1" "$([ "$def" = y ] && echo '[Y/n]' || echo '[y/N]')"
read -r ans <&3 || ans=""
ans="$(printf '%s' "$ans" | tr '[:upper:]' '[:lower:]')"
[ -z "$ans" ] && ans="$def"
case "$ans" in y|yes|s|sim) return 0 ;; *) return 1 ;; esac
}
cat <<'BANNER'
███╗ ██╗███████╗██╗ ██╗██████╗ ██████╗
████╗ ██║██╔════╝██║ ██║██╔══██╗██╔═══██╗ NeuroSploit installer
██╔██╗ ██║█████╗ ██║ ██║██████╔╝██║ ██║ v4.4.2 — Rust harness
██╔██╗ ██║█████╗ ██║ ██║██████╔╝██║ ██║ CLI + web console
██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██║ ██║ by Joas A Santos
██║ ╚████║███████╗╚██████╔╝██║ ██║╚██████╔╝ & Red Team Leaders
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ v4.4.2
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝
BANNER
# ---- platform detection (Linux / macOS / Windows-WSL · x64 / arm64) ----
# -------------------------------------------------------------- platform ----
OS_RAW="$(uname -s)"; ARCH_RAW="$(uname -m)"
case "$OS_RAW" in
Linux*) OS="linux" ;;
Darwin*) OS="macos" ;;
MINGW*|MSYS*|CYGWIN*) OS="windows" ;;
*) OS="$OS_RAW" ;;
Linux*) OS=linux ;;
Darwin*) OS=macos ;;
MINGW*|MSYS*|CYGWIN*) die "Native Windows: run setup.bat (or install.ps1). This script works inside WSL." ;;
*) die "Unsupported OS: $OS_RAW" ;;
esac
case "$ARCH_RAW" in
x86_64|amd64) ARCH="x64" ;;
arm64|aarch64) ARCH="arm64" ;;
x86_64|amd64) ARCH=x64 ;;
arm64|aarch64) ARCH=arm64 ;;
*) ARCH="$ARCH_RAW" ;;
esac
PLAT="${OS}-${ARCH}"
say "Platform: $PLAT"
[ "$OS" = "windows" ] && warn "Native Windows: prefer install.ps1 (PowerShell). This path works under WSL2/Git Bash."
DISTRO=""
if [ "$OS" = linux ] && [ -r /etc/os-release ]; then DISTRO="$(. /etc/os-release && echo "${PRETTY_NAME:-$ID}")"; fi
grep -qi microsoft /proc/version 2>/dev/null && DISTRO="$DISTRO (WSL)"
# Script dir when run from a checkout (not `curl | bash`): lets us reuse local sources.
LOCAL_SRC=""
if [ -n "${BASH_SOURCE[0]:-}" ] && [ -f "${BASH_SOURCE[0]}" ]; then
_here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
[ -f "$_here/neurosploit-rs/Cargo.toml" ] && [ -f "$_here/web/server.js" ] && LOCAL_SRC="$_here"
fi
# ------------------------------------------------------------ what to install
if [ -z "$MODE" ]; then
if [ "$TTY" = "1" ]; then
printf '\n %sWhat do you want to install?%s\n' "$B" "$R"
printf ' %s1%s CLI only %sterminal agent: neurosploit run / REPL%s\n' "$B" "$R" "$D" "$R"
printf ' %s2%s Web console + CLI %sbrowser UI on http://localhost:%s (needs Node.js)%s\n' "$B" "$R" "$D" "$WEB_PORT" "$R"
printf ' %s3%s Everything %sweb console + CLI + full recon toolset (nmap, ffuf, rustscan, typst…)%s\n' "$B" "$R" "$D" "$R"
printf ' %s?%s Choice [3]: ' "$P" "$R"
read -r _c <&3 || _c=""
case "${_c:-3}" in 1|cli) MODE=cli ;; 2|web) MODE=web ;; *) MODE=all ;; esac
else
MODE=all
fi
fi
case "$MODE" in cli|web|all) ;; *) die "NEUROSPLOIT_MODE must be cli, web or all (got: $MODE)" ;; esac
WANT_WEB=0; [ "$MODE" != cli ] && WANT_WEB=1
printf '\n %sPlan%s %s · %s%s\n' "$B" "$R" "$PLAT" "${DISTRO:-$OS}" ""
printf ' mode %s%s%s → %s\n' "$B" "$MODE" "$R" "$DIR"
printf ' commands linked in %s\n' "$PREFIX"
[ -n "$LOCAL_SRC" ] && printf ' local checkout %s\n' "$LOCAL_SRC"
TMP="$(mktemp -d 2>/dev/null || mktemp -d -t neurosploit)"
cleanup() { rm -rf "$TMP"; }
trap cleanup EXIT
dl() { # dl <url> <out>
if command -v curl >/dev/null 2>&1; then curl -fsSL "$1" -o "$2"
elif command -v wget >/dev/null 2>&1; then wget -qO "$2" "$1"
if have curl; then curl -fsL --retry 3 --connect-timeout 20 "$1" -o "$2"
elif have wget; then wget -q --tries=3 -O "$2" "$1"
else return 1; fi
}
# ---- resolve the release tag (latest, unless pinned) ----
REF="${NEUROSPLOIT_REF:-}"
if [ -z "$REF" ]; then
REF="$(dl "https://api.github.com/repos/${REPO_SLUG}/releases/latest" /dev/stdout 2>/dev/null \
| grep -m1 '"tag_name"' | sed -E 's/.*"tag_name" *: *"([^"]+)".*/\1/' || true)"
# ------------------------------------------------------- package managers ---
SUDO=""
if [ "$(id -u)" != "0" ]; then
if have sudo; then SUDO="sudo"; else SUDO="__none__"; fi
fi
[ -z "$REF" ] && REF="v4.4.2"
say "Release: $REF"
PKG=""
if [ "$OS" = macos ]; then PKG=brew
elif have apt-get; then PKG=apt
elif have dnf; then PKG=dnf
elif have yum; then PKG=yum
elif have pacman; then PKG=pacman
elif have zypper; then PKG=zypper
elif have apk; then PKG=apk; fi
brew_env() { # put Homebrew on PATH for this process (Apple Silicon / Intel / Linuxbrew)
local b
for b in /opt/homebrew/bin/brew /usr/local/bin/brew /home/linuxbrew/.linuxbrew/bin/brew; do
[ -x "$b" ] && { eval "$("$b" shellenv)"; return 0; }
done
return 1
}
APT_UPDATED=0
pkg_install() { # best-effort; never aborts the installer
[ "$NO_DEPS" = "1" ] && return 1
[ -n "$PKG" ] || return 1
if [ "$PKG" != brew ] && [ "$SUDO" = "__none__" ]; then
warn "not root and no sudo — cannot install: $*"; return 1
fi
local s="$SUDO"; [ "$s" = "__none__" ] && s=""
local log="$TMP/pkg.log" rc=0
case "$PKG" in
brew) have brew || return 1; HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_ENV_HINTS=1 brew install "$@" >"$log" 2>&1 || rc=$? ;;
apt) if [ "$APT_UPDATED" = 0 ]; then $s apt-get update -qq >"$log" 2>&1 || true; APT_UPDATED=1; fi
DEBIAN_FRONTEND=noninteractive $s apt-get install -y -qq --no-install-recommends "$@" >"$log" 2>&1 || rc=$? ;;
dnf) $s dnf install -y -q "$@" >"$log" 2>&1 || rc=$? ;;
yum) $s yum install -y -q "$@" >"$log" 2>&1 || rc=$? ;;
pacman) $s pacman -S --noconfirm --needed "$@" >"$log" 2>&1 || rc=$? ;;
zypper) $s zypper --non-interactive install "$@" >"$log" 2>&1 || rc=$? ;;
apk) $s apk add --no-cache "$@" >"$log" 2>&1 || rc=$? ;;
esac
if [ "$rc" != 0 ]; then
warn "$PKG could not install: $* (exit $rc)"
tail -n 4 "$log" 2>/dev/null | sed 's/^/ /'
return 1
fi
return 0
}
# ensure <cmd> <pkg-for-apt> <pkg-for-others> [label]
ensure() {
local cmd="$1" apt_pkg="$2" pkg="$3" label="${4:-$1}" name
if have "$cmd"; then ok "$label"; return 0; fi
case "$PKG" in apt) name="$apt_pkg" ;; *) name="$pkg" ;; esac
[ -z "$name" ] && { warn "$label missing (no package for $PKG)"; return 1; }
say "installing $label…"
pkg_install $name || true
hash -r 2>/dev/null || true
if have "$cmd"; then ok "$label installed"; return 0; fi
warn "$label still missing — install it manually"; return 1
}
# ---------------------------------------------------- 1. base prerequisites
step "Base prerequisites"
if [ "$NO_DEPS" = "1" ]; then
warn "system packages skipped (--no-deps) — only checking"
fi
if [ "$OS" = macos ]; then
if ! xcode-select -p >/dev/null 2>&1; then
warn "Xcode Command Line Tools are missing (git, compilers)."
if [ "$NO_DEPS" != 1 ] && ask "Install them now? A system dialog will open" y; then
xcode-select --install >/dev/null 2>&1 || true
say "Finish the dialog, then press Enter to continue…"
[ "$TTY" = 1 ] && read -r _ <&3 || true
fi
fi
if ! have brew && ! brew_env; then
if [ "$NO_DEPS" != 1 ] && ask "Homebrew is not installed. Install it (recommended, needs your password)?" y; then
say "installing Homebrew…"
if [ "$TTY" = 1 ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" <&3 || warn "Homebrew install failed"
else
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || warn "Homebrew install failed"
fi
brew_env || true
fi
fi
have brew && ok "Homebrew $(brew --version 2>/dev/null | head -1 | awk '{print $2}')" || { warn "no Homebrew — system tools will be skipped"; PKG=""; }
else
[ -n "$PKG" ] && ok "package manager: $PKG" || warn "no supported package manager — system tools will be skipped"
[ "$SUDO" = "__none__" ] && warn "running without root or sudo — system packages cannot be installed"
fi
# TLS roots first: minimal images ship without them and every download is HTTPS.
case "$PKG" in
apt) dpkg -s ca-certificates >/dev/null 2>&1 || pkg_install ca-certificates || true ;;
dnf|yum|zypper|apk|pacman) [ -e /etc/ssl/certs/ca-certificates.crt ] || [ -e /etc/pki/tls/certs/ca-bundle.crt ] || pkg_install ca-certificates || true ;;
esac
have curl || have wget || ensure curl curl curl || die "curl or wget is required."
ensure git git git || true
have tar || ensure tar tar tar || die "tar is required."
# --------------------------------------------------------- 2. release ref ---
if [ -z "$REF" ]; then
REF="$(curl -fsSL https://api.github.com/repos/${REPO_SLUG}/releases/latest 2>/dev/null \
| grep -m1 '"tag_name"' | sed -E 's/.*"tag_name" *: *"([^"]+)".*/\1/' || true)"
[ -z "$REF" ] && REF="$FALLBACK_REF"
fi
# ------------------------------------------------- source tree (on demand) --
SRC_TREE=""
source_tree() { # sets SRC_TREE to a directory holding neurosploit-rs/, agents_md/, web/
[ -n "$SRC_TREE" ] && return 0
if [ -n "$LOCAL_SRC" ]; then SRC_TREE="$LOCAL_SRC"; return 0; fi
local co="$DIR/src"
if have git; then
if [ -d "$co/.git" ]; then
say "updating source checkout ($REF)…"
git -C "$co" fetch -q --depth 1 origin "$REF" 2>/dev/null && git -C "$co" checkout -q FETCH_HEAD 2>/dev/null \
|| git -C "$co" pull -q 2>/dev/null || warn "could not update $co — using it as is"
else
say "cloning $REPO_SLUG ($REF)…"
mkdir -p "$DIR"
git clone -q --depth 1 --branch "$REF" "$REPO_URL" "$co" 2>/dev/null || git clone -q --depth 1 "$REPO_URL" "$co" \
|| die "git clone failed"
fi
SRC_TREE="$co"; return 0
fi
# No git: the source tarball is enough for agents + web console.
say "downloading source archive ($REF)…"
dl "https://codeload.github.com/${REPO_SLUG}/tar.gz/${REF}" "$TMP/src.tar.gz" || die "could not download sources"
mkdir -p "$TMP/src" && tar -xzf "$TMP/src.tar.gz" -C "$TMP/src"
SRC_TREE="$(find "$TMP/src" -mindepth 1 -maxdepth 1 -type d | head -1)"
}
# ------------------------------------------------------- 3. the CLI binary --
step "NeuroSploit CLI ($REF)"
mkdir -p "$DIR"
BIN="$DIR/neurosploit"
bin_works() { [ -x "$BIN" ] && NEUROSPLOIT_BASE="$DIR" "$BIN" --version >/dev/null 2>&1; }
installed=0
if [ "${NEUROSPLOIT_BUILD:-0}" != "1" ] && [ "$OS" != "windows" ]; then
# ---- try the prebuilt asset (no Rust needed) ----
if [ "$BUILD" != 1 ]; then
ASSET="neurosploit-${REF}-${PLAT}.tar.gz"
URL="https://github.com/${REPO_SLUG}/releases/download/${REF}/${ASSET}"
TMP="$(mktemp -d)"
say "Downloading prebuilt binary: $ASSET"
if dl "$URL" "$TMP/a.tar.gz"; then
mkdir -p "$DIR"
tar -xzf "$TMP/a.tar.gz" -C "$TMP" 2>/dev/null || die "download was not a valid archive"
SRC="$(find "$TMP" -maxdepth 2 -name neurosploit -type f | head -1)"
[ -n "$SRC" ] || die "extracted archive has no neurosploit binary"
SRCDIR="$(dirname "$SRC")"
rm -rf "$DIR/neurosploit" "$DIR/agents_md"
cp "$SRCDIR/neurosploit" "$DIR/neurosploit"
cp -R "$SRCDIR/agents_md" "$DIR/agents_md"
chmod +x "$DIR/neurosploit"
rm -rf "$TMP"
installed=1
ok "Downloaded & unpacked → $DIR"
say "downloading $ASSET…"
if dl "https://github.com/${REPO_SLUG}/releases/download/${REF}/${ASSET}" "$TMP/bin.tar.gz" \
&& mkdir -p "$TMP/bin" && tar -xzf "$TMP/bin.tar.gz" -C "$TMP/bin" 2>/dev/null; then
f="$(find "$TMP/bin" -maxdepth 3 -name neurosploit -type f | head -1)"
if [ -n "$f" ]; then
d="$(dirname "$f")"
cp "$f" "$BIN.new" && chmod +x "$BIN.new" && mv -f "$BIN.new" "$BIN"
if [ -d "$d/agents_md" ]; then rm -rf "$DIR/agents_md"; cp -R "$d/agents_md" "$DIR/agents_md"; fi
[ "$OS" = macos ] && xattr -d com.apple.quarantine "$BIN" 2>/dev/null || true
if bin_works; then installed=1; ok "prebuilt binary installed"
else warn "prebuilt binary does not run on this system (old glibc?) — building from source"; fi
fi
else
rm -rf "$TMP"
warn "No prebuilt asset for $PLAT ($REF) — building from source instead."
warn "no prebuilt binary for $PLAT ($REF) — building from source"
fi
fi
if [ "$installed" != "1" ]; then
# ---- build from source (needs git + Rust) ----
command -v git >/dev/null 2>&1 || die "git is required to build from source."
if ! command -v cargo >/dev/null 2>&1; then [ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" || true; fi
if ! command -v cargo >/dev/null 2>&1; then
say "Rust not found — installing rustup (stable, minimal)…"
curl --proto '=https' --tlsv1.2 -fsSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal
if [ "$installed" != 1 ]; then
# Build toolchain: a C linker + Rust (TLS is rustls, so no OpenSSL headers needed).
if [ "$OS" = linux ] && ! have cc; then
case "$PKG" in
apt) pkg_install build-essential pkg-config || true ;;
dnf|yum) pkg_install gcc gcc-c++ make pkgconf-pkg-config || true ;;
pacman) pkg_install base-devel || true ;;
zypper) pkg_install gcc gcc-c++ make pkg-config || true ;;
apk) pkg_install build-base pkgconf || true ;;
esac
fi
have cc || have clang || warn "no C compiler found — the Rust build will likely fail"
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
# rustup present but no default toolchain → cargo exists yet cannot run.
if have rustup && ! cargo --version >/dev/null 2>&1; then
say "setting the default Rust toolchain (stable)…"; rustup default stable >/dev/null 2>&1 || true
fi
if ! have cargo || ! cargo --version >/dev/null 2>&1; then
say "installing Rust (rustup, stable, minimal profile)…"
curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --profile minimal >/dev/null \
|| die "rustup install failed"
. "$HOME/.cargo/env"
fi
ok "Rust: $(cargo --version)"
SRC_CO="$DIR/src"
if [ -d "$SRC_CO/.git" ]; then
say "Updating checkout…"; git -C "$SRC_CO" fetch --depth 1 origin "$REF" 2>/dev/null && git -C "$SRC_CO" checkout -q FETCH_HEAD 2>/dev/null || git -C "$SRC_CO" pull -q || true
ok "$(cargo --version)"
have git || die "git is required to build from source"
source_tree
say "compiling (first build downloads crates, takes a few minutes)…"
if ! ( cd "$SRC_TREE/neurosploit-rs" && cargo build --release ) >"$TMP/build.log" 2>&1; then
grep -E '^error' -A6 "$TMP/build.log" | head -40 | sed 's/^/ /'
die "cargo build failed"
fi
cp "$SRC_TREE/neurosploit-rs/target/release/neurosploit" "$BIN.new" && chmod +x "$BIN.new" && mv -f "$BIN.new" "$BIN"
rm -rf "$DIR/agents_md"; cp -R "$SRC_TREE/agents_md" "$DIR/agents_md"
bin_works || die "the built binary does not run"
ok "built from source"
fi
VERSION="$(NEUROSPLOIT_BASE="$DIR" "$BIN" --version 2>/dev/null | head -1 || echo neurosploit)"
ok "$VERSION → $BIN"
mkdir -p "$PREFIX"
ln -sf "$BIN" "$PREFIX/neurosploit"
ok "linked $PREFIX/neurosploit"
# ------------------------------------------------------------- 4. Node.js ---
NODE_BIN=""
node_ok() { # node_ok <node-binary>
local v; v="$("$1" -v 2>/dev/null | sed 's/^v//' | cut -d. -f1)"
[ -n "$v" ] && [ "$v" -ge "$NODE_MIN" ] 2>/dev/null
}
node_from_nodejs_org() { # official tarball into $DIR/runtime/node — no root needed
local nos narch sums file
case "$OS" in macos) nos=darwin ;; *) nos=linux ;; esac
case "$ARCH" in x64) narch=x64 ;; arm64) narch=arm64 ;; *) return 1 ;; esac
[ -f /etc/alpine-release ] && return 1 # glibc builds do not run on musl
dl "https://nodejs.org/dist/${NODE_LINE}/SHASUMS256.txt" "$TMP/SHASUMS256.txt" || return 1
file="$(grep -oE "node-v[0-9.]+-${nos}-${narch}\.tar\.gz" "$TMP/SHASUMS256.txt" | head -1)"
[ -n "$file" ] || return 1
say "downloading $file from nodejs.org…"
dl "https://nodejs.org/dist/${NODE_LINE}/${file}" "$TMP/$file" || return 1
sums="$(grep " ${file}\$" "$TMP/SHASUMS256.txt" | awk '{print $1}')"
local got
if have sha256sum; then got="$(sha256sum "$TMP/$file" | awk '{print $1}')"; else got="$(shasum -a 256 "$TMP/$file" | awk '{print $1}')"; fi
[ "$got" = "$sums" ] || { warn "Node.js checksum mismatch — refusing to install it"; return 1; }
rm -rf "$DIR/runtime/node" && mkdir -p "$DIR/runtime"
tar -xzf "$TMP/$file" -C "$DIR/runtime" && mv "$DIR/runtime/${file%.tar.gz}" "$DIR/runtime/node"
}
if [ "$WANT_WEB" = 1 ]; then
step "Node.js (>= $NODE_MIN, for the web console)"
if [ -x "$DIR/runtime/node/bin/node" ] && node_ok "$DIR/runtime/node/bin/node"; then NODE_BIN="$DIR/runtime/node/bin/node"
elif have node && node_ok "$(command -v node)"; then NODE_BIN="$(command -v node)"
else
say "Cloning $REPO ($REF)…"; git clone --depth 1 --branch "$REF" "$REPO" "$SRC_CO" 2>/dev/null || git clone --depth 1 "$REPO" "$SRC_CO"
have node && warn "node $(node -v) is too old"
case "$PKG" in
brew) pkg_install node || true ;;
apt) pkg_install nodejs npm || true ;;
dnf|yum|zypper) pkg_install nodejs npm || true ;;
pacman) pkg_install nodejs npm || true ;;
apk) pkg_install nodejs npm || true ;;
esac
hash -r 2>/dev/null || true
if have node && node_ok "$(command -v node)"; then NODE_BIN="$(command -v node)"
elif node_from_nodejs_org && node_ok "$DIR/runtime/node/bin/node"; then NODE_BIN="$DIR/runtime/node/bin/node"
fi
fi
[ -n "$NODE_BIN" ] || die "could not get Node.js >= $NODE_MIN — install it from https://nodejs.org and re-run"
ok "node $("$NODE_BIN" -v) → $NODE_BIN"
# ------------------------------------------------------- 5. web console ---
step "Web console"
source_tree
[ -f "$SRC_TREE/web/server.js" ] || die "web console not found in $SRC_TREE"
rm -rf "$DIR/web.new" && mkdir -p "$DIR/web.new"
cp -R "$SRC_TREE/web/server.js" "$SRC_TREE/web/package.json" "$SRC_TREE/web/public" "$DIR/web.new/"
rm -rf "$DIR/web" && mv "$DIR/web.new" "$DIR/web"
mkdir -p "$DIR/runs" "$DIR/.neurosploit"
ok "deployed → $DIR/web (config and runs are kept between updates)"
mkdir -p "$DIR/bin"
cat > "$DIR/bin/neurosploit-web" <<LAUNCHER
#!/usr/bin/env bash
# NeuroSploit web console launcher (written by setup.sh).
# neurosploit-web [--port N] [--host ADDR] [--open]
# Binds to 127.0.0.1 by default; use --host 0.0.0.0 only on a trusted network.
DIR="$DIR"
NODE="$NODE_BIN"
[ -x "\$NODE" ] || NODE="\$(command -v node)"
PORT="\${NEUROSPLOIT_WEB_PORT:-$WEB_PORT}"
HOST="\${NEUROSPLOIT_WEB_HOST:-127.0.0.1}"
OPEN=0
while [ \$# -gt 0 ]; do
case "\$1" in
--port) PORT="\$2"; shift ;;
--host) HOST="\$2"; shift ;;
--open) OPEN=1 ;;
-h|--help) sed -n '2,4p' "\$0"; exit 0 ;;
esac
shift
done
export NEUROSPLOIT_BASE="\$DIR" NEUROSPLOIT_BIN="\$DIR/neurosploit" NEUROSPLOIT_WEB_PORT="\$PORT" NEUROSPLOIT_WEB_HOST="\$HOST"
export PATH="\$DIR:\$PATH"
if [ "\$OPEN" = 1 ]; then
( sleep 1.5
url="http://localhost:\$PORT"
if command -v open >/dev/null 2>&1; then open "\$url"
elif command -v xdg-open >/dev/null 2>&1; then xdg-open "\$url" >/dev/null 2>&1
elif command -v wslview >/dev/null 2>&1; then wslview "\$url"; fi ) &
fi
cd "\$DIR/web" && exec "\$NODE" server.js
LAUNCHER
chmod +x "$DIR/bin/neurosploit-web"
ln -sf "$DIR/bin/neurosploit-web" "$PREFIX/neurosploit-web"
ok "linked $PREFIX/neurosploit-web"
# Optional: start at login.
if [ -z "$SERVICE" ]; then
if [ "$TTY" = 1 ] && ask "Start the web console automatically at login?" n; then SERVICE=1; else SERVICE=0; fi
fi
if [ "$SERVICE" = 1 ]; then
if [ "$OS" = macos ]; then
PL="$HOME/Library/LaunchAgents/io.neurosploit.web.plist"
mkdir -p "$(dirname "$PL")" "$DIR/logs"
cat > "$PL" <<PLIST
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>io.neurosploit.web</string>
<key>ProgramArguments</key><array><string>$DIR/bin/neurosploit-web</string></array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>StandardOutPath</key><string>$DIR/logs/web.log</string>
<key>StandardErrorPath</key><string>$DIR/logs/web.log</string>
</dict></plist>
PLIST
launchctl unload "$PL" >/dev/null 2>&1 || true
launchctl load -w "$PL" >/dev/null 2>&1 && ok "launchd agent loaded (logs: $DIR/logs/web.log)" || warn "could not load $PL"
elif have systemctl && systemctl --user show-environment >/dev/null 2>&1; then
UNIT="$HOME/.config/systemd/user/neurosploit-web.service"
mkdir -p "$(dirname "$UNIT")"
cat > "$UNIT" <<UNIT
[Unit]
Description=NeuroSploit web console
After=network-online.target
[Service]
ExecStart=$DIR/bin/neurosploit-web
Restart=on-failure
[Install]
WantedBy=default.target
UNIT
systemctl --user daemon-reload && systemctl --user enable --now neurosploit-web.service >/dev/null 2>&1 \
&& ok "systemd user service enabled (journalctl --user -u neurosploit-web)" || warn "could not enable the systemd user service"
else
warn "no launchd/systemd user session — start it with: neurosploit-web"
fi
fi
say "Building release binary (first build downloads crates)…"
( cd "$SRC_CO/neurosploit-rs" && cargo build --release )
cp "$SRC_CO/neurosploit-rs/target/release/neurosploit" "$DIR/neurosploit"
rm -rf "$DIR/agents_md"; cp -R "$SRC_CO/agents_md" "$DIR/agents_md"
chmod +x "$DIR/neurosploit"
ok "Built → $DIR"
fi
# ---- install on PATH ----
mkdir -p "$PREFIX"
ln -sf "$DIR/neurosploit" "$PREFIX/neurosploit"
ok "Linked → $PREFIX/neurosploit"
# --------------------------------------------------------- 6. tools ---------
step "Testing tools"
ensure nmap nmap nmap "nmap (port scans)" || true
if [ "$MODE" = all ]; then
ensure jq jq jq "jq" || true
ensure python3 python3 python3 "python3" || true
case "$PKG" in
brew|pacman|apk) ensure ffuf ffuf ffuf "ffuf (content discovery)" || true ;;
apt) ensure ffuf ffuf ffuf "ffuf (content discovery)" || true ;;
*) have ffuf && ok "ffuf" || warn "ffuf optional — install with: go install github.com/ffuf/ffuf/v2@latest" ;;
esac
if have rustscan; then ok "rustscan"
elif [ "$PKG" = brew ]; then ensure rustscan "" rustscan "rustscan (fast port scan)" || true
elif have cargo; then say "installing rustscan (cargo)…"; cargo install --quiet rustscan >/dev/null 2>&1 && ok "rustscan installed" || warn "rustscan optional — skipped"
else warn "rustscan optional — skipped (needs Homebrew or Rust)"; fi
fi
# typst renders PDF reports.
if have typst; then ok "typst (PDF reports)"
elif [ "$PKG" = brew ] && pkg_install typst; then ok "typst installed"
else
TT=""
case "$PLAT" in
linux-x64) TT=x86_64-unknown-linux-musl ;; linux-arm64) TT=aarch64-unknown-linux-musl ;;
macos-x64) TT=x86_64-apple-darwin ;; macos-arm64) TT=aarch64-apple-darwin ;;
esac
if [ -n "$TT" ] && ! have xz && [ "$OS" = linux ]; then pkg_install xz-utils 2>/dev/null || pkg_install xz 2>/dev/null || true; fi
if [ -n "$TT" ] && have xz && dl "https://github.com/typst/typst/releases/latest/download/typst-${TT}.tar.xz" "$TMP/typst.tar.xz" \
&& mkdir -p "$TMP/typst" && tar -xJf "$TMP/typst.tar.xz" -C "$TMP/typst" 2>/dev/null; then
mkdir -p "$DIR/runtime/bin"
cp "$(find "$TMP/typst" -name typst -type f | head -1)" "$DIR/runtime/bin/typst" && chmod +x "$DIR/runtime/bin/typst"
ln -sf "$DIR/runtime/bin/typst" "$PREFIX/typst"
ok "typst installed → $PREFIX/typst"
else
warn "typst optional (PDF reports) — HTML/Markdown reports still work"
fi
fi
for c in claude codex gemini; do have "$c" && ok "$c CLI found (subscription login)"; done
# ---- write a source-able env script (activate in the CURRENT shell) ----
# ------------------------------------------------- optional C2 MCP servers --
# Unchanged opt-in behaviour from earlier installers; nothing runs unless the
# matching NEUROSPLOIT_*_C2=1 variable is set.
if [ "${NEUROSPLOIT_SLIVER_C2:-0}" = 1 ]; then
SLIVER_MCP_DIR="${NEUROSPLOIT_SLIVER_MCP_PATH:-$DIR/sec-sliver-c2-mcp}"
if [ -d "$SLIVER_MCP_DIR/dist" ]; then ok "Sliver C2 MCP present"
elif have npm; then
git clone -q --depth 1 https://github.com/schwarztim/sec-sliver-c2-mcp.git "$SLIVER_MCP_DIR" 2>/dev/null \
&& ( cd "$SLIVER_MCP_DIR" && npm install --production >/dev/null 2>&1 && npm run build >/dev/null 2>&1 ) \
&& ok "Sliver C2 MCP installed" || warn "Sliver C2 MCP install failed"
else warn "Sliver C2 MCP needs npm — skipped"; fi
fi
if [ "${NEUROSPLOIT_ADAPTIX_C2:-0}" = 1 ]; then
ADAPTIX_MCP_DIR="${NEUROSPLOIT_ADAPTIX_MCP_PATH:-$DIR/AdaptixC2_mcp}"
if [ -f "$ADAPTIX_MCP_DIR/AdaptixC2_mcp.py" ]; then ok "AdaptixC2 MCP present"
elif have pip3; then
git clone -q --depth 1 https://github.com/0xb11a1/AdaptixC2_mcp.git "$ADAPTIX_MCP_DIR" 2>/dev/null \
&& ( cd "$ADAPTIX_MCP_DIR" && pip3 install -q -r requirments.txt >/dev/null 2>&1 ) \
&& ok "AdaptixC2 MCP installed" || warn "AdaptixC2 MCP install failed"
else warn "AdaptixC2 MCP needs pip3 — skipped"; fi
fi
# ------------------------------------------------------ 7. shell setup ------
step "Shell environment"
cat > "$DIR/env.sh" <<EOF
# NeuroSploit env — \`source\` this to use neurosploit in the current shell.
export NEUROSPLOIT_BASE="$DIR"
export NEUROSPLOIT="$DIR/neurosploit"
case ":\$PATH:" in *":$PREFIX:"*) : ;; *) export PATH="$PREFIX:\$PATH" ;; esac
EOF
ok "Wrote env script → $DIR/env.sh (source it to activate now)"
ok "Version: $(NEUROSPLOIT_BASE="$DIR" "$DIR/neurosploit" --version 2>/dev/null || echo neurosploit)"
# ---- persist env (PATH + NEUROSPLOIT_BASE) so it runs from any folder ----
persist() { # append an idempotent block to a shell rc that exists
local rc="$1"; [ -e "$rc" ] || return 0
grep -q 'NEUROSPLOIT_BASE' "$rc" 2>/dev/null && return 0
{ echo ''; echo '# NeuroSploit (added by setup.sh)'
echo "export NEUROSPLOIT_BASE=\"$DIR\""
echo "export PATH=\"$PREFIX:\$PATH\""; } >> "$rc"
ok "Configured $rc"
persist() { # idempotent block in an rc file
local rc="$1"
[ -e "$rc" ] || touch "$rc"
if grep -q '# >>> neurosploit >>>' "$rc" 2>/dev/null; then
# refresh the managed block (install dir may have changed)
awk '/# >>> neurosploit >>>/{skip=1} !skip{print} /# <<< neurosploit <<</{skip=0}' "$rc" > "$rc.ns.tmp" && cat "$rc.ns.tmp" > "$rc" && rm -f "$rc.ns.tmp"
elif grep -q 'NEUROSPLOIT_BASE' "$rc" 2>/dev/null; then
ok "$rc already sets NEUROSPLOIT_BASE (left untouched)"; return 0
fi
{ echo '# >>> neurosploit >>>'
echo "[ -f \"$DIR/env.sh\" ] && . \"$DIR/env.sh\""
echo '# <<< neurosploit <<<'; } >> "$rc"
ok "configured $rc"
}
SHELL_NAME="$(basename "${SHELL:-bash}")"
case "$SHELL_NAME" in
zsh) touch "$HOME/.zshrc"; persist "$HOME/.zshrc" ;;
bash) touch "$HOME/.bashrc"; persist "$HOME/.bashrc"; persist "$HOME/.bash_profile" ;;
*) touch "$HOME/.profile"; persist "$HOME/.profile" ;;
case "$(basename "${SHELL:-bash}")" in
zsh) persist "$HOME/.zshrc" ;;
bash) persist "$HOME/.bashrc"; [ "$OS" = macos ] && persist "$HOME/.bash_profile" ;;
*) persist "$HOME/.profile" ;;
esac
if [ -d "$HOME/.config/fish" ]; then
FCONF="$HOME/.config/fish/config.fish"
if ! grep -q 'NEUROSPLOIT_BASE' "$FCONF" 2>/dev/null; then
{ echo ''; echo '# NeuroSploit'; echo "set -gx NEUROSPLOIT_BASE \"$DIR\""; echo "set -gx PATH \"$PREFIX\" \$PATH"; } >> "$FCONF"
ok "Configured $FCONF"
{ echo ''; echo '# NeuroSploit'; echo "set -gx NEUROSPLOIT_BASE \"$DIR\""; echo "fish_add_path \"$PREFIX\""; } >> "$FCONF"
ok "configured $FCONF"
fi
fi
# ---- dependencies: detect, and install the ones a package manager can ----
# Core recon/report tools. Rust is already handled above. Auto-install is
# best-effort: it never fails the install, and is skipped with NEUROSPLOIT_NO_DEPS=1.
PKG=""; SUDO=""
if command -v apt-get >/dev/null 2>&1; then PKG="apt"
elif command -v brew >/dev/null 2>&1; then PKG="brew"
elif command -v dnf >/dev/null 2>&1; then PKG="dnf"
elif command -v pacman >/dev/null 2>&1; then PKG="pacman"
elif command -v apk >/dev/null 2>&1; then PKG="apk"; fi
[ "$(id -u)" = "0" ] || command -v sudo >/dev/null 2>&1 && [ "$(id -u)" != "0" ] && SUDO="sudo"
pkg_install() { # pkg_install <name...> — best-effort: never aborts the installer (set -e)
[ -n "$PKG" ] || { warn "no supported package manager — install manually: $*"; return 0; }
local log; log="$(mktemp 2>/dev/null || echo /tmp/neurosploit-pkg.log)"
local rc=0
case "$PKG" in
apt) { $SUDO apt-get update -qq && DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y "$@"; } >"$log" 2>&1 || rc=$? ;;
brew) brew install "$@" >"$log" 2>&1 || rc=$? ;;
dnf) $SUDO dnf install -y "$@" >"$log" 2>&1 || rc=$? ;;
pacman) $SUDO pacman -Sy --noconfirm "$@" >"$log" 2>&1 || rc=$? ;;
apk) $SUDO apk add "$@" >"$log" 2>&1 || rc=$? ;;
esac
if [ "$rc" != "0" ]; then
warn "$PKG failed installing: $* (exit $rc) — last lines:"
tail -n 5 "$log" 2>/dev/null | sed 's/^/ /'
fi
rm -f "$log"
return 0
}
# Map a required command to its package name on the detected manager.
pkg_name() { # pkg_name <cmd>
case "$1" in
npx) echo "node" ;; # npx ships with node
node) [ "$PKG" = "apt" ] && echo "nodejs" || echo "node" ;;
*) echo "$1" ;;
esac
}
if [ "${NEUROSPLOIT_NO_DEPS:-0}" != "1" ]; then
say "Checking dependencies (install with the detected package manager: ${PKG:-none})…"
# Essential for the web console + recon; typst is for PDF reports (optional).
for t in curl git nmap node; do
if command -v "$t" >/dev/null 2>&1; then ok "$t present"; else
warn "$t missing — installing…"; pkg_install "$(pkg_name "$t")"
command -v "$t" >/dev/null 2>&1 && ok "$t installed" || warn "could not install $t automatically — install it manually"
fi
done
# Rust-cargo extras + report engine: install via cargo when present (no root).
if command -v cargo >/dev/null 2>&1; then
command -v rustscan >/dev/null 2>&1 || { say "installing rustscan (cargo)…"; cargo install rustscan >/dev/null 2>&1 && ok "rustscan installed" || warn "rustscan optional — skipped"; }
command -v typst >/dev/null 2>&1 || { say "installing typst (cargo)…"; cargo install typst-cli >/dev/null 2>&1 && ok "typst installed" || warn "typst optional (PDF reports) — skipped"; }
fi
# ffuf is Go; only hint it.
command -v ffuf >/dev/null 2>&1 && ok "ffuf present" || warn "ffuf optional (fuzzing) — install via your package manager or Go"
# Sliver C2 MCP server (optional — for C2 operations via MCP).
SLIVER_MCP_DIR="${NEUROSPLOIT_SLIVER_MCP_PATH:-$DIR/sec-sliver-c2-mcp}"
if [ -d "$SLIVER_MCP_DIR/dist" ]; then
ok "Sliver C2 MCP present ($SLIVER_MCP_DIR)"
elif [ "${NEUROSPLOIT_SLIVER_C2:-0}" = "1" ]; then
say "Installing Sliver C2 MCP server…"
if command -v node >/dev/null 2>&1 && command -v npm >/dev/null 2>&1; then
git clone --depth 1 https://github.com/schwarztim/sec-sliver-c2-mcp.git "$SLIVER_MCP_DIR" 2>/dev/null && \
( cd "$SLIVER_MCP_DIR" && npm install --production 2>/dev/null && npm run build 2>/dev/null ) && \
ok "Sliver C2 MCP installed ($SLIVER_MCP_DIR)" || \
warn "Sliver C2 MCP install failed — install manually: git clone + npm install + npm run build"
command -v python3 >/dev/null 2>&1 && { pip3 install sliver-py 2>/dev/null && ok "sliver-py installed" || warn "sliver-py install failed — pip3 install sliver-py"; }
else
warn "Sliver C2 MCP requires Node.js + npm — skipped"
fi
else
warn "Sliver C2 MCP not installed — set NEUROSPLOIT_SLIVER_C2=1 to install"
fi
# AdaptixC2 MCP server (optional — for AdaptixC2 operations via MCP).
ADAPTIX_MCP_DIR="${NEUROSPLOIT_ADAPTIX_MCP_PATH:-$DIR/AdaptixC2_mcp}"
if [ -f "$ADAPTIX_MCP_DIR/AdaptixC2_mcp.py" ]; then
ok "AdaptixC2 MCP present ($ADAPTIX_MCP_DIR)"
elif [ "${NEUROSPLOIT_ADAPTIX_C2:-0}" = "1" ]; then
say "Installing AdaptixC2 MCP server…"
if command -v uv >/dev/null 2>&1 || command -v pip3 >/dev/null 2>&1; then
git clone --depth 1 https://github.com/0xb11a1/AdaptixC2_mcp.git "$ADAPTIX_MCP_DIR" 2>/dev/null && \
( cd "$ADAPTIX_MCP_DIR" && { command -v uv >/dev/null 2>&1 && uv venv && uv pip install -r requirments.txt || pip3 install -r requirments.txt; } 2>/dev/null ) && \
ok "AdaptixC2 MCP installed ($ADAPTIX_MCP_DIR)" || \
warn "AdaptixC2 MCP install failed — install manually: git clone + uv pip install -r requirments.txt"
else
warn "AdaptixC2 MCP requires uv or pip3 — skipped"
fi
else
warn "AdaptixC2 MCP not installed — set NEUROSPLOIT_ADAPTIX_C2=1 to install"
fi
# Havoc C2 MCP server (optional — for Havoc C2 operations via MCP).
HAVOC_MCP_DIR="${NEUROSPLOIT_HAVOC_MCP_PATH:-$DIR/havoc-c2-mcp}"
if [ -f "$HAVOC_MCP_DIR/havoc_mcp.py" ]; then
ok "Havoc C2 MCP present ($HAVOC_MCP_DIR)"
elif [ "${NEUROSPLOIT_HAVOC_C2:-0}" = "1" ]; then
say "Installing Havoc C2 MCP server…"
if command -v python3 >/dev/null 2>&1; then
mkdir -p "$HAVOC_MCP_DIR" && \
ok "Havoc C2 MCP directory created ($HAVOC_MCP_DIR) — add havoc_mcp.py server implementation" || \
warn "Havoc C2 MCP setup failed — create $HAVOC_MCP_DIR manually"
else
warn "Havoc C2 MCP requires python3 — skipped"
fi
else
warn "Havoc C2 MCP not installed — set NEUROSPLOIT_HAVOC_C2=1 to install"
fi
# Mythic C2 MCP server (optional — for Mythic C2 operations via MCP).
MYTHIC_MCP_DIR="${NEUROSPLOIT_MYTHIC_MCP_PATH:-$DIR/mythic-c2-mcp}"
if [ -f "$MYTHIC_MCP_DIR/mythic_mcp.py" ]; then
ok "Mythic C2 MCP present ($MYTHIC_MCP_DIR)"
elif [ "${NEUROSPLOIT_MYTHIC_C2:-0}" = "1" ]; then
say "Installing Mythic C2 MCP server…"
if command -v python3 >/dev/null 2>&1; then
mkdir -p "$MYTHIC_MCP_DIR" && \
pip3 install mythic 2>/dev/null && \
ok "Mythic C2 MCP directory created ($MYTHIC_MCP_DIR) — add mythic_mcp.py server implementation" || \
warn "Mythic C2 MCP setup failed — create $MYTHIC_MCP_DIR and pip3 install mythic manually"
else
warn "Mythic C2 MCP requires python3 — skipped"
fi
else
warn "Mythic C2 MCP not installed — set NEUROSPLOIT_MYTHIC_C2=1 to install"
fi
else
say "Dependency auto-install skipped (NEUROSPLOIT_NO_DEPS=1)."
for t in curl git nmap node rustscan ffuf typst; do
command -v "$t" >/dev/null 2>&1 && ok "$t present" || warn "$t missing"
done
# ------------------------------------------------------------ summary -------
printf '\n%s ✓ NeuroSploit is installed%s (%s, mode: %s)\n\n' "$G" "$R" "$VERSION" "$MODE"
printf ' Activate in this shell: %ssource "%s/env.sh"%s (new terminals pick it up automatically)\n\n' "$B" "$DIR" "$R"
printf ' %sCLI%s\n' "$B" "$R"
printf ' neurosploit interactive session\n'
printf ' neurosploit run https://target -v one-shot test\n'
printf ' neurosploit --help\n'
if [ "$WANT_WEB" = 1 ]; then
printf '\n %sWeb console%s\n' "$B" "$R"
printf ' neurosploit-web --open http://localhost:%s\n' "$WEB_PORT"
fi
printf '\n %sAI access%s: one API key (set it in the web console or export ANTHROPIC_API_KEY / OPENAI_API_KEY),\n' "$B" "$R"
printf ' or a logged-in CLI subscription (claude, codex, gemini).\n'
printf ' %sUpdate later: re-run this installer. Uninstall: rm -rf "%s" and the neurosploit block in your shell rc.%s\n' "$D" "$DIR" "$R"
echo
ok "Installed. Open a NEW terminal — or activate now with:"
echo " source \"$DIR/env.sh\""
echo " (equivalently: export NEUROSPLOIT_BASE=\"$DIR\"; export PATH=\"$PREFIX:\$PATH\")"
echo " then, from ANY folder:"
echo " neurosploit # interactive session"
echo " neurosploit run http://testphp.vulnweb.com/ --subscription --model anthropic:claude-opus-4-8 -v"
echo " neurosploit --help"
echo
warn "Update later: just re-run this script. Best runtime: Kali (docker run -it kalilinux/kali-rolling)."
# ---- optionally launch right away ----
# `curl | bash` has no TTY, so auto-run only when asked (NEUROSPLOIT_RUN=1) or
# when a real terminal is attached and the operator confirms.
RUN_NOW="${NEUROSPLOIT_RUN:-}"
if [ -z "$RUN_NOW" ] && [ -t 0 ]; then
printf '\n Launch the interactive session now? [y/N] '; read -r ans
case "$ans" in y|Y|yes) RUN_NOW=1 ;; esac
# ------------------------------------------------------------ launch --------
if [ -z "$RUN_NOW" ] && [ "$TTY" = 1 ]; then
if [ "$WANT_WEB" = 1 ] && [ "$SERVICE" != 1 ]; then
ask "Open the web console now?" y && RUN_NOW=web
elif [ "$WANT_WEB" != 1 ]; then
ask "Start an interactive session now?" n && RUN_NOW=cli
fi
fi
if [ "$RUN_NOW" = "1" ]; then
say "Starting NeuroSploit…"
exec env NEUROSPLOIT_BASE="$DIR" "$DIR/neurosploit"
case "$RUN_NOW" in
1) [ "$WANT_WEB" = 1 ] && RUN_NOW=web || RUN_NOW=cli ;;
esac
if [ "$RUN_NOW" = web ]; then
printf '\n'; say "starting the web console (Ctrl+C to stop)…"
exec "$DIR/bin/neurosploit-web" --open
elif [ "$RUN_NOW" = cli ]; then
printf '\n'; say "starting NeuroSploit…"
if [ "$TTY" = 1 ]; then exec env NEUROSPLOIT_BASE="$DIR" "$BIN" <&3; else exec env NEUROSPLOIT_BASE="$DIR" "$BIN"; fi
fi
if [ "$SERVICE" = 1 ] && [ "$WANT_WEB" = 1 ]; then
printf '\n The web console is running in the background: http://localhost:%s\n' "$WEB_PORT"
fi