Skip to content

armgit / ARES

Public Imported from GitHub
0

ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.

fix: stabilize module execution UX and adapters

Mafifrizidfb0f397dffb
diff --git a/ares/api/server.py b/ares/api/server.py
index 796c46c..6e37b16 100644
--- a/ares/api/server.py
+++ b/ares/api/server.py
@@ -63,6 +63,29 @@ from ares.db.database import AresDatabase
logger = get_logger("ares.api.server")
+def _campaign_from_db_row(row: dict[str, Any]) -> Campaign:
+ data = {k: v for k, v in row.items() if k in Campaign.model_fields}
+ if "scope" not in data and row.get("scope_json"):
+ import json as _json
+
+ try:
+ scope = _json.loads(str(row["scope_json"]))
+ if isinstance(scope, list):
+ data["scope"] = scope
+ except (TypeError, ValueError):
+ data["scope"] = []
+ if "targets" not in data and row.get("targets_json"):
+ import json as _json
+
+ try:
+ targets = _json.loads(str(row["targets_json"]))
+ if isinstance(targets, list):
+ data["targets"] = targets
+ except (TypeError, ValueError):
+ data["targets"] = []
+ return Campaign(**data)
+
+
def _setup_otel(app: FastAPI, settings: Any) -> None:
"""Initialize OpenTelemetry tracing if endpoint is configured."""
if not settings.ares_otel_endpoint:
@@ -1143,12 +1166,8 @@ async def run_module(
raise HTTPException(404, "Campaign not found")
await _require_campaign_access(campaign, actor)
- # Reconstruct Campaign object from DB row
- from ares.core.campaign import Campaign as CampaignModel
-
- c_obj = CampaignModel(
- **{k: v for k, v in campaign.items() if k in CampaignModel.model_fields}
- )
+ # Reconstruct Campaign object from DB row.
+ c_obj = _campaign_from_db_row(campaign)
# Unwrap SecretStr objects → plain strings before handing to modules.
# Pydantic wraps secret fields after validation; libraries like impacket / ldap3
@@ -1380,10 +1399,10 @@ async def start_autonomous_engagement(
)
# Enforce campaign ownership — same as all other campaign endpoints
await _require_campaign_access(campaign_data, actor)
- from ares.core.campaign import Campaign
-
campaign = (
- Campaign(**campaign_data) if isinstance(campaign_data, dict) else campaign_data
+ _campaign_from_db_row(campaign_data)
+ if isinstance(campaign_data, dict)
+ else campaign_data
)
async def _run() -> None:
@@ -2009,11 +2028,7 @@ async def run_campaign_plan(
if body.dry_run:
return engine.dry_run_plan(plan, body.global_params)
- from ares.core.campaign import Campaign as CampaignModel
-
- c_obj = CampaignModel(
- **{k: v for k, v in campaign.items() if k in CampaignModel.model_fields}
- )
+ c_obj = _campaign_from_db_row(campaign)
results = await engine.run_plan(plan, c_obj, body.global_params)
return {
"campaign_id": campaign_id,
diff --git a/ares/modules/cloud/identity_federation.py b/ares/modules/cloud/identity_federation.py
index 63b92ac..c47ea68 100644
--- a/ares/modules/cloud/identity_federation.py
+++ b/ares/modules/cloud/identity_federation.py
@@ -90,6 +90,12 @@ class CloudIdentityFederationModule(BaseModule):
status="dry_run", module_id=self.MODULE_ID,
raw={"dry_run": True, "mode": ctx.params.get("mode", "enumerate")},
)
+ params = dict(ctx.params)
+ for key in (
+ "tenant_id", "client_id", "client_secret", "access_key", "secret_key",
+ "adfs_url", "krbtgt_hash", "domain", "mode",
+ ):
+ params.pop(key, None)
findings, raw = await self.run(
tenant_id=ctx.params.get("tenant_id", ""),
client_id=ctx.params.get("client_id", ""),
@@ -100,7 +106,7 @@ class CloudIdentityFederationModule(BaseModule):
krbtgt_hash=ctx.params.get("krbtgt_hash", ""),
domain=ctx.params.get("domain", ""),
mode=ctx.params.get("mode", "enumerate"),
- **ctx.params,
+ **params,
)
return ModuleResult(
status="success" if findings else "partial",
diff --git a/ares/modules/credential/golden_ticket.py b/ares/modules/credential/golden_ticket.py
index 57728e6..fb6c474 100644
--- a/ares/modules/credential/golden_ticket.py
+++ b/ares/modules/credential/golden_ticket.py
@@ -95,8 +95,12 @@ class GoldenTicketModule(BaseModule):
from ares.modules.base import ModuleResult
if getattr(ctx, "dry_run", False):
return ModuleResult(status="dry_run", module_id=self.MODULE_ID, raw={"dry_run": True})
- findings, raw = await self.run(**ctx.params,
- target=getattr(ctx, "target", ctx.params.get("target", "")))
+ params = dict(ctx.params)
+ params.pop("target", None)
+ findings, raw = await self.run(
+ **params,
+ target=getattr(ctx, "target", ctx.params.get("target", "")),
+ )
return ModuleResult(
status="success" if findings else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
diff --git a/ares/modules/credential/pass_spray.py b/ares/modules/credential/pass_spray.py
index b5b8e7c..22ad505 100644
--- a/ares/modules/credential/pass_spray.py
+++ b/ares/modules/credential/pass_spray.py
@@ -268,8 +268,11 @@ class PassSprayModule(BaseModule):
domain = getattr(ctx, "domain", "") or ctx.params.get("domain", "")
users = ctx.params.get("users", [])
passwords = ctx.params.get("passwords", DEFAULT_SPRAY_PASSWORDS[:1])
+ params = dict(ctx.params)
+ for key in ("target", "domain", "users", "passwords"):
+ params.pop(key, None)
findings, raw = await self.run(
- target=target, domain=domain, users=users, passwords=passwords, **ctx.params
+ target=target, domain=domain, users=users, passwords=passwords, **params
)
return ModuleResult(
status="success" if findings else "partial",
diff --git a/ares/modules/credential/reuse.py b/ares/modules/credential/reuse.py
index 4e0e649..dcf0f31 100644
--- a/ares/modules/credential/reuse.py
+++ b/ares/modules/credential/reuse.py
@@ -67,8 +67,11 @@ class CredentialReuseModule(BaseModule):
return ModuleResult(status="dry_run", module_id=self.MODULE_ID,
raw={"dry_run": True})
# Pass vault from ctx — it lives on ctx, NOT in ctx.params
+ params = dict(ctx.params)
+ params.pop("target", None)
+ params.pop("vault", None)
findings, raw = await self.run(
- **ctx.params,
+ **params,
vault=getattr(ctx, "vault", None),
target=getattr(ctx, "target", ctx.params.get("target", "")),
)
diff --git a/ares/modules/lateral/modules.py b/ares/modules/lateral/modules.py
index 190dd37..f9fa611 100644
--- a/ares/modules/lateral/modules.py
+++ b/ares/modules/lateral/modules.py
@@ -147,9 +147,12 @@ class BaseLateralModule(BaseModule):
target = getattr(ctx, "target", "") or ctx.params.get("target", "")
command = ctx.params.get("command", "whoami /all")
+ params = dict(ctx.params)
+ for key in ("target", "username", "domain", "secret", "command"):
+ params.pop(key, None)
findings, raw = await self.run(
target=target, username=username, domain=domain,
- secret=secret, command=command, **ctx.params,
+ secret=secret, command=command, **params,
)
return ModuleResult(
status="success" if findings else "partial",
@@ -168,7 +171,10 @@ class BaseLateralModule(BaseModule):
self._bind_log_context(target=target)
await self.before_request(target, "default")
- result = await self.move(target, username, domain, secret, command, **kwargs)
+ move_kwargs = dict(kwargs)
+ for key in ("target", "username", "domain", "secret", "command"):
+ move_kwargs.pop(key, None)
+ result = await self.move(target, username, domain, secret, command, **move_kwargs)
findings: list[Finding] = []
if result.success:
diff --git a/ares/modules/linux/kernel_suggester.py b/ares/modules/linux/kernel_suggester.py
index afdf4bc..f773c2a 100644
--- a/ares/modules/linux/kernel_suggester.py
+++ b/ares/modules/linux/kernel_suggester.py
@@ -76,8 +76,11 @@ class KernelSuggesterModule(BaseModule):
username = ctx.params.get("username", "")
password = ctx.params.get("password", "") or ctx.params.get("secret", "")
key_path = ctx.params.get("key_path", "")
+ params = dict(ctx.params)
+ for key in ("target", "username", "password", "key_path"):
+ params.pop(key, None)
findings, raw = await self.run(target=target, username=username, password=password,
- key_path=key_path, **ctx.params)
+ key_path=key_path, **params)
return ModuleResult(status="success" if findings else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
execution_id=getattr(ctx, "execution_id", ""))
diff --git a/ares/modules/network/dns_enum.py b/ares/modules/network/dns_enum.py
index db897bc..8a74fd3 100644
--- a/ares/modules/network/dns_enum.py
+++ b/ares/modules/network/dns_enum.py
@@ -87,7 +87,10 @@ class DnsEnumModule(BaseModule):
return ModuleResult(status="dry_run", module_id=self.MODULE_ID, raw={"dry_run": True})
target = getattr(ctx, "target", ctx.params.get("target", ""))
domain = ctx.params.get("domain") or target
- findings, raw = await self.run(target=target, domain=domain, **ctx.params)
+ params = dict(ctx.params)
+ params.pop("target", None)
+ params.pop("domain", None)
+ findings, raw = await self.run(target=target, domain=domain, **params)
return ModuleResult(
status="success" if (findings or raw.get("dns_records")) else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
diff --git a/ares/modules/network/http_fingerprint.py b/ares/modules/network/http_fingerprint.py
index 77219f7..7ea2402 100644
--- a/ares/modules/network/http_fingerprint.py
+++ b/ares/modules/network/http_fingerprint.py
@@ -103,7 +103,9 @@ class HttpFingerprintModule(BaseModule):
if getattr(ctx, "dry_run", False):
return ModuleResult(status="dry_run", module_id=self.MODULE_ID, raw={"dry_run": True})
target = getattr(ctx, "target", ctx.params.get("target", ""))
- findings, raw = await self.run(target=target, **ctx.params)
+ params = dict(ctx.params)
+ params.pop("target", None)
+ findings, raw = await self.run(target=target, **params)
return ModuleResult(
status="success" if (findings or raw.get("web_fingerprint")) else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
@@ -113,7 +115,7 @@ class HttpFingerprintModule(BaseModule):
@trace_module("network.http_fingerprint")
async def run(self, **kwargs: Any) -> tuple[list[Finding], dict[str, Any]]:
target = kwargs.get("target", "")
- ports = kwargs.get("http_ports") or [80, 443, 8080, 8443, 8888]
+ ports = kwargs.get("ports") or kwargs.get("http_ports") or [80, 443, 8080, 8443, 8888]
dry_run = kwargs.get("dry_run", False)
if not target:
diff --git a/ares/modules/network/port_scan.py b/ares/modules/network/port_scan.py
index 866e450..3d2e159 100644
--- a/ares/modules/network/port_scan.py
+++ b/ares/modules/network/port_scan.py
@@ -123,8 +123,12 @@ class PortScanModule(BaseModule):
if getattr(ctx, "dry_run", False):
return ModuleResult(status="dry_run", module_id=self.MODULE_ID,
raw={"dry_run": True, "target": getattr(ctx, "target", "")})
- findings, raw = await self.run(**ctx.params,
- target=getattr(ctx, "target", ctx.params.get("target", "")))
+ params = dict(ctx.params)
+ params.pop("target", None)
+ findings, raw = await self.run(
+ **params,
+ target=getattr(ctx, "target", ctx.params.get("target", "")),
+ )
return ModuleResult(
status="success" if (findings or raw.get("open_ports")) else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
diff --git a/ares/modules/network/service_detect.py b/ares/modules/network/service_detect.py
index 15ba049..7bbf12c 100644
--- a/ares/modules/network/service_detect.py
+++ b/ares/modules/network/service_detect.py
@@ -133,7 +133,10 @@ class ServiceDetectModule(BaseModule):
raw={"dry_run": True})
target = getattr(ctx, "target", ctx.params.get("target", ""))
ports = ctx.params.get("ports", [])
- findings, raw = await self.run(target=target, ports=ports, **ctx.params)
+ params = dict(ctx.params)
+ params.pop("target", None)
+ params.pop("ports", None)
+ findings, raw = await self.run(target=target, ports=ports, **params)
return ModuleResult(
status="success" if (findings or raw.get("service_versions")) else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
diff --git a/ares/modules/network/snmp_enum.py b/ares/modules/network/snmp_enum.py
index d320208..eb2f667 100644
--- a/ares/modules/network/snmp_enum.py
+++ b/ares/modules/network/snmp_enum.py
@@ -171,7 +171,9 @@ class SnmpEnumModule(BaseModule):
raw={"dry_run": True,
"target": getattr(ctx, "target", "")})
target = getattr(ctx, "target", ctx.params.get("target", ""))
- findings, raw = await self.run(target=target, **ctx.params)
+ params = dict(ctx.params)
+ params.pop("target", None)
+ findings, raw = await self.run(target=target, **params)
return ModuleResult(
status="success" if (findings or raw.get("valid_communities")) else "partial",
findings=findings, raw=raw, module_id=self.MODULE_ID,
@@ -181,7 +183,7 @@ class SnmpEnumModule(BaseModule):
@trace_module("network.snmp_enum")
async def run(self, **kwargs: Any) -> tuple[list[Finding], dict[str, Any]]:
target = kwargs.get("target", "")
- port = int(kwargs.get("snmp_port", 161))
+ port = int(kwargs.get("port") or kwargs.get("snmp_port", 161))
dry_run = kwargs.get("dry_run", False)
communities = kwargs.get("communities") or _COMMUNITY_STRINGS
do_walk = kwargs.get("walk", True) # Walk tables for deeper enum
diff --git a/ares/modules/params.py b/ares/modules/params.py
index be5f885..beac100 100644
--- a/ares/modules/params.py
+++ b/ares/modules/params.py
@@ -139,6 +139,8 @@ class ModuleParams(BaseModel):
result[name]["max_len"] = field_schema["maxLength"]
if "pattern" in field_schema:
result[name]["pattern"] = field_schema["pattern"]
+ if "items" in field_schema:
+ result[name]["items"] = field_schema["items"]
return result
def safe_dict(self) -> dict[str, Any]:
diff --git a/ares/modules/windows/lsa_secrets.py b/ares/modules/windows/lsa_secrets.py
index d61c101..26ca084 100644
--- a/ares/modules/windows/lsa_secrets.py
+++ b/ares/modules/windows/lsa_secrets.py
@@ -76,8 +76,11 @@ class LSASecretsModule(BaseModule):
username = ctx.params.get("username", "")
password = ctx.params.get("password", "") or ctx.params.get("secret", "")
domain = getattr(ctx, "domain", "") or ctx.params.get("domain", "")
+ params = dict(ctx.params)
+ for key in ("target", "username", "password", "domain"):
+ params.pop(key, None)
findings, raw = await self.run(
- target=target, username=username, password=password, domain=domain, **ctx.params
+ target=target, username=username, password=password, domain=domain, **params
)
return ModuleResult(
status="success" if findings else "partial",
diff --git a/ares/modules/windows/token_impersonation.py b/ares/modules/windows/token_impersonation.py
index 1435097..2c935ea 100644
--- a/ares/modules/windows/token_impersonation.py
+++ b/ares/modules/windows/token_impersonation.py
@@ -67,9 +67,12 @@ class TokenImpersonationModule(BaseModule):
username = ctx.params.get("username", "")
password = ctx.params.get("password", "") or ctx.params.get("secret", "")
domain = getattr(ctx, "domain", "") or ctx.params.get("domain", "")
+ params = dict(ctx.params)
+ for key in ("target", "username", "password", "domain"):
+ params.pop(key, None)
findings, raw = await self.run(
target=target, username=username, password=password, domain=domain,
- **ctx.params
+ **params
)
return ModuleResult(
status="success" if findings else "partial",
diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index aa61844..718a31b 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -7,6 +7,7 @@ import {
KeyRound,
LayoutDashboard,
ListChecks,
+ Loader2,
LogOut,
Play,
Radio,
@@ -29,6 +30,7 @@ import {
import { NavLink, Navigate, Route, Routes, useNavigate } from "react-router-dom";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
+ ApiError,
api,
buildModuleRunPayload,
campaignEventsPath,
@@ -429,6 +431,8 @@ function ModulesPage() {
});
const list = modules.data ?? [];
const selected = list.find((item) => item.id === selectedId);
+ const selectedCampaign = (campaigns.data ?? []).find((item) => item.id === campaignId);
+ const scopeWarning = moduleScopeWarning(selected, selectedCampaign, params, dryRun);
const categories = unique(list.map((item) => item.category || ""));
const visible = list.filter((item) => {
const haystack = `${item.id} ${item.name ?? ""} ${item.description ?? ""} ${item.mitre ?? ""}`.toLowerCase();
@@ -439,7 +443,8 @@ function ModulesPage() {
);
});
const sensitive = isSensitiveModule(selected);
- const canRun = Boolean(campaignId && selectedId) && (!sensitive || confirmed);
+ const canRun = Boolean(campaignId && selectedId) && (!sensitive || confirmed) && !run.isPending;
+ const runBlocked = !canRun || Boolean(scopeWarning);
useEffect(() => {
setParams({});
@@ -487,8 +492,23 @@ function ModulesPage() {
<h2 className="mb-3 text-base font-bold">Run Module</h2>
<CampaignPicker campaigns={campaigns.data ?? []} value={campaignId} onChange={setCampaignId} />
{selected ? (
- <form className="mt-4 grid gap-3" onSubmit={(e) => { e.preventDefault(); run.mutate(); }}>
+ <form
+ aria-busy={run.isPending}
+ className="mt-4 grid gap-3"
+ onSubmit={(e) => {
+ e.preventDefault();
+ if (runBlocked) {
+ return;
+ }
+ run.mutate();
+ }}
+ >
<ParamForm schema={selected.param_schema} values={params} onChange={setParams} />
+ {scopeWarning && (
+ <p className="rounded-md border border-red-200 bg-red-50 p-3 text-sm font-semibold text-red-800">
+ {scopeWarning}
+ </p>
+ )}
<label className="flex items-center gap-2 text-sm font-semibold">
<input type="checkbox" checked={dryRun} onChange={(e) => setDryRun(e.target.checked)} />
Dry run
@@ -499,9 +519,23 @@ function ModulesPage() {
Confirm authorized high-noise or sensitive execution
</label>
)}
- <button className="btn btn-primary" type="submit" disabled={!canRun}>
- <Play size={16} /> Run
+ <button className="btn btn-primary" type="submit" disabled={runBlocked}>
+ {run.isPending ? (
+ <>
+ <Loader2 className="spin" size={16} /> Running...
+ </>
+ ) : (
+ <>
+ <Play size={16} /> Run
+ </>
+ )}
</button>
+ {run.isPending && (
+ <div className="flex items-center gap-3 rounded-md border border-red-200 bg-red-50 p-3 text-sm font-semibold text-red-900" role="status" aria-live="polite">
+ <Loader2 className="spin shrink-0" size={18} />
+ Module execution in progress. Keep this page open while ARES validates the target and collects results.
+ </div>
+ )}
</form>
) : (
<EmptyState text="Select a module" />
@@ -946,7 +980,15 @@ function ParamForm({
<ParamInput
field={field}
value={values[name]}
- onChange={(value) => onChange({ ...values, [name]: value })}
+ onChange={(value) => {
+ const next = { ...values };
+ if (!field.required && isEmptyParamValue(value)) {
+ delete next[name];
+ } else {
+ next[name] = value;
+ }
+ onChange(next);
+ }}
/>
{field.description && <span className="mt-1 block text-xs text-slate-600">{field.description}</span>}
</label>
@@ -974,6 +1016,20 @@ function ParamInput({
/>
);
}
+ if (field.type === "array") {
+ return (
+ <textarea
+ className="field mt-1 min-h-20"
+ value={Array.isArray(value) ? value.join(", ") : String(value ?? "")}
+ required={field.required}
+ onInvalid={setRequiredMessage}
+ onChange={(event) => {
+ clearValidationMessage(event);
+ onChange(parseArrayParam(event.target.value, field));
+ }}
+ />
+ );
+ }
const type = field.secret ? "password" : field.type === "integer" || field.type === "number" ? "number" : "text";
return (
<input
@@ -987,10 +1043,10 @@ function ParamInput({
onChange={(event) => {
clearValidationMessage(event);
if (type === "number") {
- onChange(event.target.value === "" ? "" : Number(event.target.value));
+ onChange(event.target.value === "" ? undefined : Number(event.target.value));
return;
}
- onChange(event.target.value);
+ onChange(event.target.value === "" ? undefined : event.target.value);
}}
/>
);
@@ -1040,6 +1096,104 @@ function looksLikeScopeEntry(entry: string): boolean {
return value >= 0 && value <= 32;
}
+function parseArrayParam(value: string, field: ParamField): unknown[] | undefined {
+ const entries = splitLines(value);
+ if (entries.length === 0) {
+ return undefined;
+ }
+ const itemType = field.items?.type ?? "string";
+ if (itemType === "integer" || itemType === "number") {
+ const numericEntries = entries.map((entry) => Number(entry));
+ return numericEntries.every((entry) => Number.isFinite(entry)) ? numericEntries : entries;
+ }
+ return entries;
+}
+
+function isEmptyParamValue(value: unknown): boolean {
+ return value === undefined || value === "" || (Array.isArray(value) && value.length === 0);
+}
+
+function moduleScopeWarning(
+ module: ModuleMeta | undefined,
+ campaign: Campaign | undefined,
+ values: Record<string, unknown>,
+ dryRun: boolean
+): string {
+ if (!module || !campaign || dryRun || !("target" in (module.param_schema ?? {}))) {
+ return "";
+ }
+ const target = typeof values.target === "string" ? values.target.trim() : "";
+ if (!target) {
+ return "";
+ }
+ const scope = campaignScopeEntries(campaign);
+ if (scope.length === 0) {
+ return "Selected campaign has no scope CIDRs. Add a scoped campaign such as 127.0.0.1/32 before running target modules.";
+ }
+ if (isIpv4Address(target) && scope.every(looksLikeScopeEntry) && !scope.some((entry) => ipv4InScope(target, entry))) {
+ return `Target ${target} is outside the selected campaign scope (${scope.join(", ")}).`;
+ }
+ return "";
+}
+
+function campaignScopeEntries(campaign: Campaign): string[] {
+ if (Array.isArray(campaign.scope_cidrs)) {
+ return campaign.scope_cidrs.filter((entry): entry is string => typeof entry === "string" && entry.trim() !== "");
+ }
+ const rawScope = campaign.scope;
+ if (Array.isArray(rawScope)) {
+ return rawScope
+ .map((entry) => {
+ if (typeof entry === "string") {
+ return entry;
+ }
+ if (entry && typeof entry === "object" && "cidr" in entry && typeof entry.cidr === "string") {
+ return entry.cidr;
+ }
+ return "";
+ })
+ .filter(Boolean);
+ }
+ if (typeof campaign.scope_json === "string" && campaign.scope_json.trim()) {
+ try {
+ const parsed = JSON.parse(campaign.scope_json) as unknown;
+ if (Array.isArray(parsed)) {
+ return parsed
+ .map((entry) => {
+ if (typeof entry === "string") {
+ return entry;
+ }
+ if (entry && typeof entry === "object" && "cidr" in entry && typeof entry.cidr === "string") {
+ return entry.cidr;
+ }
+ return "";
+ })
+ .filter(Boolean);
+ }
+ } catch {
+ return [];
+ }
+ }
+ return [];
+}
+
+function ipv4InScope(ip: string, cidr: string): boolean {
+ const [network, prefixText = "32"] = cidr.split("/");
+ if (!isIpv4Address(network) || !/^\d{1,2}$/.test(prefixText)) {
+ return false;
+ }
+ const prefix = Number(prefixText);
+ if (prefix < 0 || prefix > 32) {
+ return false;
+ }
+ const mask = prefix === 0 ? 0 : (0xffffffff << (32 - prefix)) >>> 0;
+ return (ipv4ToNumber(ip) & mask) === (ipv4ToNumber(network) & mask);
+}
+
+function ipv4ToNumber(ip: string): number {
+ return ip.split(".").reduce((acc, part) => ((acc << 8) + Number(part)) >>> 0, 0);
+}
+
function isIpv4Address(value: string): boolean {
const parts = value.split(".");
return parts.length === 4 && parts.every((part) => {
@@ -1088,6 +1242,9 @@ function opsecBadge(level?: string): string {
}
function serializeError(value: unknown): unknown {
+ if (value instanceof ApiError) {
+ return { name: value.name, status: value.status, detail: value.detail };
+ }
if (value instanceof Error) {
return { name: value.name, message: value.message };
}
diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts
index 9a5bc80..2001401 100644
--- a/frontend/src/api/types.ts
+++ b/frontend/src/api/types.ts
@@ -20,6 +20,7 @@ export interface Campaign {
operator?: string;
targets?: string[];
scope_cidrs?: string[];
+ scope_json?: string;
status?: string;
created_at?: string;
[key: string]: unknown;
@@ -41,6 +42,9 @@ export interface ParamField {
description: string;
required: boolean;
secret: boolean;
+ items?: {
+ type?: string;
+ };
min?: number;
max?: number;
min_len?: number;
diff --git a/frontend/src/styles.css b/frontend/src/styles.css
index 31388e6..308d252 100644
--- a/frontend/src/styles.css
+++ b/frontend/src/styles.css
@@ -77,6 +77,12 @@ textarea {
background: #f8fafc;
}
+.btn:disabled,
+.btn:disabled:hover {
+ cursor: not-allowed;
+ opacity: 0.68;
+}
+
.btn-primary {
border-color: #991b1b;
background: #b91c1c;
@@ -87,11 +93,28 @@ textarea {
background: #991b1b;
}
+.btn-primary:disabled,
+.btn-primary:disabled:hover {
+ border-color: #991b1b;
+ background: #991b1b;
+ color: #ffffff;
+}
+
.btn-danger {
border-color: #b91c1c;
color: #b91c1c;
}
+.spin {
+ animation: spin 0.9s linear infinite;
+}
+
+@keyframes spin {
+ to {
+ transform: rotate(360deg);
+ }
+}
+
.badge {
display: inline-flex;
align-items: center;
diff --git a/tests/unit/test_api_endpoints.py b/tests/unit/test_api_endpoints.py
index c977a7e..978326f 100644
--- a/tests/unit/test_api_endpoints.py
+++ b/tests/unit/test_api_endpoints.py
@@ -551,6 +551,87 @@ class TestModuleSchemaEndpoint:
# ── Reports safety ───────────────────────────────────────────────────────────
+class TestModuleRunEndpoint:
+ def setup_method(self) -> None:
+ _reset_rate_limiter()
+
+ @pytest.mark.asyncio # type: ignore[untyped-decorator]
+ async def test_module_run_uses_persisted_campaign_scope_json(
+ self, aclient: Any
+ ) -> None:
+ c, db, app = aclient
+ from ares.api.server import get_engine
+
+ captured: dict[str, Any] = {}
+
+ class FakeRegistry:
+ def get(self, module_id: str) -> Any:
+ return object
+
+ class FakeResult:
+ findings: list[Any] = []
+ status = "success"
+
+ def model_dump(self) -> dict[str, Any]:
+ return {
+ "module_id": "demo.scope_capture",
+ "status": "success",
+ "findings": [],
+ "validation_results": [],
+ "raw_output": {},
+ "error": "",
+ "duration_ms": 0,
+ }
+
+ class FakeEngine:
+ registry = FakeRegistry()
+
+ async def run_module(
+ self,
+ module_id: str,
+ campaign: Any,
+ params: dict[str, Any],
+ actor_role: str = "",
+ ) -> FakeResult:
+ captured["campaign"] = campaign
+ captured["params"] = params
+ captured["actor_role"] = actor_role
+ return FakeResult()
+
+ db.is_access_token_revoked.return_value = False
+ db.get_campaign.return_value = {
+ "id": "camp-scope-json",
+ "name": "Scope JSON",
+ "client": "Internal",
+ "operator": "admin",
+ "noise_profile": "stealth",
+ "status": "created",
+ "scope_json": '[{"cidr": "127.0.0.1/32", "description": ""}]',
+ "targets_json": '["127.0.0.1"]',
+ "notes": "",
+ "created_at": "2026-06-27 02:15:19",
+ "updated_at": "2026-06-27 02:15:19",
+ }
+ app.dependency_overrides[get_engine] = lambda: FakeEngine()
+ try:
+ r = await c.post(
+ "/modules/demo.scope_capture/run",
+ json={
+ "campaign_id": "camp-scope-json",
+ "params": {"target": "127.0.0.1"},
+ "dry_run": False,
+ },
+ headers=_auth("admin", "team_lead"),
+ )
+ finally:
+ app.dependency_overrides.pop(get_engine, None)
+
+ assert r.status_code == 200
+ campaign = captured["campaign"]
+ assert [entry.cidr for entry in campaign.scope] == ["127.0.0.1/32"]
+ assert campaign.targets == ["127.0.0.1"]
+
+
class TestReportEndpoints:
def setup_method(self) -> None:
_reset_rate_limiter()
diff --git a/tests/unit/test_module_execute_adapters.py b/tests/unit/test_module_execute_adapters.py
new file mode 100644
index 0000000..812202b
--- /dev/null
+++ b/tests/unit/test_module_execute_adapters.py
@@ -0,0 +1,201 @@
+from __future__ import annotations
+
+import asyncio
+import importlib
+from types import SimpleNamespace
+from typing import Any
+
+import pytest
+
+from tests.unit.modules.test_modules import _make_module
+
+
+def _run(coro):
+ return asyncio.run(coro)
+
+
+def _ctx(params: dict[str, Any]) -> SimpleNamespace:
+ return SimpleNamespace(
+ params=params,
+ target=params.get("target", "10.0.0.1"),
+ domain=params.get("domain", "corp.local"),
+ dry_run=False,
+ execution_id="adapter-test",
+ vault=params.get("vault"),
+ best_credential=lambda: None,
+ )
+
+
+ ("module_path", "class_name", "params", "expected"),
+ [
+ (
+ "ares.modules.network.http_fingerprint",
+ "HttpFingerprintModule",
+ {"target": "10.0.0.1", "ports": [8888], "timeout": 1.0},
+ {"target": "10.0.0.1", "ports": [8888]},
+ ),
+ (
+ "ares.modules.network.dns_enum",
+ "DnsEnumModule",
+ {"target": "example.com", "domain": "example.com"},
+ {"target": "example.com", "domain": "example.com"},
+ ),
+ (
+ "ares.modules.network.port_scan",
+ "PortScanModule",
+ {"target": "10.0.0.1", "ports": [80], "timeout": 1.0},
+ {"target": "10.0.0.1", "ports": [80]},
+ ),
+ (
+ "ares.modules.network.service_detect",
+ "ServiceDetectModule",
+ {"target": "10.0.0.1", "ports": [80], "timeout": 1.0},
+ {"target": "10.0.0.1", "ports": [80]},
+ ),
+ (
+ "ares.modules.network.snmp_enum",
+ "SnmpEnumModule",
+ {"target": "10.0.0.1", "port": 161, "communities": ["public"]},
+ {"target": "10.0.0.1", "port": 161},
+ ),
+ (
+ "ares.modules.cloud.identity_federation",
+ "CloudIdentityFederationModule",
+ {
+ "tenant_id": "tenant",
+ "client_id": "client",
+ "client_secret": "secret",
+ "access_key": "ak",
+ "secret_key": "sk",
+ "adfs_url": "https://adfs.example",
+ "krbtgt_hash": "a" * 32,
+ "domain": "corp.local",
+ "mode": "enumerate",
+ },
+ {"tenant_id": "tenant", "domain": "corp.local", "mode": "enumerate"},
+ ),
+ (
+ "ares.modules.linux.kernel_suggester",
+ "KernelSuggesterModule",
+ {"target": "10.0.0.1", "username": "user", "password": "pw", "key_path": ""},
+ {"target": "10.0.0.1", "username": "user", "password": "pw"},
+ ),
+ (
+ "ares.modules.windows.token_impersonation",
+ "TokenImpersonationModule",
+ {"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
+ {"target": "10.0.0.1", "username": "user", "domain": "corp"},
+ ),
+ (
+ "ares.modules.windows.lsa_secrets",
+ "LSASecretsModule",
+ {"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
+ {"target": "10.0.0.1", "username": "user", "domain": "corp"},
+ ),
+ (
+ "ares.modules.credential.golden_ticket",
+ "GoldenTicketModule",
+ {
+ "target": "corp.local",
+ "domain": "corp.local",
+ "krbtgt_hash": "a" * 32,
+ "domain_sid": "S-1-5-21-1-2-3",
+ },
+ {"target": "corp.local", "domain": "corp.local"},
+ ),
+ (
+ "ares.modules.credential.reuse",
+ "CredentialReuseModule",
+ {"target": "10.0.0.1"},
+ {"target": "10.0.0.1", "vault": None},
+ ),
+ (
+ "ares.modules.credential.pass_spray",
+ "PassSprayModule",
+ {
+ "target": "10.0.0.1",
+ "domain": "corp.local",
+ "users": ["alice"],
+ "passwords": ["Password1!"],
+ },
+ {"target": "10.0.0.1", "domain": "corp.local", "users": ["alice"]},
+ ),
+ ],
+)
+def test_execute_adapter_deduplicates_explicit_ctx_params(
+ monkeypatch, module_path, class_name, params, expected
+):
+ module = importlib.import_module(module_path)
+ cls = getattr(module, class_name)
+ mod, _ = _make_module(cls)
+ captured: dict[str, Any] = {}
+
+ async def fake_run(**kwargs):
+ captured.update(kwargs)
+ return [], {"adapter": "ok"}
+
+ monkeypatch.setattr(mod, "run", fake_run)
+
+ result = _run(mod.execute(_ctx(params)))
+
+ assert result.module_id == mod.MODULE_ID
+ for key, value in expected.items():
+ assert captured[key] == value
+
+
+def test_lateral_adapter_deduplicates_execute_and_move_kwargs(monkeypatch):
+ from ares.modules.lateral.modules import LateralResult, LateralTechnique, PsExecLateral
+
+ mod, _ = _make_module(PsExecLateral)
+ captured: dict[str, Any] = {}
+
+ async def fake_before_request(*args, **kwargs):
+ return None
+
+ async def fake_move(target, username, domain, secret, command="whoami /all", **kwargs):
+ captured.update(
+ {
+ "target": target,
+ "username": username,
+ "domain": domain,
+ "secret": secret,
+ "command": command,
+ "kwargs": kwargs,
+ }
+ )
+ return LateralResult(
+ technique=LateralTechnique.PSEXEC,
+ source_host="operator",
+ target_host=target,
+ username=username,
+ domain=domain,
+ success=False,
+ error="not executed",
+ )
+
+ monkeypatch.setattr(mod, "before_request", fake_before_request)
+ monkeypatch.setattr(mod, "move", fake_move)
+
+ result = _run(
+ mod.execute(
+ _ctx(
+ {
+ "target": "10.0.0.1",
+ "username": "user",
+ "domain": "corp",
+ "secret": "pw",
+ "command": "whoami",
+ }
+ )
+ )
+ )
+
+ assert result.module_id == mod.MODULE_ID
+ assert captured["target"] == "10.0.0.1"
+ assert captured["username"] == "user"
+ assert captured["domain"] == "corp"
+ assert captured["secret"] == "pw"
+ assert captured["command"] == "whoami"
+ for key in ("target", "username", "domain", "secret", "command"):
+ assert key not in captured["kwargs"]