SlideShare a Scribd company logo
Portcullis Computer Security
DETECTING WINDOWS HORIZONTAL PASSWORD GUESSING ATTACKS IN NEAR REAL-TIME
Detecting Windows horizontal password
guessing attacks in near real-time
When attempting to gain a foothold into a Windows Domain, an attacker will
often attempt one or two likely passwords against every user in the Active
Directory, a so-called horizontal password guessing attack. A small number of
failed logons per user will usually not trigger a user account lockout policy and
can be very effective. This post will provide an example solution to detecting such
attacks in near real time, using only native Windows tools.
Even with password complexity requirements and custom filters there is no built-in
way to stop users choosing poor passwords. It is scary how may user accounts are
identified with the password Password1 for example. We need a method of
detecting password guessing attacks, preferably before someone takes control of
the Domain.
By following these instructions you can get hourly (can be trivially customised)
notifications of such horizontal password guessing attacks.
Note: The following method has been developed using Windows 2012.
Configuring the Domain Controller
First we need to configure the Active Directory
Domain Controller to log failed logon attempts:
From the Server Manager tool click Tools and
select Group Policy Management, as shown in
the screenshot :
Expand the nodes in the left hand pane so you
can see the policy Default Domain Controllers
Policy for Domain Controllers within the Domain.
Right-click it and select Edit, as shown :
In the Group Policy Management Editor expand
β€œComputer Configuration > Policies > Windows
Settings > Security Settings > Local Policies” and then
click β€œAudit Policy”
Right-click β€œAudit account logon events” and select
β€œProperties”, as shown below:
Ensure that both β€œDefine these
policy settings” and β€œFailure” are
enabled then click β€œOK”. The
following screenshot shows both
β€œSuccess” and β€œFailure” are
selected:
When you click β€œOK” the
updated policy settings will be
visible. Next we force the server
to recognise the updated policy
settings by running the
command gpupdate /force by
pressing Windows key + r, as
shown:
Testing
To test that the policy has taken affect
we make a failed logon attempts (from
another system). Note the IP address of
the machine used in the screenshot:
By viewing the Event Viewer on the
Domain Controller we can see in the
following screenshot that failed logon
attempts now generate Audit
Failure events (in this case EventID 4771)
and that the IPAddress shown matches
the host from which the logon attempt
was made:
Parsing the event logs
PowerShell has a cmdlet called get-WinEvent that allows us to filter out all events with a specific
EventId within a given timespan.
Note: The backtick at the end of the first line is PowerShell’s multiline indicator and is required.
By running the above PowerShell command we get all events from the Security log with an ID
value of 4771 from the past hour. If we wanted to change the timespan we could replace
AddHours(-1) with AddMinutes(-30) for the last 30 minutes, or AddDays(-1) for the last 24 hours.
Those events will be accessed via the $events variable.
If we want to check additional EventIds we simply add extra calls to get-WinEvent like so:
Note the use of += to append the extra events.
Parsing the event logs continued…
We specify the parameter -EA silentlycontinue to avoid error messages if there are no events
returned.
Of course some of those events might well be innocent users who mis-typed their password.
Someone performing a horizontal password guessing attack against Active Directory users
will be running that attack from a single host on the network (E.g. an IP address). Or several
hosts might be being used, each testing a sub-set of user accounts and/or passwords. We
want to identify any IP address that failed to logon more than a specified number of times
within our timespan.
In order to obtain information from the event entry message we need to convert the event
to XML so that we can parse it. We will make a note of each IP address that generated the
failed logon event by looping through each event (remember we filtered only those events
we are interested in) and increment a counter specific for each unique IP address we
encounter.
Once we have counted each failed logon attempt originating from all the source IPs
referenced in the log event we simply report on any IP where the counted value exceeds
our specified threshold value by sending an email alert.
The Complete Script
The following PowerShell script implements the complete process:
The PowerShell script will
display information to the
PowerShell Console (if
visible) and send an email,
in this case to
ITSecurity@mydomain.com
from
alerts@mydomain.com,
using the Send-
MailMessage cmdlet.
Testing the Script
We can test the script with the following command :
Note: You may need to first enable external scripting within PowerShell:
For a more secure configuration of PowerShell you can specify Signed instead
of Unrestricted. More details on this can be found on Microsoft’s web site.
Running the script automatically
Now we need a method of running the script on the Domain Controller
each hour. We can use the task scheduler (as an Administrator):
Once we create the scheduled task we need to start it:
Note: For extra security you should create a service account with the minimum privileges required to access the
event log and send Emails, and specify that account in the /ru parameter, in place of NT
AUTHORITYLOCALSERVICE.
And that’s it. You may want to tweak the time period settings and the $mail_domainSr value, and the email settings
will need to be updated.
This solution can also be used to cover password attacks on local user accounts through the use of Centralised
Event Logging. Also see the National Security Agency’s (NSA)detailed paper on configuring centralised event
logging.
Download available
https://www.nsa.gov/ia/_files/app/Spotting_the_Adversary_with_Windows_Eve
nt_Log_Monitoring.pdf
https://labs.portcullis.co.uk/blog/detecting-windows-horizontal-password-
guessing-attacks-in-near-real-time/
Request to be added to
the Portcullis Labs
Newsletter
SIGN UP HERE

More Related Content

PPTX
Detecting Windows horizontal password guessing attacks in near real-time
PDF
Pandora FMS: End to End Exchange Plugin
PPT
Alcool 2011
PPTX
Venom vulnerability
PPTX
Third street aleworks
PPTX
MS SQL server audit
DOCX
AKSHAY BOGS CV
PPTX
Permanent building
Detecting Windows horizontal password guessing attacks in near real-time
Pandora FMS: End to End Exchange Plugin
Alcool 2011
Venom vulnerability
Third street aleworks
MS SQL server audit
AKSHAY BOGS CV
Permanent building

Viewers also liked (7)

PPTX
Permanent-building
PPTX
5th grade finance (career lesson)
PDF
Finance
PPTX
Transfer pricing
PDF
How to set ASL (Access, Stair, Ladder) standard for pdms 12 in Module Design ...
PDF
Steps to prepare MTO (Material Take Off) in PDMS
Permanent-building
5th grade finance (career lesson)
Finance
Transfer pricing
How to set ASL (Access, Stair, Ladder) standard for pdms 12 in Module Design ...
Steps to prepare MTO (Material Take Off) in PDMS
Ad

Similar to Detecting windows horizontal password blog (20)

PDF
Merged document
PPT
sfdx continuous Integration with Jenkins on aws (Part I)
PDF
Training Alcatel-Lucent WDM PSS 183x
PDF
Windows Registry Auditing Cheat Sheet ver Oct 2016 - MalwareArchaeology
PPTX
Magento security best practices magento's approach to pci compliance
DOCX
ANET SureLog SIEM IntelligentResponse
PPT
GigaSpaces CCF Quick Tour - 2.3.6
PDF
Windows logging cheat sheet
PDF
Windows Logging Cheat Sheet ver Jan 2016 - MalwareArchaeology
PPTX
Windows Incident Response CheatSheet.pptx
PPT
GigaSpaces Cloud Computing Framework 4 XAP - Quick Tour - v2
PDF
Tips to Remediate your Vulnerability Management Program
PPT
Remote Login
PPT
Intrusion Discovery on Windows
Β 
PPTX
Windows Event Analysis - Correlation for Investigation
PDF
Windows splunk logging cheat sheet Oct 2016 - MalwareArchaeology.com
DOC
State management in asp
PPTX
Windows 7 Application Compatibility
Β 
PPTX
Monitoring of computers
PDF
Micro services from scratch - Part 1
Merged document
sfdx continuous Integration with Jenkins on aws (Part I)
Training Alcatel-Lucent WDM PSS 183x
Windows Registry Auditing Cheat Sheet ver Oct 2016 - MalwareArchaeology
Magento security best practices magento's approach to pci compliance
ANET SureLog SIEM IntelligentResponse
GigaSpaces CCF Quick Tour - 2.3.6
Windows logging cheat sheet
Windows Logging Cheat Sheet ver Jan 2016 - MalwareArchaeology
Windows Incident Response CheatSheet.pptx
GigaSpaces Cloud Computing Framework 4 XAP - Quick Tour - v2
Tips to Remediate your Vulnerability Management Program
Remote Login
Intrusion Discovery on Windows
Β 
Windows Event Analysis - Correlation for Investigation
Windows splunk logging cheat sheet Oct 2016 - MalwareArchaeology.com
State management in asp
Windows 7 Application Compatibility
Β 
Monitoring of computers
Micro services from scratch - Part 1
Ad

Recently uploaded (20)

PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PDF
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Introduction to cybersecurity and digital nettiquette
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
Funds Management Learning Material for Beg
PPT
Ethics in Information System - Management Information System
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
DOCX
Unit-3 cyber security network security of internet system
PPTX
t_and_OpenAI_Combined_two_pressentations
PPTX
E -tech empowerment technologies PowerPoint
PPTX
Mathew Digital SEO Checklist Guidlines 2025
PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
The Ikigai Template _ Recalibrate How You Spend Your Time.pdf
PPTX
SAP Ariba Sourcing PPT for learning material
PPTX
Database Information System - Management Information System
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PPTX
artificial intelligence overview of it and more
PDF
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
PDF
Introduction to the IoT system, how the IoT system works
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Introduction to cybersecurity and digital nettiquette
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Funds Management Learning Material for Beg
Ethics in Information System - Management Information System
Unit-1 introduction to cyber security discuss about how to secure a system
Unit-3 cyber security network security of internet system
t_and_OpenAI_Combined_two_pressentations
E -tech empowerment technologies PowerPoint
Mathew Digital SEO Checklist Guidlines 2025
Sims 4 Historia para lo sims 4 para jugar
The Ikigai Template _ Recalibrate How You Spend Your Time.pdf
SAP Ariba Sourcing PPT for learning material
Database Information System - Management Information System
The New Creative Director: How AI Tools for Social Media Content Creation Are...
artificial intelligence overview of it and more
Smart Home Technology for Health Monitoring (www.kiu.ac.ug)
Introduction to the IoT system, how the IoT system works

Detecting windows horizontal password blog

  • 1. Portcullis Computer Security DETECTING WINDOWS HORIZONTAL PASSWORD GUESSING ATTACKS IN NEAR REAL-TIME
  • 2. Detecting Windows horizontal password guessing attacks in near real-time When attempting to gain a foothold into a Windows Domain, an attacker will often attempt one or two likely passwords against every user in the Active Directory, a so-called horizontal password guessing attack. A small number of failed logons per user will usually not trigger a user account lockout policy and can be very effective. This post will provide an example solution to detecting such attacks in near real time, using only native Windows tools. Even with password complexity requirements and custom filters there is no built-in way to stop users choosing poor passwords. It is scary how may user accounts are identified with the password Password1 for example. We need a method of detecting password guessing attacks, preferably before someone takes control of the Domain. By following these instructions you can get hourly (can be trivially customised) notifications of such horizontal password guessing attacks. Note: The following method has been developed using Windows 2012.
  • 3. Configuring the Domain Controller First we need to configure the Active Directory Domain Controller to log failed logon attempts: From the Server Manager tool click Tools and select Group Policy Management, as shown in the screenshot :
  • 4. Expand the nodes in the left hand pane so you can see the policy Default Domain Controllers Policy for Domain Controllers within the Domain. Right-click it and select Edit, as shown : In the Group Policy Management Editor expand β€œComputer Configuration > Policies > Windows Settings > Security Settings > Local Policies” and then click β€œAudit Policy” Right-click β€œAudit account logon events” and select β€œProperties”, as shown below:
  • 5. Ensure that both β€œDefine these policy settings” and β€œFailure” are enabled then click β€œOK”. The following screenshot shows both β€œSuccess” and β€œFailure” are selected:
  • 6. When you click β€œOK” the updated policy settings will be visible. Next we force the server to recognise the updated policy settings by running the command gpupdate /force by pressing Windows key + r, as shown:
  • 7. Testing To test that the policy has taken affect we make a failed logon attempts (from another system). Note the IP address of the machine used in the screenshot:
  • 8. By viewing the Event Viewer on the Domain Controller we can see in the following screenshot that failed logon attempts now generate Audit Failure events (in this case EventID 4771) and that the IPAddress shown matches the host from which the logon attempt was made:
  • 9. Parsing the event logs PowerShell has a cmdlet called get-WinEvent that allows us to filter out all events with a specific EventId within a given timespan. Note: The backtick at the end of the first line is PowerShell’s multiline indicator and is required. By running the above PowerShell command we get all events from the Security log with an ID value of 4771 from the past hour. If we wanted to change the timespan we could replace AddHours(-1) with AddMinutes(-30) for the last 30 minutes, or AddDays(-1) for the last 24 hours. Those events will be accessed via the $events variable. If we want to check additional EventIds we simply add extra calls to get-WinEvent like so: Note the use of += to append the extra events.
  • 10. Parsing the event logs continued… We specify the parameter -EA silentlycontinue to avoid error messages if there are no events returned. Of course some of those events might well be innocent users who mis-typed their password. Someone performing a horizontal password guessing attack against Active Directory users will be running that attack from a single host on the network (E.g. an IP address). Or several hosts might be being used, each testing a sub-set of user accounts and/or passwords. We want to identify any IP address that failed to logon more than a specified number of times within our timespan. In order to obtain information from the event entry message we need to convert the event to XML so that we can parse it. We will make a note of each IP address that generated the failed logon event by looping through each event (remember we filtered only those events we are interested in) and increment a counter specific for each unique IP address we encounter. Once we have counted each failed logon attempt originating from all the source IPs referenced in the log event we simply report on any IP where the counted value exceeds our specified threshold value by sending an email alert.
  • 11. The Complete Script The following PowerShell script implements the complete process: The PowerShell script will display information to the PowerShell Console (if visible) and send an email, in this case to ITSecurity@mydomain.com from alerts@mydomain.com, using the Send- MailMessage cmdlet.
  • 12. Testing the Script We can test the script with the following command : Note: You may need to first enable external scripting within PowerShell: For a more secure configuration of PowerShell you can specify Signed instead of Unrestricted. More details on this can be found on Microsoft’s web site.
  • 13. Running the script automatically Now we need a method of running the script on the Domain Controller each hour. We can use the task scheduler (as an Administrator): Once we create the scheduled task we need to start it: Note: For extra security you should create a service account with the minimum privileges required to access the event log and send Emails, and specify that account in the /ru parameter, in place of NT AUTHORITYLOCALSERVICE. And that’s it. You may want to tweak the time period settings and the $mail_domainSr value, and the email settings will need to be updated. This solution can also be used to cover password attacks on local user accounts through the use of Centralised Event Logging. Also see the National Security Agency’s (NSA)detailed paper on configuring centralised event logging.
  • 15. Request to be added to the Portcullis Labs Newsletter SIGN UP HERE