mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-12-05 18:44:48 +01:00
349 lines
18 KiB
PowerShell
349 lines
18 KiB
PowerShell
# 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
|
|
#
|
|
# 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 { }
|
|
|
|
$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) — CLI + web console" -ForegroundColor Cyan
|
|
Write-Host " by Joas A Santos & Red Team Leaders" -ForegroundColor DarkGray
|
|
|
|
$rawArch = $env:PROCESSOR_ARCHITECTURE
|
|
$Arch = if ($rawArch -match 'ARM64') { 'arm64' } else { 'x64' }
|
|
|
|
# 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 }
|
|
|
|
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 ""
|
|
Write-Host " Plan windows-$Arch · mode $Mode -> $Dir"
|
|
if ($LocalSrc) { Write-Host " local checkout $LocalSrc" }
|
|
|
|
$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 }
|
|
}
|
|
|
|
$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 }
|