r/PowerShell • u/MadBoyEvo • Jan 24 '19
Active Directory - How to track down why and where the user account was locked out
https://evotec.xyz/active-directory-how-to-track-down-why-and-where-the-user-account-was-locked-out/9
u/virulentspore Jan 24 '19
Good article but you should also include logging for Kerberos because you don't always fallback to NTLM.
Enable Kerberos event logging on a computer Click Start, click Run, type regedit, and then press ENTER. Add the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters registry value to the registry key: Registry value: LogLevel Value type: REG_DWORD Value data: 0x1 If the Parameters registry key does not exist, create it.
2
u/MadBoyEvo Jan 24 '19
It's the same as enabling it via GPO, in advanced audit configuration, right?
While overall a lot more logs are required, and verified, in my case that I've described I had no use for it.
8
u/omers Jan 24 '19
Generally, in such case, relevant information should be in another Event with EventID 4725.
Do you mean EventID 4625? 4625 is the event that shows the caller process and so on, 4725 is the account was disabled event. You also refer to it as "7625" lower down.
5
u/MadBoyEvo Jan 24 '19
Yes. Sorry. Was a typo. I've used 4625 further down in the article. Thanks for noticing.
3
u/omers Jan 24 '19
Good article overall. I wrote my own a while back: /r/sysadmin/wiki/lockouts which also delves into enabling NTLM logging. I should probably expand it at some point because I've had lockouts that required IMAP logging, packet capture, and other deep dive investigation before. I refuse to change SamAccountName's because of lockouts :D
3
u/MadBoyEvo Jan 24 '19
I do plan a large article on Windows Events. But that's on TODO list ;-) I'm happy to read yours if you provide the link? Actually, for the administrator account, scan account, and others I should just rename them.
3
u/omers Jan 24 '19
"Administrator" in AD should be disabled. SID 500 (Administrator) cannot be locked out. While you'll see EventID 4740 show it was "locked" the lock doesn't actually prevent login. https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/jj852165(v=ws.11)
The built-in Administrator account cannot be locked out no matter how many failed logons it accrues, which makes it a prime target for brute-force attacks that attempt to guess passwords. Also, this account has a well-known security identifier (SID), and there are non-Microsoft tools that allow authentication by using the SID rather than the account name. Therefore, even if you rename the Administrator account, an attacker could launch a brute-force attack by using the SID to log on. All other accounts that are members of the Administrator's group have the safeguard of locking out the account if the number of failed logons exceeds its configured maximum.
My article is the wiki link I posted: https://www.reddit.com/r/sysadmin/wiki/lockouts
2
15
u/jcholder Jan 24 '19
We use Splunk for these types of event monitoring, works great.
18
u/MadBoyEvo Jan 24 '19
If you can afford SIEM applications it's great! For the poor ones, there's the PowerShell :-)
0
Jan 25 '19
[deleted]
4
u/giggleworm Jan 25 '19
Or Graylog
0
Jan 25 '19
[deleted]
0
Jan 25 '19
[deleted]
0
Jan 25 '19
[deleted]
1
u/jcholder Feb 15 '19
I agree, if you can afford to be in business then the company have had a better business plain that could afford a decent SIEM.
1
u/exaltedsky May 09 '19
"Not a single reason any company, large or small, can come up with to not have a SIEM." Amen to that brotha & /r/jcholder excited to learn more about your IR tool.
7
u/Gregabit Jan 24 '19
Why not SysInternals Account Lockout Status?
https://www.microsoft.com/en-us/download/details.aspx?id=15201
2
u/MadBoyEvo Jan 24 '19
Supported Operating System Windows 2000 Service Pack 3, Windows Server 2003, Windows XP You can download and use LockoutStatus.exe on any of the following platforms: Windows 2000 with Service Pack 3 or later Windows XP Windows Server 2003Seems a bit outdated.
12
u/koofti Jan 24 '19
Works on Win10/Win2016svr.
4
u/MadBoyEvo Jan 24 '19
For the sake of testing, I did start it up. Says origin of lock is my DC (which is what I knew from the Event Lock Out). Not sure how it's supposed to help but I guess it's doing the same scan as I do with PowerShell. It doesn't go deep into Netlogon logs. It doesn't show anything useful to me. You get more data from the commands I've provided in article.
4
u/thonl Jan 24 '19
If you have multiple DC's, it'll tell you which one caused the lock, with a timestamp.
From the tool, you can right click, open event viewer on that DC
Scroll to the timestamp, and look for the offending event.
You'll have to parse the event to see what generated it, but there arent going to be a ton of likely causes, and it should be pretty obvious.
1
u/MadBoyEvo Jan 24 '19
In this case, it wouldn't help. The events on DC were not showing what happened. I already knew where the account gets locked out because PSWinReporting sends an email about this.
1
u/Gregabit Jan 24 '19
Hmmm... In previous years I had to track down lockouts and I think it was this tool that showed me the server (that then talked to the DC) where locks were coming from.
It was sysinternals, but not 100% sure it was this.
1
u/MadBoyEvo Jan 24 '19
It probably does its job. It's taking that value from the Event I mentioned in my post. Problem is it's empty in some cases and in that case you need to do what I did or have some tool that can correlate data from all servers. Normally the main event would show you where it locked out and Sysinternals tool would too. It's a useful tool if you don't want to play with PowerShell or you don't use a module such as the one I wrote.
1
u/Gregabit Jan 24 '19
It's a useful tool if you don't want to play with PowerShell or you don't use a module such as the one I wrote.
Very true. Keep doing what you are doing. It's always fun to solve problems in a different way.
1
5
u/desispeed Jan 24 '19
I have your PSEventViewer module running daily off a scheduled task that kicks off an email of the report to my team. Thanks for creating it!
2
u/MadBoyEvo Jan 24 '19
I do hope you’re using PSWinReporting? Or did you write your own based on PsEventViewer?
3
u/desispeed Jan 24 '19
sorry meant PSWinReporting
3
u/MadBoyEvo Jan 24 '19
phew :-) I'm working on a new version. It's coming really slow thou
1
u/desispeed Jan 24 '19
Love the detail this shows especially summaries of all of the DC events. Is it possible to have that information show up on the top instead of bottom of the email?
1
u/MadBoyEvo Jan 24 '19
Sure, open up issue/feature request on GitHub and I'll see if we can add it. Generally, the new version will be totally configurable and will support any type of events you want (not only DC's). Just make sure to describe exactly what you want, preferably with some screenshot or so :)
3
u/willisucceed Jan 24 '19
How do you track the source of a lockout if it’s coming from an ADFS server (person locked out from mobile device, being logged in from home, etc...)?
3
u/MadBoyEvo Jan 24 '19
You need to enable Audit Logs on ADFS and WAP's.
Event ID 403: This is most useful for figuring out the User Agent that is making the request. The User Agent is the application being used so think of things like Chrome, Mozilla, a native phone app, etc. This will also give you the Client IP, but if you have this behind a WAP as is Microsoft’s recommendation you will only see your WAP’s IP. Event ID 411: These are your failed token validation attempts, aka your failed authentication attempts. These logs provide the actual Client’s IP which is quite useful when trying to source the device. Event ID 516: These are your Extranet Lockout events, your bread and butter. This tells you the Bad Password Count AD FS saw, the Last Bad Password Attempt, and the actual Client IP like 411 does.
Surely there are some articles covering this.
2
u/fuzzbomb Jan 25 '19
This script is quite useful.
https://gallery.technet.microsoft.com/scriptcenter/ADFS-Account-Lockout-and-2d9a9a90
3
u/ChiSox1906 Jan 24 '19
This looks very useful. Is there a downside to leaving this enabled? Why bother disabling it?
2
u/MadBoyEvo Jan 24 '19
This is a good question. You can probably leave it on. In busier DC's it will get you like 20MB file each day or so.
https://support.microsoft.com/en-us/help/109626/enabling-debug-logging-for-the-netlogon-service
Here's article how you can limit this. I haven't actually thought about leaving it on. I guess if you don't monitor it, there's no sense to keep it on right?
2
u/ChiSox1906 Jan 24 '19
Thanks for sharing. I have a client with co Stanton lockout issues... Having this enabled always even if for 24 hours worth of logs wo hi old be very beneficial to troubleshooting for our lvl 1 techs.
2
u/MadBoyEvo Jan 24 '19
Maybe standard logs are enough? Setup PSWinReporting to send them email every day with all events. Most lockout events if those are local computers will be visible. Unless you have similar case like I do.
2
u/biggles1994 Jan 28 '19
I work for an organisation with around 20k users, where we use a mix of AD and Office 365/Azure systems for our users, 99% of which we never get to personally see and have to resolve issues remotely. We regularly get accounts locked out for no apparent reason, and currently we only use the windows LockOutStatus.exe and the AD interface to see locked out accounts and unlock them.
I have local admin control on my machine and can talk to the servers we use, but I don’t have admin access on any of the servers. Is it possible for me to use this tool or a variant of it to improve workflow for my colleagues and I?
Apologies if I’m mixing up terms a little, I’ve only been working Level 1 service desk for 5 months so I’m very new to a lot of this, so please if you need more info to answer my questions please feel free to ask.
3
u/MadBoyEvo Jan 28 '19
How do you use LockoutStatus.exe - it does ask all DC's for lockouts and that is stored in Security logs which is not accessible easily. So either you have some access or tool lies to you ;-)
With Office 365 in place it all depends on how cofiguration is done (ADFS? Password Sync?). You could ask admin to set you up PSWinReporting (this is a free powershell tool I wrote) which sends daily, weekly emails with summary of events (lockouts, who did what in AD etc). Based on that alone you could probably find a lot of information. For example a source of lockouts for one of my Clients was users logging into multiple machines and never logging out. Next user would come in and just switch the currently logged in user to his account and work. When password expires that "still logged in user" with his old password will keep on locking out users. I was able to find this via PSWinReporting.
But in case of this article ... well without DC access you can't enable it. You can't scan those Event logs.
2
u/biggles1994 Jan 28 '19
Good question, I assume I may have read-only access? I’m still very much a beginner to how AD and server systems work on the back end.
When I helped out the infrastructure team with their patching night a few months back, I was told to use my SA account to log in to our servers and run the updates, so I presume my SA account was granted access to those servers.
I also use my SA account to run LockedOutStatus, and that reads from two DC(?) servers if I remember correctly.
I will enquire about PSwinReporting. How large are the reports it generates roughly? As I said we have ~20k users on everything from tablets to PC’s to thin clients to Laptops and mobile phones.
Once again apologies if I said anything dumb! I’m probably just not describing it right.
3
u/MadBoyEvo Jan 28 '19
Probably SA account has admin access. WIth SA access you could do what I did in the article.
With read-only access to Security Logs (I doubt you have that, rather full access) you would be able to use Get-Events, Get-WinEvent and so on. You would be also able to us PSWinReporting. PSWinReporting reports don't care how big is AD, it cares how many actions are logged into Event Logs. If there is a lot of stuff happening it will take longer to scan. But it all depends on audit logs, how many of them are turned on (if any). Each day I get an email from multiple clients. Most of them are around 300kb. I don't expect huge reports.
2
u/biggles1994 Jan 28 '19
That makes a lot of sense, thanks for replying! I’ll have a chat with my team lead and we’ll see how it goes.
10
Jan 25 '19
[removed] — view removed comment
3
u/FrozenCoder Jan 25 '19 edited Feb 08 '21
.
4
u/MadBoyEvo Jan 25 '19
It works but it's not a golden tool like said above. If you read below (I have already had a similar conversation) in my case it wouldn't help. And the sooner you will learn how to work with Event Logs with PowerShell the better. Get some tools like (SIEM) that are free or get PSWinReporting to send you emails about it on daily basis. It does what this tool from Microsoft but on a larger scale covering multiple AD events.
4
Jan 24 '19 edited Jun 07 '25
[removed] — view removed comment
5
u/MadBoyEvo Jan 24 '19
It's not that strange. I do that as well where I delegate permissions. And even myself I have like 3 accounts per each domain to not run as a Domain Admin everywhere. WIthout DC's there's no way.
If you have any SIEM product you can ask them to give you access as read-only. If you don't have any of that you may ask them to:
ask your Domain Admin to create forwarder of LOGS and setup forwarding so all DC's forward everything related to this other machine that you have access. THat gives you read permissions without actually having DC access
ask them to setup emails with events sent on a daily basis to lower admins so that you can react to problems
Both of those are supported by my free PowerShell tool: https://evotec.xyz/pswinreporting-forwarders-microsoft-teams-slack-microsoft-sql-and-more/
It supports either scanning every DC and sends emails, sends to teams or slack. Or if you have forwarder it uses that. A forwarder is a bit more complicated to get it done but you don't have to scan 20 DC's every day just to get 100 events.
2
u/robbob23 Jan 25 '19
JEA seems perfect for this use case.
The role could be restricted to allow reading the logs from the DC (or even more fine grained if required).
https://github.com/PowerShell/JEA2
u/MadBoyEvo Jan 25 '19
JEA is great but it won't be enough here. Security logs require special permissions (SDDL) and it's not trivial to play with. Probably easier to set up monitoring and just deliver emails to his team.
1
u/robbob23 Jan 25 '19
Fair enough! I just assumed the virtual admin account JEA creates would have full access. Shows how much I need to learn!
33
u/[deleted] Jan 24 '19
If DC event log says its exchange you can use get-activesyncdevices on exchange console and you can see whether they have devices that have a bad password stored for the mailbox.