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): add normalizer handlers for lsa_secrets and cached domain credentials (MOD-028)

Mafifrizi56ca2320537d
diff --git a/ares/normalize/artifacts.py b/ares/normalize/artifacts.py
index e1b1e5d..6e31cab 100644
--- a/ares/normalize/artifacts.py
+++ b/ares/normalize/artifacts.py
@@ -492,6 +492,11 @@ class ArtifactNormalizer:
"golden_ticket": self._normalize_kerberos_tickets,
"open_ports": self._normalize_open_ports,
"service_map": self._normalize_open_ports,
+ # LSA Secrets & Cached Domain Credentials (MOD-028)
+ "lsa_secrets": self._normalize_lsa_secrets,
+ "windows.lsa_secrets": self._normalize_lsa_secrets,
+ "cached_credentials": self._normalize_cached_domain_credentials,
+ "cached_domain_credentials": self._normalize_cached_domain_credentials,
}
handler = handlers.get(capability)
if handler:
@@ -864,3 +869,104 @@ class ArtifactNormalizer:
)
store.add(artifact)
return 1
+
+ def _normalize_lsa_secrets(self, raw: dict, store: ArtifactStore) -> int:
+ """
+ Normalize LSA secrets (service accounts, machine account passwords, DPAPI keys)
+ into CredentialArtifact(cred_type="lsa_secret").
+ """
+ secrets = raw.get("lsa_secrets") or []
+ if isinstance(secrets, (str, dict)):
+ secrets = [secrets]
+ count = 0
+ target = raw.get("target") or raw.get("host", "")
+ domain_default = raw.get("domain", "")
+ for s in secrets:
+ if isinstance(s, dict):
+ username = s.get("username") or s.get("name") or s.get("secret_name", "")
+ domain = s.get("domain") or domain_default
+ secret_val = s.get("secret") or s.get("value") or s.get("password", "")
+ source_host = s.get("host") or s.get("target") or target
+ privilege = s.get("privilege") or ("service_account" if ("$MACHINE.ACC" in username or "_SC_" in username) else "unknown")
+ elif isinstance(s, str):
+ s_str = s.strip()
+ if ":" in s_str:
+ name_part, val_part = s_str.split(":", 1)
+ username = name_part.strip()
+ secret_val = val_part.strip()
+ else:
+ username = ""
+ secret_val = s_str
+ domain = domain_default
+ source_host = target
+ privilege = "service_account" if ("$MACHINE.ACC" in username or "_SC_" in username or "DPAPI" in username) else "unknown"
+ else:
+ continue
+
+ artifact = CredentialArtifact(
+ username=username,
+ domain=domain,
+ cred_type="lsa_secret",
+ secret=secret_val,
+ cracked=False,
+ source_host=source_host,
+ privilege=privilege,
+ )
+ store.add(artifact)
+ count += 1
+ return count
+
+ def _normalize_cached_domain_credentials(self, raw: dict, store: ArtifactStore) -> int:
+ """
+ Normalize DCC2 / MSCACHE2 cached domain hashes into CredentialArtifact(cred_type="cached_domain", cracked=False).
+ """
+ cached = raw.get("cached_credentials") or raw.get("cached_creds", [])
+ if isinstance(cached, (str, dict)):
+ cached = [cached]
+ count = 0
+ target = raw.get("target") or raw.get("host", "")
+ domain_default = raw.get("domain", "")
+ for c in cached:
+ if isinstance(c, dict):
+ username = c.get("username", "")
+ domain = c.get("domain") or domain_default
+ hash_val = c.get("hash") or c.get("secret", "")
+ source_host = c.get("host") or c.get("target") or target
+ privilege = c.get("privilege", "user")
+ elif isinstance(c, str):
+ c_str = c.strip()
+ if ":" in c_str:
+ user_part, hash_part = c_str.split(":", 1)
+ if "\\" in user_part:
+ domain, username = user_part.split("\\", 1)
+ else:
+ domain = domain_default
+ username = user_part
+ hash_val = hash_part.strip()
+ elif "#" in c_str and ("$DCC2$" in c_str or "$MSCACHE2$" in c_str):
+ parts = c_str.split("#")
+ username = parts[1] if len(parts) > 1 else ""
+ domain = domain_default
+ hash_val = c_str
+ else:
+ username = ""
+ domain = domain_default
+ hash_val = c_str
+ source_host = target
+ privilege = "user"
+ else:
+ continue
+
+ artifact = CredentialArtifact(
+ username=username,
+ domain=domain,
+ cred_type="cached_domain",
+ secret=hash_val,
+ cracked=False,
+ source_host=source_host,
+ privilege=privilege,
+ )
+ store.add(artifact)
+ count += 1
+ return count
+
diff --git a/tests/unit/test_artifact_normalizer_pipeline.py b/tests/unit/test_artifact_normalizer_pipeline.py
index e9fa86b..05ffa79 100644
--- a/tests/unit/test_artifact_normalizer_pipeline.py
+++ b/tests/unit/test_artifact_normalizer_pipeline.py
@@ -337,3 +337,97 @@ def test_acl_findings_permissions_pipeline(normalizer: ArtifactNormalizer, store
assert perms[0].is_dangerous is True
assert perms[0].right == "GenericAll"
+
+def test_lsa_secrets_pipeline_recovers_credentials(normalizer: ArtifactNormalizer, store: ArtifactStore):
+ """windows.lsa_secrets writes raw['lsa_secrets']; normalizer must ingest into CredentialArtifact(cred_type='lsa_secret')."""
+ raw = {
+ "target": "10.0.0.15",
+ "domain": "CORP.LOCAL",
+ "sam_hashes": ["Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::"],
+ "lsa_secrets": [
+ "$MACHINE.ACC: plain_password_hex_31323334",
+ "_SC_MSSQLSERVER: ComplexServicePassword!2024",
+ "DPAPI_SYSTEM: 01000000d08c9ddf0115d1118c7a00c04fc297eb01000000",
+ ],
+ "cached_credentials": [],
+ "errors": [],
+ }
+ added = normalizer.normalize("windows.lsa_secrets", ["lsa_secrets"], raw, store)
+ assert added == 3
+ creds = store.credentials()
+ assert len(creds) == 3
+
+ assert creds[0].username == "$MACHINE.ACC"
+ assert creds[0].cred_type == "lsa_secret"
+ assert creds[0].secret == "plain_password_hex_31323334"
+ assert creds[0].source_host == "10.0.0.15"
+ assert creds[0].cracked is False
+
+ assert creds[1].username == "_SC_MSSQLSERVER"
+ assert creds[1].secret == "ComplexServicePassword!2024"
+ assert creds[1].privilege == "service_account"
+
+ assert creds[2].username == "DPAPI_SYSTEM"
+ assert creds[2].cred_type == "lsa_secret"
+
+
+def test_cached_domain_credentials_pipeline_recovers_credentials(normalizer: ArtifactNormalizer, store: ArtifactStore):
+ """windows.lsa_secrets writes raw['cached_credentials']; normalizer must ingest into CredentialArtifact(cred_type='cached_domain', cracked=False)."""
+ raw = {
+ "target": "10.0.0.15",
+ "domain": "CORP.LOCAL",
+ "sam_hashes": [],
+ "lsa_secrets": [],
+ "cached_credentials": [
+ "CORP.LOCAL\\jdoe:$DCC2$10240#jdoe#5f4dcc3b5aa765d61d8327deb882cf99",
+ "$DCC2$10240#admin_ops#8b1a9953c4611296a827abf8c47804d7",
+ ],
+ "errors": [],
+ }
+ added = normalizer.normalize("windows.lsa_secrets", ["cached_credentials"], raw, store)
+ assert added == 2
+ creds = store.credentials()
+ assert len(creds) == 2
+
+ assert creds[0].username == "jdoe"
+ assert creds[0].domain == "CORP.LOCAL"
+ assert creds[0].cred_type == "cached_domain"
+ assert creds[0].cracked is False
+ assert creds[0].secret == "$DCC2$10240#jdoe#5f4dcc3b5aa765d61d8327deb882cf99"
+ assert creds[0].source_host == "10.0.0.15"
+
+ assert creds[1].username == "admin_ops"
+ assert creds[1].cred_type == "cached_domain"
+ assert creds[1].cracked is False
+
+
+def test_lsa_secrets_and_cached_creds_dict_structure(normalizer: ArtifactNormalizer, store: ArtifactStore):
+ """Test structured dictionary input for lsa_secrets and cached_creds fallback."""
+ raw = {
+ "target": "10.0.0.20",
+ "lsa_secrets": [
+ {"username": "svc_backup", "domain": "CORP", "secret": "BackupPass123!", "privilege": "service_account"}
+ ],
+ "cached_creds": [
+ {"username": "d_admin", "domain": "CORP", "hash": "dcc2_hash_value", "privilege": "domain_admin"}
+ ],
+ }
+ added_lsa = normalizer.normalize("windows.lsa_secrets", ["lsa_secrets"], raw, store)
+ assert added_lsa == 1
+
+ added_cached = normalizer.normalize("windows.lsa_secrets", ["cached_credentials"], raw, store)
+ assert added_cached == 1
+
+ creds = store.credentials()
+ assert len(creds) == 2
+
+ lsa_cred = next(c for c in creds if c.cred_type == "lsa_secret")
+ assert lsa_cred.username == "svc_backup"
+ assert lsa_cred.secret == "BackupPass123!"
+
+ cached_cred = next(c for c in creds if c.cred_type == "cached_domain")
+ assert cached_cred.username == "d_admin"
+ assert cached_cred.secret == "dcc2_hash_value"
+ assert cached_cred.cracked is False
+
+