mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-07-06 19:37:57 +02:00
setup: global install (download prebuilt + PATH + NEUROSPLOIT_BASE), run from anywhere
- setup.sh: downloads the prebuilt release asset for the detected OS/arch (no Rust needed; latest release auto-resolved), installs binary + agents_md to ~/.neurosploit-app, symlinks into ~/.local/bin, and PERSISTS PATH + NEUROSPLOIT_BASE into the shell rc (bash/zsh/fish). Falls back to a source build (NEUROSPLOIT_BUILD=1 to force). Idempotent. - install.ps1: same for Windows — downloads windows-x64 zip, installs to %LOCALAPPDATA%\NeuroSploit, sets User PATH + NEUROSPLOIT_BASE (setx), source-build fallback (incl. arm64). - find_base(): auto-discovers agents_md/ NEXT TO THE EXECUTABLE (resolves the PATH symlink via current_exe) and at common install dirs — so `neurosploit` runs from ANY folder even without the env var. Env override still takes precedence. Verified: symlinked binary run from /tmp with no env finds all 383 agents.
This commit is contained in:
+88
-37
@@ -2,8 +2,11 @@
|
||||
#
|
||||
# irm https://raw.githubusercontent.com/JoasASantos/NeuroSploit/main/install.ps1 | iex
|
||||
#
|
||||
# Installs the Rust toolchain if needed, clones the repo, builds the release
|
||||
# binary, and adds it to your PATH. Works on x64 and arm64.
|
||||
# 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"
|
||||
|
||||
function Say($m) { Write-Host " > $m" -ForegroundColor Magenta }
|
||||
@@ -12,50 +15,98 @@ function Warn($m){ Write-Host " ! $m" -ForegroundColor Yellow }
|
||||
|
||||
Write-Host ""
|
||||
Write-Host " NeuroSploit installer (Windows) — v3.5.5" -ForegroundColor Cyan
|
||||
$arch = $env:PROCESSOR_ARCHITECTURE
|
||||
|
||||
# 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"
|
||||
|
||||
$dir = if ($env:NEUROSPLOIT_DIR) { $env:NEUROSPLOIT_DIR } else { Join-Path $HOME ".neurosploit-src" }
|
||||
$ref = if ($env:NEUROSPLOIT_REF) { $env:NEUROSPLOIT_REF } else { "main" }
|
||||
$slug = "JoasASantos/NeuroSploit"
|
||||
$dir = if ($env:NEUROSPLOIT_DIR) { $env:NEUROSPLOIT_DIR } else { Join-Path $env:LOCALAPPDATA "NeuroSploit" }
|
||||
$ref = $env:NEUROSPLOIT_REF
|
||||
|
||||
# 1) git
|
||||
if (-not (Get-Command git -ErrorAction SilentlyContinue)) { throw "git is required (install Git for Windows) and re-run." }
|
||||
# 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 = "v3.5.5" }
|
||||
Say "Release: $ref"
|
||||
|
||||
# 2) Rust (rustup) — winget if available, else the rustup-init bootstrap
|
||||
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/$arch" -OutFile $ri
|
||||
& $ri -y --default-toolchain stable --profile minimal
|
||||
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."
|
||||
}
|
||||
$env:Path = "$HOME\.cargo\bin;$env:Path"
|
||||
}
|
||||
Ok ("Rust: " + (cargo --version))
|
||||
|
||||
# 3) clone or update
|
||||
if (Test-Path (Join-Path $dir ".git")) {
|
||||
Say "Updating $dir..."; git -C $dir fetch --depth 1 origin $ref; git -C $dir reset --hard "origin/$ref"
|
||||
} else {
|
||||
Say "Cloning to $dir..."; git clone --depth 1 --branch $ref "https://github.com/JoasASantos/NeuroSploit.git" $dir
|
||||
}
|
||||
|
||||
# 4) build
|
||||
Say "Building release binary (first build downloads crates)..."
|
||||
Push-Location (Join-Path $dir "neurosploit-rs"); cargo build --release; Pop-Location
|
||||
$bin = Join-Path $dir "neurosploit-rs\target\release\neurosploit.exe"
|
||||
if (-not (Test-Path $bin)) { throw "build did not produce $bin" }
|
||||
Ok ("Built: " + (& $bin --version))
|
||||
# ---- 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"
|
||||
}
|
||||
|
||||
# 5) add to PATH (user)
|
||||
$binDir = Split-Path $bin
|
||||
$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 "*$binDir*") {
|
||||
[Environment]::SetEnvironmentVariable("Path", "$userPath;$binDir", "User")
|
||||
Ok "Added $binDir to your PATH (open a new terminal)."
|
||||
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))
|
||||
Write-Host ""
|
||||
Ok "Done. Launch: neurosploit"
|
||||
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."
|
||||
|
||||
Reference in New Issue
Block a user