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.

feat(feasibility): expand pre-flight defense matrix to Windows & Lateral modules and AI AttackPlanner

Mafifrizia47c59bb2099
diff --git a/ares/core/engine.py b/ares/core/engine.py
index c1a6eed..51c0adb 100644
--- a/ares/core/engine.py
+++ b/ares/core/engine.py
@@ -1096,6 +1096,50 @@ class AresEngine:
],
}
+ async def assess_module_feasibility(
+ self,
+ module_id: str,
+ campaign: Campaign,
+ params: dict[str, Any],
+ ) -> Any:
+ """
+ Evaluate pre-flight defense feasibility for a module against target defenses,
+ session state, and noise profile without executing active operations.
+ """
+ from ares.modules.base import FeasibilityReport
+
+ if module_id not in self.registry:
+ return FeasibilityReport(
+ feasible=False,
+ score=0.0,
+ risk_level="high_noise",
+ blockers=[f"Module '{module_id}' not found in registry"],
+ )
+
+ cls = self.registry.get(module_id)
+ noise = NoiseController(campaign)
+ instance = cls(settings=self.settings, campaign=campaign, noise=noise)
+ runtime_state = await self.ensure_campaign_runtime(campaign)
+
+ ctx = ExecutionContext.build(
+ campaign=campaign,
+ target=params.get("dc") or params.get("host") or params.get("target", ""),
+ module_id=module_id,
+ domain=params.get("domain", ""),
+ params=params,
+ operator=campaign.operator,
+ credentials=runtime_state.safe_credentials(),
+ session=runtime_state.session,
+ vault=runtime_state.vault,
+ artifact_store=runtime_state.artifact_store,
+ runtime_state=runtime_state,
+ settings=self.settings,
+ noise=noise,
+ telemetry=runtime_state.telemetry,
+ )
+
+ return await instance.assess_feasibility(ctx)
+
async def _finalize_committed_module_result(
self,
campaign: Campaign,
diff --git a/ares/goal/planner.py b/ares/goal/planner.py
index 09260f6..366eaa6 100644
--- a/ares/goal/planner.py
+++ b/ares/goal/planner.py
@@ -305,14 +305,59 @@ class AttackPlanner:
total = sum(
_SCORE_WEIGHTS[k] * v
for k, v in breakdown.items()
+ if k in _SCORE_WEIGHTS
)
- # Filter out very low scores (likely no prerequisites met)
+ # ── Target Defense Feasibility Evaluation ─────────────────────────
+ defense_multiplier = 1.0
+ defense_note = ""
+ session = ctx.session or self.session
+ if session is not None and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state is not None and hasattr(host_state, "has_defense"):
+ # 1. Credential Guard (VBS)
+ if host_state.has_defense("credential_guard") or host_state.has_defense("vbs"):
+ if module_id == "windows.lsass_dump":
+ defense_multiplier *= 0.05
+ defense_note = "Target enforces Credential Guard: LSASS memory dump penalized"
+ elif module_id == "windows.dpapi":
+ defense_multiplier *= 1.35
+ defense_note = "Target enforces Credential Guard: DPAPI boosted as primary bypass"
+ # 2. LSA Protection (PPL)
+ if host_state.has_defense("lsa_protection") or host_state.has_defense("ppl"):
+ if module_id == "windows.lsass_dump":
+ defense_multiplier *= 0.15
+ defense_note = "Target enforces LSA Protection: LSASS dump penalized"
+ elif module_id in ("windows.dpapi", "windows.token_impersonation"):
+ defense_multiplier *= 1.25
+ # 3. Microsoft Defender for Identity / DRSUAPI monitoring
+ if host_state.has_defense("mde_identity") or host_state.has_defense("drsuapi_monitoring"):
+ if module_id == "ad.dcsync":
+ defense_multiplier *= 0.1
+ defense_note = "Target DC has MDI / DRSUAPI monitoring: DCSync penalized"
+ elif module_id in ("ad.adcs", "ad.shadow_credentials"):
+ defense_multiplier *= 1.3
+ defense_note = "Target DC has MDI: ADCS / Shadow Credentials boosted as evasion route"
+ # 4. Service Creation Monitoring / EDR on lateral movement
+ if host_state.has_defense("service_creation_monitoring") or host_state.has_defense("edr"):
+ if module_id == "lateral.psexec":
+ defense_multiplier *= 0.1
+ defense_note = "Target EDR monitors SCM Event ID 7045: PsExec penalized"
+ elif module_id in ("lateral.dcom", "lateral.winrm"):
+ defense_multiplier *= 1.25
+ defense_note = "Target EDR active: stealthier lateral transport boosted"
+
+ total = max(0.0, min(1.0, total * defense_multiplier))
+ breakdown["defense_feasibility"] = round(defense_multiplier, 3)
+
+ # Filter out very low scores (likely no prerequisites met or blocked by defenses)
if total < 0.05:
return None
# Build rationale
rationale = self._build_rationale(module_id, breakdown, ctx.goal, requires)
+ if defense_note:
+ rationale = f"[{defense_note}] {rationale}"
return PlanSuggestion(
module_id = module_id,
diff --git a/ares/modules/lateral/dcom.py b/ares/modules/lateral/dcom.py
index e60e745..479d254 100644
--- a/ares/modules/lateral/dcom.py
+++ b/ares/modules/lateral/dcom.py
@@ -60,6 +60,50 @@ class DCOMLateral(BaseLateralModule):
MODULE_AUTHOR = "ARES Team <[email protected]>"
MIN_NOISE_PROFILE = "normal" # blocked in stealth — creates remote process
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ DCOM (MMC20.Application / ShellWindows) is significantly stealthier than PsExec
+ because it requires no service creation.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+ from ares.core.security import sanitize_hostname
+
+ base = await super().assess_feasibility(ctx)
+ blockers = list(base.blockers)
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {"object_preference": "MMC20.Application"}
+ score = base.score
+ risk = "medium"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH:
+ score -= 0.2
+ opsec_tuning["note"] = "DCOM executes remote process via MMC20; stealthier than PsExec but triggers remote process logging."
+ recommendations.append("lateral.winrm")
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ if host_state.has_defense("dcom_restricted") or host_state.has_defense("firewall_rpc"):
+ blockers.append("DCOM / RPC port 135 restricted or filtered")
+ score -= 0.4
+ recommendations.append("lateral.winrm")
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=recommendations,
+ opsec_tuning=opsec_tuning,
+ details={"target": target},
+ )
+
async def validate(self, ctx: "Any") -> None:
"""Pre-flight param checks before any network call."""
await super().validate(ctx)
diff --git a/ares/modules/lateral/modules.py b/ares/modules/lateral/modules.py
index f9fa611..7ff7e4f 100644
--- a/ares/modules/lateral/modules.py
+++ b/ares/modules/lateral/modules.py
@@ -89,6 +89,51 @@ class BaseLateralModule(BaseModule):
f"{self.__class__.__name__} must implement move()"
)
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Default lateral movement feasibility evaluation:
+ Checks target reachability, credentials, and noise profile compatibility.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+ from ares.core.security import sanitize_hostname
+
+ blockers: list[str] = []
+ recommendations: list[str] = []
+ score = 1.0
+ risk = getattr(self.OPSEC_LEVEL, "value", str(self.OPSEC_LEVEL or "medium"))
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ if not target:
+ blockers.append(f"{self.MODULE_ID} requires 'target'")
+ score -= 0.5
+
+ has_password = bool(getattr(ctx, "params", {}).get("password") or getattr(ctx, "params", {}).get("secret"))
+ has_hash = bool(getattr(ctx, "params", {}).get("nt_hash") or getattr(ctx, "params", {}).get("hash"))
+ has_vault = bool(getattr(ctx, "vault", None) and getattr(getattr(ctx, "vault", None), "_store", None))
+ has_cred = bool(getattr(ctx, "best_credential", lambda: None)())
+
+ if not (has_password or has_hash or has_vault or has_cred):
+ blockers.append("No credentials (password, NTLM hash, or vault entry) available for lateral authentication")
+ score -= 0.4
+
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH and risk == "high_noise":
+ blockers.append(f"Module {self.MODULE_ID} is high_noise and blocked under STEALTH profile")
+ score = 0.1
+ risk = "critical_alarm"
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=recommendations,
+ opsec_tuning={},
+ details={"target": target, "module_id": self.MODULE_ID},
+ )
+
async def validate(self, ctx: "Any") -> None:
"""
Enforce target and credentials before any network connection.
@@ -242,6 +287,56 @@ class PsExecLateral(BaseLateralModule):
OUTPUTS = ["lateral_session", "command_output"]
MITRE_TECHNIQUES = ["T1569.002", "T1021.002"]
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ PsExec installs a service (Event ID 7045) which is actively monitored by every
+ modern enterprise EDR and blocked under STEALTH.
+ Recommends stealthier alternatives: lateral.dcom, lateral.winrm, or lateral.wmiexec.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+ from ares.core.security import sanitize_hostname
+
+ base = await super().assess_feasibility(ctx)
+ blockers = list(base.blockers)
+ recommendations = ["lateral.dcom", "lateral.winrm", "lateral.wmiexec"]
+ opsec_tuning: dict[str, Any] = {}
+ score = base.score
+ risk = "high_noise"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH:
+ blockers.append("PsExec SCM service installation generates Event ID 7045 — strictly blocked under STEALTH profile")
+ score = 0.05
+ risk = "critical_alarm"
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ edr_detected = host_state.defense_profile.get("edr") or host_state.has_defense("service_creation_monitoring") or host_state.has_defense("edr")
+ if edr_detected:
+ blockers.append(f"Target EDR / monitoring ({edr_detected}) detects Service Control Manager execution (Event ID 7045)")
+ score = min(score, 0.15)
+ risk = "critical_alarm"
+ opsec_tuning["edr_warning"] = (
+ f"Target host has active EDR ({edr_detected}). PsExec binary/service will trigger high-severity alert. "
+ "Switch to lateral.dcom or lateral.winrm."
+ )
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=recommendations,
+ opsec_tuning=opsec_tuning,
+ details={"target": target},
+ )
+
async def move(self, target, username, domain, secret, command="whoami /all", **kwargs) -> LateralResult:
import time
t0 = time.monotonic()
@@ -425,6 +520,55 @@ class WmiExecLateral(BaseLateralModule):
OUTPUTS = ["lateral_session", "command_output"]
MITRE_TECHNIQUES = ["T1047", "T1021.002"]
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ Evaluates WMI / Win32_Process.Create feasibility and RPC port 135 filtering.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+ from ares.core.security import sanitize_hostname
+
+ base = await super().assess_feasibility(ctx)
+ blockers = list(base.blockers)
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {}
+ score = base.score
+ risk = "medium"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH:
+ score -= 0.3
+ risk = "medium"
+ opsec_tuning["note"] = "WMI process creation generates Event ID 4688 with wmiprvse.exe parent. Consider lateral.winrm for stealth."
+ recommendations.append("lateral.winrm")
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ if host_state.has_defense("wmi_filtering") or host_state.has_defense("firewall_rpc"):
+ blockers.append("WMI / RPC port 135 blocked or filtered by firewall")
+ score -= 0.4
+ recommendations.extend(["lateral.winrm", "lateral.ssh_pivot"])
+
+ unique_recs = []
+ for r in recommendations:
+ if r not in unique_recs:
+ unique_recs.append(r)
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=unique_recs,
+ opsec_tuning=opsec_tuning,
+ details={"target": target},
+ )
+
async def move(self, target, username, domain, secret, command="whoami /all", **kwargs) -> LateralResult:
import time
t0 = time.monotonic()
@@ -577,6 +721,41 @@ class WinRMLateral(BaseLateralModule):
OUTPUTS = ["lateral_session", "command_output", "powershell_session"]
MITRE_TECHNIQUES = ["T1021.006", "T1059.001"]
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ WinRM is the standard enterprise management protocol; blends into normal admin traffic.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.security import sanitize_hostname
+
+ base = await super().assess_feasibility(ctx)
+ blockers = list(base.blockers)
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {"preferred_protocol": "WinRM / WS-Man (port 5985/5986)"}
+ score = base.score
+ risk = "low"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state and host_state.has_defense("winrm_disabled"):
+ blockers.append("WinRM service is disabled or blocked on target")
+ score -= 0.5
+ recommendations.extend(["lateral.dcom", "lateral.wmiexec"])
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=recommendations,
+ opsec_tuning=opsec_tuning,
+ details={"target": target},
+ )
+
async def move(self, target, username, domain, secret, command="whoami", **kwargs) -> LateralResult:
import time
t0 = time.monotonic()
@@ -824,6 +1003,39 @@ class RDPLateral(BaseLateralModule):
MITRE_TECHNIQUES = ["T1021.001"]
MIN_NOISE_PROFILE = "normal"
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ RDP creates interactive logons (Event ID 4624 type 10); high noise and blocked under STEALTH.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+ from ares.core.security import sanitize_hostname
+
+ base = await super().assess_feasibility(ctx)
+ blockers = list(base.blockers)
+ recommendations = ["lateral.winrm", "lateral.dcom"]
+ score = base.score
+ risk = "high_noise"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH:
+ blockers.append("Blocked in STEALTH profile: RDP connection triggers immediate Event ID 4624/4625")
+ score = 0.05
+ risk = "critical_alarm"
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=recommendations,
+ opsec_tuning={"suggested_alternatives": ["lateral.winrm", "lateral.dcom"]},
+ details={"target": target},
+ )
+
async def validate(self, ctx: "Any") -> None:
"""RDP lateral blocked in STEALTH — triggers EventID 4624/4625 immediately."""
await super().validate(ctx)
diff --git a/ares/modules/windows/dpapi.py b/ares/modules/windows/dpapi.py
index 59b84d1..07379b7 100644
--- a/ares/modules/windows/dpapi.py
+++ b/ares/modules/windows/dpapi.py
@@ -56,6 +56,87 @@ class DPAPIModule(BaseModule):
MITRE_TECHNIQUES = ["T1555.004", "T1555.003"]
MODULE_TIMEOUT_SECONDS: int | None = 180 # seconds
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ Evaluates credential accessibility, user context, and target host defense posture.
+ DPAPI operates in user space and does not access LSASS memory, making it an optimal
+ stealthy alternative when Credential Guard, PPL, or EDR process hooks are active.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+
+ blockers: list[str] = []
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {}
+ score = 1.0
+ risk = "medium"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ if not target:
+ blockers.append("No target host specified")
+ score -= 0.5
+
+ username = getattr(ctx, "params", {}).get("username", "")
+ mode = getattr(ctx, "params", {}).get("mode", "auto")
+ password = getattr(ctx, "params", {}).get("password", "") or getattr(ctx, "params", {}).get("secret", "")
+ nt_hash = getattr(ctx, "params", {}).get("nt_hash", "")
+ backup_key = getattr(ctx, "params", {}).get("backup_key", "")
+
+ if not username:
+ cred = getattr(ctx, "best_credential", lambda: None)()
+ if cred:
+ username = cred.username
+ if not password:
+ password = getattr(cred, "password", "")
+ if not nt_hash and getattr(cred, "hash", ""):
+ nt_hash = cred.hash
+
+ if not username:
+ blockers.append("Target username required for DPAPI blob masterkey resolution")
+ score -= 0.4
+ recommendations.extend(["windows.token_impersonation", "lateral.winrm"])
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ # If target has Credential Guard or PPL, DPAPI is the preferred evasion technique!
+ if host_state.has_defense("credential_guard") or host_state.has_defense("ppl"):
+ score = min(1.0, score + 0.1)
+ opsec_tuning["evasion_advantage"] = (
+ "Target enforces Credential Guard / PPL. DPAPI is optimal because it recovers "
+ "stored user secrets (browser credentials, Windows Vault, WiFi, RDP) from disk "
+ "without triggering LSASS memory protections."
+ )
+ if host_state.has_defense("edr"):
+ opsec_tuning["edr_note"] = "EDR active on host: DPAPI avoids process injection; file access is low-noise."
+
+ if mode == "backup" and not backup_key:
+ blockers.append("Backup key mode selected but no domain backup key provided")
+ score -= 0.3
+ recommendations.append("windows.lsa_secrets")
+
+ if mode == "offline" and not (nt_hash or password):
+ blockers.append("Offline mode requires user NT hash or password for masterkey derivation")
+ score -= 0.3
+
+ unique_recs: list[str] = []
+ for r in recommendations:
+ if r not in unique_recs:
+ unique_recs.append(r)
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=unique_recs,
+ opsec_tuning=opsec_tuning,
+ details={"target": target, "username": username, "mode": mode},
+ )
+
async def validate(self, ctx: "Any") -> None:
await super().validate(ctx)
from ares.core.context import ExecutionContext
diff --git a/ares/modules/windows/lsa_secrets.py b/ares/modules/windows/lsa_secrets.py
index 87c7a42..c89411e 100644
--- a/ares/modules/windows/lsa_secrets.py
+++ b/ares/modules/windows/lsa_secrets.py
@@ -48,6 +48,75 @@ class LSASecretsModule(BaseModule):
MODULE_AUTHOR = "ARES Team <[email protected]>"
MIN_NOISE_PROFILE = "normal" # blocked in stealth
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ Evaluates registry auditing, local admin access, noise constraints,
+ and recommends ad.dcsync if target is a DC, or windows.dpapi if in stealth.
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+
+ blockers: list[str] = []
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {}
+ score = 1.0
+ risk = "high_noise"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ if not target:
+ blockers.append("No target host specified")
+ score -= 0.5
+
+ username = getattr(ctx, "params", {}).get("username", "")
+ if not username:
+ cred = getattr(ctx, "best_credential", lambda: None)()
+ if cred:
+ username = cred.username
+ if not username:
+ blockers.append("No administrator credentials provided")
+ score -= 0.4
+
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH:
+ blockers.append("Blocked in STEALTH profile: remote registry SAM/LSA hive dumping generates Sysmon Event 12/13 alerts")
+ score = 0.1
+ risk = "critical_alarm"
+ recommendations.extend(["windows.dpapi", "ad.dcsync"])
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ if host_state.has_defense("registry_auditing") or host_state.has_defense("sysmon_id12"):
+ risk = "critical_alarm"
+ score -= 0.3
+ recommendations.append("windows.dpapi")
+ is_dc = (
+ getattr(host_state, "is_dc", False)
+ or getattr(host_state, "domain_role", "") == "domain_controller"
+ or (hasattr(host_state, "roles") and "dc" in getattr(host_state, "roles", []))
+ )
+ if is_dc:
+ recommendations.insert(0, "ad.dcsync")
+ opsec_tuning["dc_recommendation"] = "Target is a Domain Controller: ad.dcsync or NTDS extraction is more comprehensive than local LSA secrets."
+
+ unique_recs: list[str] = []
+ for r in recommendations:
+ if r not in unique_recs:
+ unique_recs.append(r)
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=unique_recs,
+ opsec_tuning=opsec_tuning,
+ details={"target": target, "username": username},
+ )
+
async def validate(self, ctx: "Any") -> None:
"""LSA secrets dump blocked in STEALTH — registry access triggers Sysmon."""
await super().validate(ctx)
diff --git a/ares/modules/windows/lsass_dump.py b/ares/modules/windows/lsass_dump.py
index 5a18af3..9587803 100644
--- a/ares/modules/windows/lsass_dump.py
+++ b/ares/modules/windows/lsass_dump.py
@@ -60,6 +60,96 @@ class LsassDumpModule(BaseModule):
MITRE_TECHNIQUES = ["T1003.001"]
MODULE_TIMEOUT_SECONDS: int | None = 300 # seconds
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ Evaluates Credential Guard (VBS/LsaIso), LSA Protection (RunAsPPL),
+ Sysmon Event ID 10 / EDR process access hooks, and noise profile constraints.
+ Recommends stealthier alternatives (windows.dpapi, windows.token_impersonation, ad.kerberoast).
+ """
+ from ares.modules.base import FeasibilityReport
+ from ares.core.campaign import NoiseProfile
+
+ blockers: list[str] = []
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {}
+ score = 1.0
+ risk = "high_noise"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ if not target:
+ blockers.append("No target host IP or hostname specified")
+ score -= 0.5
+
+ username = getattr(ctx, "params", {}).get("username", "")
+ if not username:
+ cred = getattr(ctx, "best_credential", lambda: None)()
+ if cred:
+ username = cred.username
+ if not username:
+ blockers.append("No local administrator credentials provided or found in vault")
+ score -= 0.4
+ recommendations.extend(["windows.token_impersonation", "ad.kerberoast"])
+
+ noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
+ if noise == NoiseProfile.STEALTH:
+ blockers.append("Blocked in STEALTH profile: LSASS process access triggers Sysmon Event ID 10 and EDR process handles")
+ score = 0.05
+ risk = "critical_alarm"
+ recommendations.extend(["windows.dpapi", "ad.kerberoast"])
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ # 1. Check Credential Guard (VBS/LsaIso.exe)
+ if host_state.has_defense("credential_guard") or host_state.has_defense("vbs"):
+ blockers.append(
+ "Credential Guard (LsaIso.exe) active: LSASS memory isolated via VBS — "
+ "NTLM hashes and Kerberos keys cannot be extracted from userland memory"
+ )
+ score = min(score, 0.05)
+ risk = "critical_alarm"
+ recommendations.extend(["windows.dpapi", "windows.token_impersonation", "ad.kerberoast"])
+
+ # 2. Check LSA Protection (RunAsPPL)
+ if host_state.has_defense("lsa_protection") or host_state.has_defense("ppl"):
+ blockers.append(
+ "LSA Protection (RunAsPPL) enabled: OpenProcess with PROCESS_VM_READ is blocked by the Windows kernel"
+ )
+ score = min(score, 0.15)
+ risk = "critical_alarm"
+ recommendations.extend(["windows.dpapi", "windows.token_impersonation", "ad.kerberoast"])
+
+ # 3. Check EDR / Sysmon ID 10
+ edr_detected = host_state.defense_profile.get("edr") or host_state.has_defense("sysmon_id10") or host_state.has_defense("edr")
+ if edr_detected:
+ risk = "critical_alarm"
+ score -= 0.3
+ opsec_tuning["recommended_technique"] = "comsvcs"
+ opsec_tuning["note"] = (
+ f"Active endpoint defense ({edr_detected}) detected; standard procdump or direct inject will trigger alert. "
+ "Use comsvcs MiniDump or pivot to DPAPI."
+ )
+ if "windows.dpapi" not in recommendations:
+ recommendations.append("windows.dpapi")
+
+ unique_recs: list[str] = []
+ for r in recommendations:
+ if r not in unique_recs:
+ unique_recs.append(r)
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=unique_recs,
+ opsec_tuning=opsec_tuning,
+ details={"target": target, "username": username},
+ )
+
async def validate(self, ctx: "Any") -> None:
await super().validate(ctx)
from ares.core.context import ExecutionContext
diff --git a/ares/modules/windows/token_impersonation.py b/ares/modules/windows/token_impersonation.py
index 488e100..8dd5598 100644
--- a/ares/modules/windows/token_impersonation.py
+++ b/ares/modules/windows/token_impersonation.py
@@ -42,6 +42,45 @@ class TokenImpersonationModule(BaseModule):
OUTPUTS = ["privesc_vectors"]
MITRE_TECHNIQUES = ["T1134.001", "T1134.002"]
+ async def assess_feasibility(self, ctx: "Any") -> "FeasibilityReport":
+ """
+ Pre-flight Defense Feasibility Assessment:
+ Evaluates SeImpersonatePrivilege conditions and Potato-family attack feasibility.
+ """
+ from ares.modules.base import FeasibilityReport
+
+ blockers: list[str] = []
+ recommendations: list[str] = []
+ opsec_tuning: dict[str, Any] = {}
+ score = 1.0
+ risk = "medium"
+
+ target = sanitize_hostname(getattr(ctx, "target", "") or getattr(ctx, "params", {}).get("target", ""))
+ if not target:
+ blockers.append("No target host specified")
+ score -= 0.5
+
+ session = getattr(ctx, "session", None)
+ if session and hasattr(session, "get_host") and target:
+ host_state = session.get_host(target)
+ if host_state:
+ if host_state.has_defense("edr"):
+ risk = "high_noise"
+ score -= 0.2
+ opsec_tuning["suggested_variant"] = "GodPotato / PrintSpoofer"
+ opsec_tuning["note"] = "EDR detected on host; classic JuicyPotato DCOM reflection is signatured. Use PrintSpoofer or GodPotato."
+
+ feasible = len(blockers) == 0 and score >= 0.4
+ return FeasibilityReport(
+ feasible=feasible,
+ score=max(0.0, min(1.0, score)),
+ risk_level=risk,
+ blockers=blockers,
+ recommended_alternatives=recommendations,
+ opsec_tuning=opsec_tuning,
+ details={"target": target},
+ )
+
async def validate(self, ctx: "Any") -> None:
"""Pre-flight param checks before any network call."""
await super().validate(ctx)
diff --git a/ares/state/target_state.py b/ares/state/target_state.py
index c6bf5d7..3971c24 100644
--- a/ares/state/target_state.py
+++ b/ares/state/target_state.py
@@ -111,10 +111,14 @@ class HostState:
elif self.ip_address and not self.ip:
self.ip = self.ip_address
- def update_defense_profile(self, controls: dict[str, Any]) -> None:
+ def update_defense_profile(self, controls: dict[str, Any] | None = None, **kwargs: Any) -> None:
"""Update or merge detected defense controls and security posture."""
- self.defense_profile.update(controls)
- self.security_controls.update(controls)
+ if controls:
+ self.defense_profile.update(controls)
+ self.security_controls.update(controls)
+ if kwargs:
+ self.defense_profile.update(kwargs)
+ self.security_controls.update(kwargs)
self.last_updated = time.time()
def has_defense(self, control_name: str) -> bool:
diff --git a/tests/unit/test_defense_feasibility_matrix.py b/tests/unit/test_defense_feasibility_matrix.py
new file mode 100644
index 0000000..bd724bc
--- /dev/null
+++ b/tests/unit/test_defense_feasibility_matrix.py
@@ -0,0 +1,420 @@
+"""
+Pre-Flight Defense Feasibility Matrix Unit Tests
+Validates intelligent evasion and defense assessment for Windows, Lateral, and Planner modules:
+ - windows.lsass_dump (Credential Guard, RunAsPPL, Sysmon ID 10 / EDR hooks)
+ - windows.dpapi (Credential Guard bypass, backup key, offline derivation)
+ - windows.lsa_secrets (SAM/LSA registry auditing, DC role recommendation)
+ - windows.token_impersonation (Potato privilege escalation defense tuning)
+ - lateral.psexec, lateral.dcom, lateral.winrm, lateral.rdp (EDR service monitoring, stealth alternatives)
+ - AttackPlanner (Automated intelligent evasion routing based on target host defense profile)
+ - AresEngine.assess_module_feasibility (Engine orchestration interface)
+"""
+from __future__ import annotations
+
+import pytest
+
+from ares.core.campaign import Campaign, NoiseProfile
+from ares.core.config import AresSettings
+from ares.core.context import ExecutionContext
+from ares.core.noise import NoiseController
+from ares.state.target_state import HostState, OperatorSession
+from ares.modules.windows.lsass_dump import LsassDumpModule
+from ares.modules.windows.dpapi import DPAPIModule
+from ares.modules.windows.lsa_secrets import LSASecretsModule
+from ares.modules.windows.token_impersonation import TokenImpersonationModule
+from ares.modules.lateral.modules import PsExecLateral, WmiExecLateral, WinRMLateral, RDPLateral
+from ares.modules.lateral.dcom import DCOMLateral
+
+
+def dummy_settings():
+ return AresSettings(jwt_secret_key="test-secret-that-is-at-least-32-bytes-long!")
+
+
+def test_campaign():
+ return Campaign(
+ name="Enterprise Engagement",
+ operator="lead_operator",
+ noise_profile=NoiseProfile.NORMAL,
+ )
+
+
+def stealth_campaign():
+ return Campaign(
+ name="Stealth Red Team",
+ operator="covert_operator",
+ noise_profile=NoiseProfile.STEALTH,
+ )
+
+
+def test_noise(test_campaign):
+ return NoiseController(test_campaign)
+
+
+def stealth_noise(stealth_campaign):
+ return NoiseController(stealth_campaign)
+
+
+class TestLsassDumpFeasibility:
+ @pytest.mark.asyncio
+ async def test_baseline_feasibility(self, dummy_settings, test_campaign, test_noise):
+ mod = LsassDumpModule(dummy_settings, test_campaign, test_noise)
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.lsass_dump",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is True
+ assert report.score >= 0.8
+ assert report.risk_level == "high_noise"
+ assert len(report.blockers) == 0
+
+ @pytest.mark.asyncio
+ async def test_blocked_by_credential_guard(self, dummy_settings, test_campaign, test_noise):
+ mod = LsassDumpModule(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50", hostname="WORKSTATION-01")
+ host.update_defense_profile(controls={"credential_guard": True})
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.lsass_dump",
+ params={"username": "Administrator", "password": "Password123!"},
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert report.score <= 0.1
+ assert report.risk_level == "critical_alarm"
+ assert any("Credential Guard" in b for b in report.blockers)
+ assert "windows.dpapi" in report.recommended_alternatives
+ assert "windows.token_impersonation" in report.recommended_alternatives
+ assert "ad.kerberoast" in report.recommended_alternatives
+
+ @pytest.mark.asyncio
+ async def test_blocked_by_lsa_protection_ppl(self, dummy_settings, test_campaign, test_noise):
+ mod = LsassDumpModule(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(controls={"ppl": True})
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.lsass_dump",
+ params={"username": "Administrator", "password": "Password123!"},
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert report.score <= 0.2
+ assert any("RunAsPPL" in b or "LSA Protection" in b for b in report.blockers)
+ assert "windows.dpapi" in report.recommended_alternatives
+
+ @pytest.mark.asyncio
+ async def test_blocked_in_stealth_noise_profile(self, dummy_settings, stealth_campaign, stealth_noise):
+ mod = LsassDumpModule(dummy_settings, stealth_campaign, stealth_noise)
+ ctx = ExecutionContext.build(
+ campaign=stealth_campaign,
+ target="10.10.10.50",
+ module_id="windows.lsass_dump",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert report.risk_level == "critical_alarm"
+ assert any("STEALTH" in b for b in report.blockers)
+ assert "windows.dpapi" in report.recommended_alternatives
+
+ @pytest.mark.asyncio
+ async def test_edr_detected_tunes_to_comsvcs(self, dummy_settings, test_campaign, test_noise):
+ mod = LsassDumpModule(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(edr="CrowdStrike Falcon")
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.lsass_dump",
+ params={"username": "Administrator", "password": "Password123!"},
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.opsec_tuning.get("recommended_technique") == "comsvcs"
+ assert "windows.dpapi" in report.recommended_alternatives
+
+
+class TestDPAPIFeasibility:
+ @pytest.mark.asyncio
+ async def test_baseline_feasibility(self, dummy_settings, test_campaign, test_noise):
+ mod = DPAPIModule(dummy_settings, test_campaign, test_noise)
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.dpapi",
+ params={"username": "jdoe", "password": "UserPass123"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is True
+ assert report.score >= 0.8
+ assert report.risk_level == "medium"
+
+ @pytest.mark.asyncio
+ async def test_credential_guard_evasion_advantage(self, dummy_settings, test_campaign, test_noise):
+ mod = DPAPIModule(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(controls={"credential_guard": True})
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.dpapi",
+ params={"username": "jdoe", "password": "UserPass123"},
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is True
+ assert report.score == 1.0
+ assert "evasion_advantage" in report.opsec_tuning
+ assert "Credential Guard" in report.opsec_tuning["evasion_advantage"]
+
+ @pytest.mark.asyncio
+ async def test_backup_mode_without_key_blocks(self, dummy_settings, test_campaign, test_noise):
+ mod = DPAPIModule(dummy_settings, test_campaign, test_noise)
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.dpapi",
+ params={"username": "jdoe", "mode": "backup"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert any("Backup key" in b for b in report.blockers)
+ assert "windows.lsa_secrets" in report.recommended_alternatives
+
+
+class TestLSASecretsFeasibility:
+ @pytest.mark.asyncio
+ async def test_blocked_in_stealth(self, dummy_settings, stealth_campaign, stealth_noise):
+ mod = LSASecretsModule(dummy_settings, stealth_campaign, stealth_noise)
+ ctx = ExecutionContext.build(
+ campaign=stealth_campaign,
+ target="10.10.10.50",
+ module_id="windows.lsa_secrets",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert any("STEALTH" in b for b in report.blockers)
+ assert "windows.dpapi" in report.recommended_alternatives
+
+ @pytest.mark.asyncio
+ async def test_recommends_dcsync_for_domain_controller(self, dummy_settings, test_campaign, test_noise):
+ mod = LSASecretsModule(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.5", is_dc=True)
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.5",
+ module_id="windows.lsa_secrets",
+ params={"username": "Administrator", "password": "Password123!"},
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert "ad.dcsync" in report.recommended_alternatives
+
+
+class TestTokenImpersonationFeasibility:
+ @pytest.mark.asyncio
+ async def test_edr_tuning_for_potatoes(self, dummy_settings, test_campaign, test_noise):
+ mod = TokenImpersonationModule(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(controls={"edr": "SentinelOne"})
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="windows.token_impersonation",
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is True
+ assert "GodPotato" in report.opsec_tuning.get("suggested_variant", "")
+
+
+class TestLateralMovementFeasibility:
+ @pytest.mark.asyncio
+ async def test_psexec_blocked_in_stealth(self, dummy_settings, stealth_campaign, stealth_noise):
+ mod = PsExecLateral(dummy_settings, stealth_campaign, stealth_noise)
+ ctx = ExecutionContext.build(
+ campaign=stealth_campaign,
+ target="10.10.10.50",
+ module_id="lateral.psexec",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert report.risk_level == "critical_alarm"
+ assert any("STEALTH" in b for b in report.blockers)
+ assert "lateral.dcom" in report.recommended_alternatives
+ assert "lateral.winrm" in report.recommended_alternatives
+
+ @pytest.mark.asyncio
+ async def test_psexec_blocked_by_edr(self, dummy_settings, test_campaign, test_noise):
+ mod = PsExecLateral(dummy_settings, test_campaign, test_noise)
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(edr="Microsoft Defender for Endpoint")
+
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="lateral.psexec",
+ params={"username": "Administrator", "password": "Password123!"},
+ session=session,
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert report.score <= 0.15
+ assert any("Event ID 7045" in b for b in report.blockers)
+ assert "lateral.dcom" in report.recommended_alternatives
+ assert "lateral.winrm" in report.recommended_alternatives
+
+ @pytest.mark.asyncio
+ async def test_dcom_stealthier_alternative(self, dummy_settings, test_campaign, test_noise):
+ mod = DCOMLateral(dummy_settings, test_campaign, test_noise)
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="lateral.dcom",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is True
+ assert report.risk_level == "medium"
+ assert report.opsec_tuning.get("object_preference") == "MMC20.Application"
+
+ @pytest.mark.asyncio
+ async def test_winrm_optimal_admin_protocol(self, dummy_settings, test_campaign, test_noise):
+ mod = WinRMLateral(dummy_settings, test_campaign, test_noise)
+ ctx = ExecutionContext.build(
+ campaign=test_campaign,
+ target="10.10.10.50",
+ module_id="lateral.winrm",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is True
+ assert report.risk_level == "low"
+ assert "5985" in report.opsec_tuning.get("preferred_protocol", "")
+
+ @pytest.mark.asyncio
+ async def test_rdp_blocked_in_stealth(self, dummy_settings, stealth_campaign, stealth_noise):
+ mod = RDPLateral(dummy_settings, stealth_campaign, stealth_noise)
+ ctx = ExecutionContext.build(
+ campaign=stealth_campaign,
+ target="10.10.10.50",
+ module_id="lateral.rdp",
+ params={"username": "Administrator", "password": "Password123!"},
+ )
+ report = await mod.assess_feasibility(ctx)
+ assert report.feasible is False
+ assert any("STEALTH" in b for b in report.blockers)
+ assert "lateral.winrm" in report.recommended_alternatives
+
+
+class TestAttackPlannerDefenseEvasion:
+ def test_planner_prefers_dpapi_over_lsass_dump_when_credential_guard_active(self):
+ from ares.goal.planner import AttackPlanner, PlannerContext
+ from ares.goal.engine import Goal
+ from ares.core.plugin.loader import ModuleRegistry
+
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(controls={"credential_guard": True})
+
+ registry = ModuleRegistry()
+ registry.register(LsassDumpModule)
+ registry.register(DPAPIModule)
+
+ planner = AttackPlanner(registry=registry, session=session)
+ ctx = PlannerContext(
+ goal=Goal.DOMAIN_ADMIN,
+ targets=["10.10.10.50"],
+ opsec_profile="normal",
+ session=session,
+ )
+ suggestions = planner.suggest(ctx, limit=5)
+
+ # DPAPI should rank higher than LSASS dump due to Credential Guard penalty
+ suggested_ids = [s.module_id for s in suggestions]
+ assert "windows.dpapi" in suggested_ids
+ dpapi_score = next((s.score for s in suggestions if s.module_id == "windows.dpapi"), None)
+ lsass_score = next((s.score for s in suggestions if s.module_id == "windows.lsass_dump"), 0.0)
+ assert dpapi_score is not None
+ assert dpapi_score > lsass_score
+
+ def test_planner_penalizes_psexec_when_edr_monitors_services(self):
+ from ares.goal.planner import AttackPlanner, PlannerContext
+ from ares.goal.engine import Goal
+ from ares.core.plugin.loader import ModuleRegistry
+
+ session = OperatorSession(campaign_id="test-camp")
+ host = session.add_host("10.10.10.50")
+ host.update_defense_profile(controls={"service_creation_monitoring": True, "edr": "Falcon"})
+
+ registry = ModuleRegistry()
+ registry.register(PsExecLateral)
+ registry.register(DCOMLateral)
+ registry.register(WinRMLateral)
+
+ planner = AttackPlanner(registry=registry, session=session)
+ ctx = PlannerContext(
+ goal=Goal.DOMAIN_ADMIN,
+ targets=["10.10.10.50"],
+ opsec_profile="normal",
+ session=session,
+ )
+ suggestions = planner.suggest(ctx, limit=5)
+
+ dcom_score = next((s.score for s in suggestions if s.module_id == "lateral.dcom"), 0.0)
+ psexec_score = next((s.score for s in suggestions if s.module_id == "lateral.psexec"), 0.0)
+ assert dcom_score > psexec_score
+
+
+class TestEngineFeasibilityAPI:
+ @pytest.mark.asyncio
+ async def test_engine_assess_module_feasibility(self, test_campaign):
+ from ares.core.engine import AresEngine
+ engine = AresEngine()
+ engine.load_modules()
+
+ report = await engine.assess_module_feasibility(
+ module_id="windows.lsass_dump",
+ campaign=test_campaign,
+ params={"target": "10.10.10.50", "username": "admin", "password": "Password123!"},
+ )
+ assert report.feasible is True
+ assert report.risk_level == "high_noise"
+
+ @pytest.mark.asyncio
+ async def test_engine_assess_nonexistent_module(self, test_campaign):
+ from ares.core.engine import AresEngine
+ engine = AresEngine()
+ report = await engine.assess_module_feasibility(
+ module_id="nonexistent.module",
+ campaign=test_campaign,
+ params={"target": "10.10.10.50"},
+ )
+ assert report.feasible is False
+ assert any("not found" in b for b in report.blockers)