🔏
RootGuard
HomeSOC OperationsIncident ResponseWindows ForensicsLinux ForensicsKQL Investigations
  • Welcome
    • RootGuard
      • Who Am I?
        • Professional Profile
  • Resources Hub
    • Blogs
      • Articles
        • Safeguarding SMEs: The Strategic Importance of a Security Operations Center (SOC)
      • Posts
        • Roadmap to Becoming a Cybersecurity Specialist
        • Starting a Career in Cybersecurity
        • A Guide to Landing Your First Cybersecurity Analyst Role
        • Moving from Intermediate to Expert Incident Responder
  • SOC Operations
    • Introduction
      • Development Resources
        • SOC Analysts Roadmap
        • Becoming A SOC Analyst
        • SOC Analysts Prep Interview Questions
    • Essential Skills
      • Critical Windows EventIDs to Monitor
    • Junior Analyst Skills
      • Splunk Use Cases
      • KQL Use Cases
        • Reconnaissance (TA0043)
        • Initial Access (TA0001)
        • Execution (TA0002)
        • Persistence (TA0003)
        • Privilege Escalation (TA0004)
        • Defence Evasion (TA0005)
        • Credential Access (TA0006)
        • Discovery (TA0007)
        • Lateral Movement (TA0008)
        • Collection (TA0009)
        • Command and Control (TA0011)
        • Exfiltration (TA0010)
        • Impact (TA0040)
      • Investigating Common Attacks
        • Domain Dominance Attacks - Detection & Analysis
        • Investigating a Suspected AD FS Distributed Key Management (DKM) Attack
        • Authentication From Suspicious DeviceName
        • Identifying Interactive or RemoteInteractive Session From Service Account
        • Identifying Split or Part Archive File Transfers
        • Detect Potential Cleartext Credentials in Command Line
        • Detecting Command Line Interpreters Launched via Scheduled Tasks
        • Detecting Files Containing Potentially Sensitive Data
        • Detecting DeviceNetworkEvents From Windows Processes and Domains by TLD
        • Detecting Silent cmd.exe Execution With Redirected STDERR & STDOUT
        • Detecting Low Prevalence DLL Loaded From Process In User Downloads Directory
        • Detecting Virtual Drive Mounted From Archive
        • Identify Execution of Script From User's Downloads Folder
        • Identify Potential RDP Tunneled Sessions
        • Identify Instances of PowerShell Invoke-WebRequest, IWR or Net.WebClient
        • Identify Processes Launched by PowerShell Remoting (WSMProvHost.exe)
        • Detect DeviceNetworkEvents for LOLBAS with Download or Upload Functions
        • Detect Execution of PSEXESVC via Remote Systems
        • Identify Suspicious String in Service Creation ImagePath
        • Identify File with Double Extensions
        • Detect Potential Cleartext Credentials in Commandline
        • Detect When Large Number of Files Downloaded From OneDrive or SharePoint
        • Identify and Investigate Phishing Attacks with KQL
      • PowerShell for SecOps
        • Powershell Remoting
        • Reconnaissance Discovery
        • Initial Access Discovery
        • Execution Discovery
        • Persistence Discovery
        • Privilege Escalation Discovery
        • Defence Evasion Discovery
        • Credential Access Discovery
        • Discovery
        • Lateral Movement Discovery
        • Collection Discovery
        • Command & Control (C2) Discovery
        • Exfiltration Discovery
        • Impact Discovery
      • Packet Analysis (pcap)
        • Tcpdump
        • Tcpdump (Intermediate)
        • Tshark
        • Ngrep
      • Investigating Suspicious Emails Using KQL
    • Intermediate and Advanced Skills
      • Investigate Using MITRE ATT&CK Methodology
        • Reconnaissance (TA0043) Techniques
        • Resource Development (TA0042) Techniques
        • Initial Access (TA0001) Techniques
        • Command Execution (TA0002) Techniques
        • Persistence (TA0003) Techniques
        • Privilege Escalation (TA0004) Techniques
        • Defence Evasion (TA0005) Techniques
        • Credential Access (TA0006) Techniques
        • Discovery (TA0007) Techniques
        • Lateral Movement (TA0008) Techniques
        • Collection (TA0009) Techniques
        • Command and Control (C2) (TA0011) Techniques
        • Exfiltration (TA0010) Techniques
        • Impact (TA0040) Techniques
    • Vulnerability Management
    • Malware Analysis
  • DFIR
    • Incident Response
      • Incident Triage
        • Triage Types and Processes
        • PowerShell for Detection and Analysis
          • Malware or Compromise Investigation
          • Lateral Movement Discovery
        • Registry Analysis
        • Sysinternals Intrusion Analysis
        • PowerShell Intrusion Analysis
        • Velociraptor Intrusion Analysis
        • Zimmerman Tools Intrusion Analysis
      • KAPE Artifacts Analysis
      • Velociraptor Artifacts Analysis
      • Using The Unified Kill Chain Model to Analyse Individual Cyber Attacks
        • Phase 1 - Gaining an Initial Foothold
          • Gaining Access to the Network
          • Establishing a Foothold
          • Network Discovery
      • Response Strategies
        • Privilege Escalation Assessment
        • Command and Control Assessment
        • Command Execution Assessment
        • Defence Evasion Assessment
        • Detection Assessment
        • Discovery Assessment
        • Exfiltration Assessment
        • Initial Access Assessment
        • Initial Impact Assessment Techniques
        • Lateral Movement Assessment
        • Persistence Assessment
    • Windows Forensics
      • Evidence of Execution
      • Window Artifact Analysis
        • Account Usage
        • User Activity Tracking (Event Logs)
        • Program Execution
        • File and Folder Opening
        • File Download
        • Browser Usage
        • Deleted File or File Knowledge
        • External Device & USB Usage
    • Linux Forensics
      • Linux Commandline Basics
      • Host Compromise Assessment
    • KQL for Defender & Sentinel
      • MDO (Office)
      • MDI (Identity)
      • MDE (Endpoint)
    • Memory Forensics
      • Memory Forensics (Volatility 3)
    • Playbooks
      • First Responder DFIR Playbook
        • Device Isolation
        • Evidence Collection
          • Acquire Triage Image Using KAPE
          • Acquire Triage Data Using Velociraptor
          • Acquire Triage Data Using Powershell
          • Acquire Triage Memory Image
          • Acquire Image Using FTK
          • AXIOM Cyber Data Collection
        • Windows Forensic Artefacts
          • Application Execution
          • File & Folder Knowledge
          • External Device Usage
          • Network Activity
          • Windows Event Logs
        • Initial Analysis
          • Memory Analysis (Vol 3)
          • Axiom Cyber Examiner
  • Detection Engineering
    • AD Attack Detections & Mitigations
      • Kerberoasting
      • Authentication Server Response (AS-REP) Roasting
      • Password Spraying
      • MachineAccountQuota Compromise
      • Unconstrained Delegation
      • Password in Group Policy Preferences (GPP) Compromise
      • Active Directory Certificate Services (AD CS) Compromise
      • Golden Certificate
      • DCSync
      • Dumping ntds.dit
      • Golden Ticket
      • Silver Ticket
      • Golden Security Assertion Markup Language (SAML)
      • Microsoft Entra Connect Compromise
      • One-way Domain Trust Bypass
      • Security Identifier (SID) History Compromise
      • Skeleton Key
      • Active Directory Security Controls
      • Active Directory Events for Detecting Compromise
    • Attack Triage Playbooks (KQL Triage)
      • Windows Malware Detection Playbook
      • Linux Host Intrusion Detection Playbook (CLI)
      • Linux Intrusion Detection Playbook
      • Large-Scale Compromise Detection Playbook
      • Ransomware Detection Playbook
      • Phishing Email Compromise Detection Playbook
      • Scam Detection Playbook
      • Customer Phishing Detection Playbook
      • Insider Abuse Detection Playbook
      • Information Leakage Detection Playbook
      • Social Engineering Detection Playbook
      • Malicious Network Behaviour Detection Playbook
      • Windows Intrusion Detection Playbook
      • Vulnerability Detection Playbook
      • Business Email Compromise Detection Playbook
    • Process Execution (KQL Triage)
    • Threat Hunting
      • Hunting Ransomware Indicators
      • Hunting With KQL
        • Detecting Malware Infection (MITRE ATT&CK: T1566, T1059)
        • Discovery Activities (MITRE ATT&CK: T1016, T1083, T1046)
        • Credential Theft (MITRE ATT&CK: T1003, T1078)
        • Lateral Movement (MITRE ATT&CK: T1076, T1021)
        • Data Theft (MITRE ATT&CK: T1041, T1071)
        • Detecting CommandLine Executions (MITRE ATT&CK: T1059)
        • Windows Security Logs (Identity and Logon Activities)
      • Hunting With Splunk
Powered by GitBook
On this page
  • Introduction
  • How Password Spraying Works
  • Why Password Spraying is Effective
  • Indicators of Password Spraying
  • Mitigation Strategies
  • Detection Techniques
  • KQL Detection Queries
  • Splunk Detection Queries
  • Reference
Edit on GitHub
  1. Detection Engineering
  2. AD Attack Detections & Mitigations

Password Spraying

Introduction

Password spraying is a technique used by attackers to gain unauthorised access to user accounts by exploiting weak or commonly used passwords. Unlike traditional brute-force attacks that repeatedly try many passwords on a single account (risking account lockout due to failed attempts), password spraying involves attempting a single password across multiple accounts. This method helps avoid triggering lockout policies, making it a stealthier and more effective attack technique.

Password spraying is categorised under the Credential Access tactic in the MITRE ATT&CK framework (ID: T1110.003) and is frequently used as a precursor to further attacks, such as lateral movement, privilege escalation, or data exfiltration.


How Password Spraying Works

  1. Account Discovery:

    • Attackers compile a list of valid usernames or email addresses.

    • This can be achieved through OSINT (Open Source Intelligence), compromised databases, or reconnaissance tools.

  2. Weak Password Selection:

    • Commonly used passwords, such as Password123, Welcome1, or season/year combinations like Spring2025, are selected as attack vectors.

  3. Spraying Process:

    • A single weak password is tested across multiple accounts.

    • If unsuccessful, another password is selected, avoiding consecutive failed attempts on any single account to evade lockout policies.

  4. Successful Compromise:

    • Once a valid username-password pair is identified, the attacker gains unauthorised access to the account.

    • They can then escalate privileges or use the account to launch further attacks.


Why Password Spraying is Effective

  1. Avoids Lockouts:

    • By distributing authentication attempts across many accounts, attackers stay under account lockout thresholds.

  2. Exploits Weak Password Policies:

    • Organisations with poorly enforced password complexity policies are especially vulnerable.

  3. Large Attack Surface:

    • Modern organisations with hundreds or thousands of user accounts provide attackers with ample opportunities.

  4. Low Detection Probability:

    • Spraying attacks mimic normal authentication attempts, making them harder to detect.


Indicators of Password Spraying

  1. High Volume of Failed Logons:

    • A significant number of failed authentication attempts distributed across multiple accounts within a short timeframe.

  2. Unusual Authentication Sources:

    • Logon attempts originating from unknown or suspicious IP addresses, especially from geographic locations where the organisation has no presence.

  3. Targeting Multiple Accounts:

    • Logon failures affecting many accounts, often with the same password.

  4. Successful Logons Following Failures:

    • Successful logons from the same IP after multiple failed attempts suggest spraying success.


Mitigation Strategies

  1. Strong Password Policies:

    • Enforce password complexity requirements (e.g., length, special characters, and no common passwords).

    • Implement password expiration policies.

  2. Multi-Factor Authentication (MFA):

    • Require MFA for all user accounts, making password spraying ineffective even if the password is compromised.

  3. Account Lockout Policies:

    • Configure account lockout settings to limit the number of failed login attempts.

  4. Monitor Authentication Logs:

    • Continuously analyse logs for patterns of failed and successful logons.

    • Set alerts for unusual logon activity.

  5. Limit Exposure:

    • Reduce publicly accessible account lists, such as employee directories or email address formats.

  6. User Awareness Training:

    • Educate users on creating strong passwords and recognising social engineering techniques.


Detection Techniques

  1. Log Analysis:

    • Event ID 4625: Monitor logs for failed login attempts.

    • Event ID 4624: Event is generated when an object logs on successfully, such as to a user

    • Event ID 2889: Event is generated when a computer object tries to make an unsigned LDAP bind.

    • Event ID 4648: Event is generated when a logon is attempted using explicit credentials.

    • Event ID 4740: Event is generated when a user object is locked out.

    • Event ID 4771: Event is generated when Kerberos pre-authentication fails.

    • Detect patterns of failures distributed across multiple accounts from the same IP.

  2. Correlation Rules:

    • Use SIEM solutions (e.g., Splunk, Sentinel) to detect suspicious patterns, such as failed logons from unusual IPs followed by a successful logon.

  3. Geographic Analysis:

    • Flag logons from locations inconsistent with the user's typical behaviour.

  4. Threat Intelligence Integration:

    • Cross-reference IP addresses with known malicious actors or threat intelligence feeds.


Password spraying remains a prevalent and effective attack method due to its simplicity and the prevalence of weak passwords in many organisations. By understanding how it works and proactively implementing strong defences and monitoring, organisations can significantly reduce their exposure to this attack vector.

KQL Detection Queries

Query to Detect Password Spraying

let FailedLogons = SecurityEvent
| where EventID == 4625  // Failed logons
| extend AccountName = tostring(TargetUserName), 
         ClientIP = tostring(IpAddress), 
         FailureReason = tostring(Status)
| summarize FailedAttempts = count(), UniqueAccounts = dcount(AccountName) 
    by ClientIP, bin(TimeGenerated, 15m)  // Group by client IP and 15-minute intervals
| where FailedAttempts > 10 and UniqueAccounts > 5;  // Thresholds for potential spraying

let SuccessfulLogons = SecurityEvent
| where EventID == 4624  // Successful logons
| extend AccountName = tostring(TargetUserName), ClientIP = tostring(IpAddress)
| summarize SuccessfulAttempts = count(), UniqueAccounts = dcount(AccountName) 
    by ClientIP, bin(TimeGenerated, 15m);

FailedLogons
| join kind=inner (SuccessfulLogons) on ClientIP, TimeGenerated
| extend SuspiciousScore = case(
    FailedAttempts > 20 and UniqueAccounts > 10 and SuccessfulAttempts > 5, "High",
    FailedAttempts > 10 and UniqueAccounts > 5, "Medium",
    "Low"
)
| project TimeGenerated, ClientIP, FailedAttempts, SuccessfulAttempts, UniqueAccounts, SuspiciousScore
| where SuspiciousScore in ("High", "Medium")
| sort by SuspiciousScore desc, FailedAttempts desc

Query Breakdown

  1. Failed Logons (Event ID 4625):

    • Captures failed logon events, grouping by ClientIP and aggregating failed attempts over 15-minute intervals.

    • Identifies IPs with a high number of failed attempts and multiple targeted accounts:

      • FailedAttempts > 10: Adjust based on environment baseline.

      • UniqueAccounts > 5: Indicates many accounts were targeted.

  2. Successful Logons (Event ID 4624):

    • Captures successful logons from the same IPs within the same 15-minute window.

    • Identifies instances where spraying attempts succeeded.

  3. Suspicious Scoring:

    • Assigns a SuspiciousScore based on the severity of activity:

      • High: Over 20 failed attempts, more than 10 accounts, and successful logons.

      • Medium: Over 10 failed attempts and 5 accounts targeted.

  4. Correlation:

    • Joins failed logon data with successful logon data using ClientIP and TimeGenerated.

  5. Final Output:

    • Displays the client IP, time, number of failed attempts, number of successful attempts, and targeted accounts.

    • Focuses on High and Medium suspicious activity.


Customisations

  1. Threshold Tuning:

    • Adjust thresholds (FailedAttempts > 10, UniqueAccounts > 5) based on the baseline of your environment.

  2. Time Binning:

    • Modify bin(TimeGenerated, 15m) to adjust the time window for detecting spraying.

  3. Exclusions:

    • Exclude trusted IPs or service accounts to reduce false positives:

      | where not (ClientIP in ("trusted_ip1", "trusted_ip2") or AccountName startswith "svc_")

Additional Recommendations

  1. Alert Configuration:

    • Set up alerts for SuspiciousScore = High to notify SOC analysts.

  2. Dashboard Integration:

    • Create a visualisation showing failed logon trends, unique accounts targeted, and suspicious IPs.

  3. Threat Intelligence:

    • Cross-reference ClientIP with known malicious IPs from threat intelligence feeds.

// Define the time range for the query
let startTime = ago(7d);
let endTime = now();

// Define thresholds for suspicious activity
let Threshold_FailedLogons = 10;
let Threshold_UniqueIPs = 3;
let RareAccountThreshold = 5;

// Step 1: Identify failed logon attempts (Event ID 4625)
let FailedLogons = SecurityEvent
| where TimeGenerated between (startTime .. endTime)
| where EventID == 4625
| extend AccountName = tostring(TargetUserName), Domain = tostring(TargetDomainName), ClientIP = tostring(IpAddress), FailureReason = tostring(Status)
| project AccountName, Domain, ClientIP, FailureReason, TimeGenerated;

// Step 2: Aggregate failed logon activity
let Aggregated_FailedLogons = FailedLogons
| summarize FailedLogonCount = count(), UniqueIPs = dcount(ClientIP), ClientIPs = make_set(ClientIP), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by AccountName, Domain;

// Step 3: Identify Rare Accounts (Low Authentication Activity)
let RareAccounts = SecurityEvent
| where EventID == 4624 // Successful Logon
| summarize LogonCount = count(), LogonIPs = make_set(IpAddress) by AccountName
| where LogonCount < RareAccountThreshold
| project AccountName, LogonCount, LogonIPs;

// Step 4: Combine Failed Logon Events with Rare Account Info
Aggregated_FailedLogons
| join kind=leftouter (RareAccounts) on AccountName
| extend IsRareAccount = iff(isnull(LogonCount), 1, 0)
| extend SuspiciousScore = case(
    FailedLogonCount > Threshold_FailedLogons and UniqueIPs > Threshold_UniqueIPs and IsRareAccount == 1, 3,
    FailedLogonCount > Threshold_FailedLogons and UniqueIPs > Threshold_UniqueIPs, 2,
    FailedLogonCount > Threshold_FailedLogons or UniqueIPs > Threshold_UniqueIPs, 1,
    0
)
| where SuspiciousScore > 0
| project AccountName, Domain, FailedLogonCount, UniqueIPs, ClientIPs, FirstSeen, LastSeen, IsRareAccount, SuspiciousScore
| sort by SuspiciousScore desc, FailedLogonCount desc

Query performs the following steps:

  1. Defines the time range for the query to look back over the past 7 days.

  2. Identifies failed logon attempts (Event ID 4625) and extracts relevant information.

  3. Aggregates failed logon activity to count the number of failed logons and unique IPs per account.

  4. Identifies rare accounts with low authentication activity (Event ID 4624).

  5. Combines failed logon events with rare account information to calculate a SuspiciousScore based on multiple factors.

  6. Displays the results in a table format, sorted by SuspiciousScore and FailedLogonCount.

Splunk Detection Queries

Basic Splunk Query for Password Spraying Detection

index=windows (EventCode=4625 OR EventCode=4624)
| eval LogonType = case(EventCode=4625, "Failed Logon", EventCode=4624, "Successful Logon")
| stats count AS TotalAttempts, 
        count(eval(EventCode=4625)) AS FailedAttempts, 
        count(eval(EventCode=4624)) AS SuccessfulAttempts, 
        values(AccountName) AS TargetAccounts, 
        dc(AccountName) AS UniqueAccounts, 
        values(IpAddress) AS SourceIPs, 
        dc(IpAddress) AS UniqueSourceIPs 
    BY LogonType, IpAddress
| where FailedAttempts > 10 AND UniqueAccounts > 5  // Threshold: Failed attempts across multiple accounts
| eval SuspiciousScore = case(
    FailedAttempts > 20 AND UniqueAccounts > 10, "High",
    FailedAttempts > 10 AND UniqueAccounts > 5, "Medium",
    true(), "Low"
)
| where SuspiciousScore IN ("High", "Medium")
| table IpAddress, TotalAttempts, FailedAttempts, SuccessfulAttempts, UniqueAccounts, SourceIPs, SuspiciousScore
| sort - SuspiciousScore, -FailedAttempts

Query Breakdown

  1. Filters Relevant Events:

    • EventCode=4625: Failed logons.

    • EventCode=4624: Successful logons.

  2. Evaluates Logon Type:

    • Label events as "Failed Logon" or "Successful Logon" for clarity.

  3. Aggregates Data:

    • FailedAttempts: Count of failed logons per source IP.

    • SuccessfulAttempts: Count of successful logons per source IP.

    • UniqueAccounts: Number of distinct accounts targeted by the source IP.

    • SourceIPs: IP addresses involved in the activity.

  4. Detects Suspicious Behavior:

    • Flags source IPs with:

      • More than 10 failed attempts across 5 or more accounts.

      • Assigns a "High" or "Medium" SuspiciousScore for prioritised analysis.

  5. Excludes Low-Risk Activity:

    • Focuses only on high or medium risk patterns by filtering out low scores.

Advanced Query with Temporal Analysis

index=windows (EventCode=4625 OR EventCode=4624)
| eval LogonType = case(EventCode=4625, "Failed Logon", EventCode=4624, "Successful Logon")
| bin _time span=15m  // Group events into 15-minute intervals
| stats count AS TotalAttempts, 
        count(eval(EventCode=4625)) AS FailedAttempts, 
        count(eval(EventCode=4624)) AS SuccessfulAttempts, 
        values(AccountName) AS TargetAccounts, 
        dc(AccountName) AS UniqueAccounts, 
        values(IpAddress) AS SourceIPs, 
        dc(IpAddress) AS UniqueSourceIPs 
    BY _time, IpAddress
| where FailedAttempts > 10 AND UniqueAccounts > 5
| eval SuspiciousScore = case(
    FailedAttempts > 20 AND UniqueAccounts > 10, "High",
    FailedAttempts > 10 AND UniqueAccounts > 5, "Medium",
    true(), "Low"
)
| where SuspiciousScore IN ("High", "Medium")
| table _time, IpAddress, TotalAttempts, FailedAttempts, SuccessfulAttempts, UniqueAccounts, SourceIPs, SuspiciousScore
| sort - _time, -SuspiciousScore, -FailedAttempts

Query Enhancements

  • Whitelist Known Sources or Accounts:

    | search NOT [ | inputlookup whitelist_ips.csv ]
  • Threshold Adjustments:

    • Tune FailedAttempts > 10 and UniqueAccounts > 5 based on your environment’s normal behaviour.

  • Include Geolocation:

    • Add geographic context to identify activity from unexpected regions:

      | iplocation IpAddress
      | table IpAddress, Country, Region, City, TotalAttempts, FailedAttempts, SuccessfulAttempts

Recommendations

  1. Create Alerts:

    • Trigger alerts for SuspiciousScore = High to notify SOC analysts in realtime.

  2. Correlate with Threat Intelligence:

    • Cross-reference SourceIPs with threat feeds to identify known malicious actors.

  3. Build Dashboards:

    • Visualize password spraying activity trends and affected accounts in a Splunk dashboard.

Reference

PreviousAuthentication Server Response (AS-REP) RoastingNextMachineAccountQuota Compromise

Last updated 4 months ago

Microsoft Identity and Access documentation
Detecting and mitigating Active Directory compromises
Best Practices for Securing Active Directory
Securing Domain Controllers Against Attack
Top 25 Active Directory Security Best Practices
Active Directory Security Best Practices