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(data): laps_enum direct vault write + OPSEC-safe raw output (MOD-055)

Mafifrizi4bbf61d1d861
diff --git a/ares/core/context.py b/ares/core/context.py
index 933af11..25588bc 100644
--- a/ares/core/context.py
+++ b/ares/core/context.py
@@ -207,6 +207,10 @@ class ExecutionContext(Generic[P]):
cred_type: str = "password",
metadata: dict[str, Any] | None = None,
io_verified: bool | None = None,
+ target: str = "",
+ privilege: str = "",
+ source: str = "",
+ **kwargs: Any,
) -> Any:
"""Store a discovered credential in the context vault if available (protected by Gate 6)."""
has_io = (
@@ -237,10 +241,14 @@ class ExecutionContext(Generic[P]):
secret=secret,
domain=domain or self.domain,
cred_type=cred_type,
- host=self.target,
+ host=target or self.target,
+ target_host=target or self.target,
+ privilege=privilege or "user",
+ source_module=source or self.module_id,
metadata=metadata or {},
io_verified=has_io,
ctx=self,
+ **kwargs,
)
except Exception:
pass
diff --git a/ares/modules/ad/laps_enum.py b/ares/modules/ad/laps_enum.py
index c0e1c37..0f80ab5 100644
--- a/ares/modules/ad/laps_enum.py
+++ b/ares/modules/ad/laps_enum.py
@@ -113,17 +113,19 @@ class LAPSEnumModule(BaseModule[LAPSEnumParams, ModuleResult]):
dc=ad["dc"], domain=ad["domain"],
username=ad["username"], password=ad["password"],
vault=getattr(ctx, "vault", None),
+ ctx=ctx,
)
# Cryptographic Evidence Records with SHA-256 Merkle Provenance
evidence_chain: list[EvidenceRecord] = []
for cred in raw.get("laps_passwords", []):
+ comp_name = cred.get("computer") or cred.get("computer_name") or "unknown"
ev = EvidenceRecord(
- artifact_id=f"laps-{cred.get('computer', 'unknown').lower()}",
+ artifact_id=f"laps-{comp_name.lower()}",
source_target=ad["dc"],
collected_by=self.MODULE_ID,
data={
- "computer": cred.get("computer"),
+ "computer": comp_name,
"account": cred.get("account", "Administrator"),
"version": cred.get("version", "LAPS"),
},
@@ -193,7 +195,7 @@ class LAPSEnumModule(BaseModule[LAPSEnumParams, ModuleResult]):
@trace_module("ad.laps_enum")
async def run(self, dc: str, domain: str, username: str, password: str,
- vault: "Any" = None, **kwargs: Any):
+ vault: "Any" = None, ctx: "Any" = None, **kwargs: Any):
dc = sanitize_hostname(dc)
username = sanitize_ldap(username)
domain = sanitize_ldap(domain)
@@ -215,29 +217,58 @@ class LAPSEnumModule(BaseModule[LAPSEnumParams, ModuleResult]):
logger.info("laps_enum_done", found=len(laps_entries))
+ raw_entries: list[dict[str, Any]] = []
if laps_entries:
# Store every LAPS password to vault so lateral modules can use them
_vault = vault or getattr(getattr(self, "campaign", None), "_vault", None)
- if _vault:
- from ares.credential.vault import Credential, CredentialType, PrivilegeLevel
- stored = 0
- campaign_id = getattr(getattr(self, "campaign", None), "id", "")
- for entry in laps_entries:
+ from ares.credential.vault import Credential, CredentialType, PrivilegeLevel
+ stored = 0
+ campaign_id = getattr(getattr(self, "campaign", None), "id", "")
+
+ for entry in laps_entries:
+ comp = entry.get("computer") or entry.get("computer_name") or ""
+ pwd = entry.get("password", "")
+
+ # 1. Direct write to context vault if ctx available (protected by Gate 6)
+ if ctx and hasattr(ctx, "record_credential"):
+ try:
+ res = ctx.record_credential(
+ username=f"{comp}\\Administrator",
+ secret=pwd,
+ cred_type=CredentialType.CLEARTEXT,
+ target=comp,
+ privilege="local_admin",
+ source="laps_enum",
+ )
+ if asyncio.iscoroutine(res):
+ await res
+ except Exception as exc:
+ logger.debug("laps_ctx_record_failed", computer=comp, error=str(exc)[:60])
+
+ # 2. Direct write to campaign or passed vault (fallback / direct call)
+ if _vault:
try:
cred = Credential(
campaign_id = campaign_id,
username = "Administrator",
- domain = entry["computer"], # host-scoped
+ domain = comp, # host-scoped
cred_type = CredentialType.CLEARTEXT,
privilege = PrivilegeLevel.LOCAL_ADMIN,
source_module = self.MODULE_ID,
- target_host = entry["computer"],
+ target_host = comp,
)
- _vault.store(cred, entry["password"])
+ _vault.store(cred, pwd)
stored += 1
except Exception as exc:
logger.debug("laps_vault_store_failed",
- computer=entry["computer"], error=str(exc)[:60])
+ computer=comp, error=str(exc)[:60])
+
+ # Tulis ke raw TANPA password (OPSEC)
+ raw_entry = {k: v for k, v in entry.items() if k != "password"}
+ raw_entry["has_password"] = True # flag bahwa password ada di vault
+ raw_entries.append(raw_entry)
+
+ if stored:
logger.info("laps_stored_to_vault", count=stored)
self.finding(
@@ -252,8 +283,8 @@ class LAPSEnumModule(BaseModule[LAPSEnumParams, ModuleResult]):
mitre_tactic = "Credential Access",
evidence = {
"host_count": len(laps_entries),
- "computers": [e["computer"] for e in laps_entries[:20]],
- "laps_version": list({e["version"] for e in laps_entries}),
+ "computers": [e.get("computer") or e.get("computer_name") for e in laps_entries[:20]],
+ "laps_version": list({e.get("version", "v1") for e in laps_entries}),
"note": "Plaintext passwords in vault - not shown in findings",
},
remediation = (
@@ -265,14 +296,12 @@ class LAPSEnumModule(BaseModule[LAPSEnumParams, ModuleResult]):
)
raw = {
- "found": len(laps_entries),
- "entries": [{"computer": e["computer"], "expiry": e.get("expiry", ""),
- "version": e["version"]}
- for e in laps_entries], # passwords omitted from raw
+ "found": len(raw_entries),
+ "entries": raw_entries, # passwords omitted from raw
}
await self.noise.jitter.sleep()
- raw["laps_passwords"] = raw.get("entries", []) # OUTPUTS key
- raw["valid_credentials"] = raw.get("found", 0) # OUTPUTS key
+ raw["laps_passwords"] = raw_entries # OUTPUTS key
+ raw["valid_credentials"] = raw_entries # OUTPUTS key
return self._findings[:], raw
def _query_laps_sync(self, dc: str, username: str, password: str,
diff --git a/ares/normalize/artifacts.py b/ares/normalize/artifacts.py
index 662f207..3406763 100644
--- a/ares/normalize/artifacts.py
+++ b/ares/normalize/artifacts.py
@@ -242,6 +242,8 @@ class CredentialArtifact(NormalizedArtifact):
target: str = "" # alias for source_host
protocol: str = "" # ssh | smb | winrm | rdp etc
privilege: str = "" # domain_admin | service_account | local_admin | user | unknown
+ has_password: bool = False
+ note: str = ""
def __post_init__(self) -> None:
self.artifact_type = ArtifactType.CREDENTIAL
@@ -268,9 +270,9 @@ class CredentialArtifact(NormalizedArtifact):
"username": self.username, "domain": self.domain,
"cred_type": self.cred_type, "cracked": self.cracked,
"source_host": self.source_host, "privilege": self.privilege,
+ "protocol": self.protocol, "has_password": self.has_password,
+ "note": self.note,
}
- if self.protocol:
- d["protocol"] = self.protocol
return d
@@ -796,13 +798,19 @@ class ArtifactNormalizer:
continue
comp = e.get("computer") or e.get("computer_name") or e.get("host", "")
pwd = e.get("password", "")
+ has_pwd = bool(e.get("has_password", False) or pwd)
+ note = ""
+ if not pwd and e.get("has_password"):
+ note = "password stored in vault"
artifact = CredentialArtifact(
username = e.get("username", "Administrator"),
- domain = e.get("domain", ""),
+ domain = e.get("domain", "") or comp,
cred_type = "laps",
secret = pwd,
source_host = comp,
privilege = "local_admin",
+ has_password= has_pwd,
+ note = note,
)
store.add(artifact)
count += 1
diff --git a/tests/unit/test_artifact_normalizer_pipeline.py b/tests/unit/test_artifact_normalizer_pipeline.py
index 8745215..dc2d979 100644
--- a/tests/unit/test_artifact_normalizer_pipeline.py
+++ b/tests/unit/test_artifact_normalizer_pipeline.py
@@ -329,6 +329,67 @@ def test_laps_passwords_pipeline(normalizer: ArtifactNormalizer, store: Artifact
assert creds[0].privilege == "local_admin"
+async def test_laps_opsec_direct_vault_pipeline_mod_055(normalizer: ArtifactNormalizer, store: ArtifactStore):
+ """
+ MOD-055: LAPS module writes passwords directly to vault (Gate 6 validated),
+ while raw output omits password for OPSEC and sets has_password=True.
+ Normalizer ingests has_password=True and creates CredentialArtifact with secret="" and note.
+ """
+ from unittest.mock import patch
+ from tests.unit.modules.test_modules import _make_module
+ from ares.modules.ad.laps_enum import LAPSEnumModule
+ from ares.credential.vault import CredentialVault
+ from ares.core.context import ExecutionContext
+
+ mod, _ = _make_module(LAPSEnumModule)
+ vault = CredentialVault(encryption_key=None)
+ ctx = ExecutionContext(
+ target="10.0.0.1",
+ domain="corp.local",
+ vault=vault,
+ network_io_occurred=True,
+ )
+
+ mock_entries = [
+ {"computer": "PC-FINANCE-01", "password": "RealSecretLapsPassword123!", "version": "v1", "expiry": ""},
+ ]
+
+ with patch.object(mod, "_query_laps_sync", return_value=mock_entries):
+ findings, raw = await mod.run(
+ dc="10.0.0.1",
+ domain="corp.local",
+ username="analyst",
+ password="fake_login_pwd",
+ vault=vault,
+ ctx=ctx,
+ )
+
+ # 1. raw output does NOT contain plaintext password (OPSEC safe)
+ assert raw["entries"][0].get("has_password") is True
+ assert "password" not in raw["entries"][0]
+ assert "password" not in raw["laps_passwords"][0]
+
+ # 2. Vault contains full password (Gate 6 passed valid CLEARTEXT)
+ stored_creds = [c for c in vault._store.values() if "PC-FINANCE-01" in getattr(c, "domain", "") or "PC-FINANCE-01" in getattr(c, "target_host", "")]
+ assert len(stored_creds) >= 1
+ cred_id = stored_creds[0].id
+ revealed_secret = vault.reveal(cred_id)
+ assert revealed_secret == "RealSecretLapsPassword123!"
+
+ # 3. Normalizer creates CredentialArtifact with has_password=True and note
+ added = normalizer.normalize("ad.laps_enum", ["laps_passwords"], raw, store)
+ assert added == 1
+ artifacts = store.credentials()
+ assert len(artifacts) == 1
+ assert artifacts[0].username == "Administrator"
+ assert artifacts[0].source_host == "PC-FINANCE-01"
+ assert artifacts[0].secret == ""
+ assert artifacts[0].has_password is True
+ assert artifacts[0].note == "password stored in vault"
+
+
+
def test_kerberos_tickets_pipeline(normalizer: ArtifactNormalizer, store: ArtifactStore):
"""lateral.ntlm_relay / linux.ccache_hunt write tickets; normalizer must create CredentialArtifact."""
raw = {