ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.
Python active-directorycloud-securitydefensive-validationfastapigood-first-issuemitre-attackopsecreactred-teamreportingsecurity
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"),
campaign=params.get("campaign"),
best_credential=lambda: None,
)
@pytest.mark.parametrize(
("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": "10.0.0.1", "domain": "example.com"},
{"target": "10.0.0.1", "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.network.pivot",
"PivotModule",
{"target": "10.0.0.1", "username": "admin", "password": "pw", "local_port": 1080},
{"target": "10.0.0.1", "username": "admin", "local_port": 1080},
),
(
"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.applocker_bypass",
"AppLockerBypassModule",
{"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
{"target": "10.0.0.1", "username": "user", "domain": "corp"},
),
(
"ares.modules.windows.dpapi",
"DPAPIModule",
{"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
{"target": "10.0.0.1", "username": "user", "domain": "corp"},
),
(
"ares.modules.windows.lsass_dump",
"LsassDumpModule",
{"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
{"target": "10.0.0.1", "username": "user", "domain": "corp"},
),
(
"ares.modules.windows.registry_enum",
"RegistryEnumModule",
{"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
{"target": "10.0.0.1", "username": "user", "domain": "corp"},
),
(
"ares.modules.windows.scheduled_tasks_enum",
"ScheduledTasksEnumModule",
{"target": "10.0.0.1", "username": "user", "password": "pw", "domain": "corp"},
{"target": "10.0.0.1", "username": "user", "domain": "corp"},
),
(
"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.uac_bypass",
"UACBypassModule",
{"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"]},
),
(
"ares.modules.persistence.scheduled_task",
"ScheduledTaskPersistence",
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"domain": "corp.local",
"task_name": "AresUpdater",
"command": "powershell.exe -NoP -W Hidden",
},
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"task_name": "AresUpdater",
},
),
(
"ares.modules.persistence.scheduled_task",
"RegistryRunKeyPersistence",
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"domain": "corp.local",
"key_name": "AresUpdate",
"command": r"C:\Windows\Temp\ares.exe",
},
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"value_name": "AresUpdate",
"payload": r"C:\Windows\Temp\ares.exe",
},
),
(
"ares.modules.persistence.wmi_subscription",
"WMISubscriptionModule",
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"domain": "corp.local",
"subscription_name": "AresMonitor",
"command": "powershell.exe -NoP -W Hidden",
},
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"subscription_name": "AresMonitor",
},
),
(
"ares.modules.exfil.secrets_scan",
"SecretsScan",
{
"target": "10.0.0.1",
"username": "root",
"password": "Password1!",
"key_path": "/root/.ssh/id_rsa",
"platform": "linux",
},
{
"target": "10.0.0.1",
"username": "root",
"password": "Password1!",
"key_path": "/root/.ssh/id_rsa",
"platform": "linux",
},
),
(
"ares.modules.exfil.smb_shares",
"SmbSharesExfil",
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"domain": "corp.local",
"max_depth": 2,
},
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"domain": "corp.local",
"max_depth": 2,
},
),
(
"ares.modules.exfil.staged_collection",
"StagedCollectionModule",
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"destination": "/tmp/staged",
"platform": "linux",
"max_files": 100,
},
{
"target": "10.0.0.1",
"username": "admin",
"password": "Password1!",
"destination": "/tmp/staged",
"platform": "linux",
"max_files": 100,
},
),
(
"ares.modules.recon.fingerprint",
"FingerprintModule",
{
"target": "10.0.0.1",
"username": "admin",
"domain": "corp.local",
"secret": "Password1!",
"timeout": 5.0,
},
{
"target": "10.0.0.1",
"username": "admin",
"domain": "corp.local",
"secret": "Password1!",
"timeout": 5.0,
},
),
(
"ares.modules.edr.bypass_adaptive",
"EDRAdaptiveBypassModule",
{
"target": "10.0.0.1",
"edr_vendor": "crowdstrike",
"os_version": "Windows Server 2022",
},
{
"target": "10.0.0.1",
"edr_vendor": "crowdstrike",
"os_version": "Windows Server 2022",
},
),
(
"ares.modules.opsec.coverage_predictor",
"CoveragePredictorModule",
{
"noise_profile": "stealth",
},
{
"noise_profile": "stealth",
},
),
(
"ares.modules.ai.autonomous_planner",
"AIAutonomousPlannerModule",
{
"goal": "domain_admin",
"llm_backend": "claude",
"llm_model": "claude-3-7-sonnet",
"auto_approve": False,
},
{
"goal": "domain_admin",
"llm_backend": "claude",
"llm_model": "claude-3-7-sonnet",
"auto_approve": False,
},
),
(
"ares.modules.cloud.aws",
"AWSEnumModule",
{
"profile": "prod",
"access_key": "AKIAIOSFODNN7EXAMPLE",
"region": "us-west-2",
},
{
"profile": "prod",
"access_key": "AKIAIOSFODNN7EXAMPLE",
"region": "us-west-2",
},
),
(
"ares.modules.cloud.aws_privesc",
"AWSPrivescModule",
{
"profile": "prod",
"access_key": "AKIAIOSFODNN7EXAMPLE",
"region": "us-west-2",
},
{
"profile": "prod",
"access_key": "AKIAIOSFODNN7EXAMPLE",
"region": "us-west-2",
},
),
(
"ares.modules.cloud.azure",
"AzureModule",
{
"subscription_id": "00000000-0000-0000-0000-000000000000",
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
},
{
"subscription_id": "00000000-0000-0000-0000-000000000000",
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
},
),
(
"ares.modules.cloud.azure_ad",
"AzureADModule",
{
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
"technique": "enumerate",
},
{
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
"technique": "enumerate",
},
),
(
"ares.modules.cloud.gcp",
"GCPModule",
{
"project_id": "corp-cloud-prod",
"credentials_file": "/tmp/sa.json",
},
{
"project_id": "corp-cloud-prod",
"credentials_file": "/tmp/sa.json",
},
),
(
"ares.modules.cloud.identity_federation",
"CloudIdentityFederationModule",
{
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
"domain": "corp.local",
"mode": "enumerate",
},
{
"tenant_id": "11111111-1111-1111-1111-111111111111",
"client_id": "22222222-2222-2222-2222-222222222222",
"domain": "corp.local",
"mode": "enumerate",
},
),
],
)
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)
if getattr(cls, "ENABLED", True) is False:
from ares.core.errors import ModuleError
with pytest.raises(ModuleError, match="module disabled"):
_run(mod.execute(_ctx(params)))
return
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"]