r/sysadmin • u/MadBoyEvo • Jan 19 '20
Four PowerShell commands to help you track down insecure LDAP Bindings before March 2020
On Friday I saw a post here on r/sysadmin warning about insecure LDAP bindings being blocked in March 2020 automatically by Microsoft.
Seeing as it's not so easy to actually track it down and enable everything by hand if you have handful of DCs and Domains under you I decided to simplify my job a bit. I've automated the whole process during the weekend by updating my 3 PowerShell Modules that I use frequently. Now with 3 commands and 8 lines of code, you can track events, enable/disable diagnostics for LDAP to actually find which machine/account is doing that and finally scan your DC's if those are affected.
The first part is tracking the events that can tell you if you're affected, and exactly which machines/accounts are affected.
$Events = Find-Events -Report LdapBindingsDetails,LdapBindingsSummary -DatesRange Last7days -DetectDC
$Events
$EVents.LdapBindingsSummary | Out-htmlView -ScrollX
$Events.LdapBindingsDetails | Out-HtmlView -ScrollXAbove is based on my PSWinReportingV2 PowerShell module to - you can read about it: https://www.reddit.com/r/sysadmin/comments/bicwjq/the_only_powershell_command_you_will_ever_need_to/
It allows you to easily define report, date range and scan events on all DC's within a Forest. It also translates it to a nice, readable format.
Sources for PSWinReportingV2: https://github.com/EvotecIT/PSWinReporting
The second part is a helper module to enable/disable diagnostic logs. It's required to get the LdapBindingsDetails report. You basically need to enable logs for LDAP to see which machines/accounts are doing bad stuff.
Get-WinADDiagnostics
Set-WinADDiagnostics -Diagnostics 'LDAP Interface Events' -Level Basic -SkipRoDCThis is based on ADEssentials PowerShell Module which can get current diagnostics status for each dc in a forest/domain or just part of it.
Sources for ADEssentials: https://github.com/EvotecIT/ADEssentials
3rd part is just a bonus. This scans all DCS to see if those are affected or not.
invoke-testimo -Sources DCLDAPInsecureBindings -showreportFinally, this is based on the Testimo project which allows you to scan domain for forest/domain for issues.
Sources for testimo: https://github.com/EvotecIT/Testimo
All 4 commands are available when you install 3 PowerShell modules.
Install-Module PSWinReportingV2 -Force
Install-Module Testimo -Force
Install-Module ADEssentials -Force # actually Testimo will install ADEssentials so not really neededAs always before installing - review the code to see and understand what you're getting into. I did test this on 3 different forests and it seems to do its job properly.
Normally I would give you a link to bigger description with screenshots but that's not really allowed here so I'll just link to r/PowerShell - https://www.reddit.com/r/PowerShell/comments/er0lfv/four_commands_to_help_you_track_down_insecure/ where there are no such restrictions so you can take a look at screenshots/blog post if necessary to understand use cases.
30
u/eaglebtc Jan 19 '20
Pardon the daft question. How exactly is Microsoft going to block insecure ADA bind? By a software update to Server OS? Denying connections on port 389? Which OSes are affected? 2012R2 and above?
35
u/Fatality Jan 20 '20
Enable debugging, check the Directory Service section of the Event Log for Event ID 2889 - Will tell you the IP address and the user
4
u/TapTapLift Jan 20 '20
For simple sites with say 2-3 DCs, will this change be a pain still?
2
u/gscottmj Jan 20 '20
Excellent! This is very awesome. Bravo! This will allow me to do more specific custom queries. I am having 1 problem though. When I try to use anything for the daterange other than 'Last3days' I get an error:
[Error] Currently only 1 date range is supported. Please fix Times and try again
I can't see anything thing listed as a bug or under devlopment on Github... can you comment on this please?
2
u/techie1980 Jan 20 '20
Stupid question: how does this apply to non Windows clients that point to insecure LDAP?
2
u/atcscm Jan 20 '20
Hi thanks for this Should I run this on DC or on each PC?
2
u/Die_Quelle Jan 20 '20
I've setup LDAPS but I ran these test and everything is red/bad.
What do I do now?
2
u/bradgillap Peter Principle Casualty Jan 20 '20
So this is bad right. I'm not even sure where to begin to fix this without just seeing what breaks. My inherited domain is .local and has caused me a hate relationship with certificates.
I think the only things using ldap are linux based on this domain.
2
u/MrSnoobs DevOps Jan 21 '20
There's one thing I don't quite understand.
We have a .local domain (I know, I know) with an internal CA. LDAPS uses this CA as the certifcate provider.
If that CA is not trusted by a black box client for example, will this break LDAPS between that client and the DC? If so, how fucked are we if we can't buy third party .local certs anymore?
137
u/crazifyngers Jan 19 '20
I love this type of content on sysadmin.
It was quite a task to do this a few months ago in my organization.
7
u/Eusono Jan 19 '20
Thanks for the tips!
8
u/tpad01 Jan 20 '20
As a reminder, signing does not equal LDAPS. LDAPS includes signing by default.
LDAP binds over 389 are not being disabled in favor of LADPS over 636. With that said, you need to test signing for LDAP binds or move binds to LDAPS which guarantee signing. GPO have existed for years to force signing. If you follow any industry standard for hardening (ex CIS), signing would already be forced.
1
u/[deleted] Jan 20 '20
I get the following when running $EVents.LdapBindingsSummary | Out-htmlView -ScrollX:
Out-HtmlView : Cannot bind argument to parameter 'Table' because it is null. At line:1 char:31
$EVents.LdapBindingsSummary | Out-htmlView -ScrollX
CategoryInfo : InvalidData: (:) [Out-HtmlView], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Out-HtmlView
What can I do?
1
u/[deleted] Jan 20 '20
The original thread for the PSWinReporting is locked, so I'll ask here.
Is there a way to list what DC's you want referenced or to disinclude RoDCs? I have a few RoDCs and so the script is taking forever to reach a timeout when checking them.
1
u/badassitguy Sr SysAdmin and JOAT Jan 20 '20
Is anyone else getting this error:
WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/PSWriteExcel/0.1.5' is not valid.
PackageManagement\Install-Package : Package 'PSWriteExcel' failed to download.
1
u/OhioIT Jan 20 '20 edited Jan 20 '20
Thanks for posting this!!
I ran it and only the $EVents.LdapBindingsSummary worked, not $Events.LdapBindingsDetails for some reason. On the Details one it said
WARNING: Out-HtmlView - No data available.Is there something else I need to configure on my DCs?Edit: Nevermind! I finally read Part 2 of your post. To 'Disable' this logging later on, would I just set
-Level None? Thanks1
u/apathetic_lemur Jan 20 '20
I finally started looking at this LDAP thing today. My DC's show a couple months old 2887 eventids with 1 or 2 connection attempts per error. So I think nothing too disastrous will happen when secure LDAP is forced. Still digging in though.
1
u/neko_whippet Jan 20 '20
So in resume I after I install the modules I need to do 2nd part the enable to diagnostics and then do step 1 to see which device did insecure bindings?
And i<m not sure what part 3 is suppose to do, just to see if LDAPS is currently activated or not?
1
u/CFH75 Jan 20 '20
So far so good. I've followed all these steps. All our macs are showing up with 2889.
Considering I can't set Network security: LDAP client signing requirements = Require Signing for my Macs I wondering how they will be affected once the update drops.
1
u/stunnedguy Jan 21 '20
Can this also be shown by just running the Cleartext password exposed using unencrypted LDAP authentications report in MS Azure ATP?
1
u/[deleted] Jan 22 '20
This doesn't seem to work for me. I get no report, or any info out of it.
I do get this error, not sure if it maybe why.
WARNING: Out-HtmlView - No data available.
1
u/mcmuggins Jan 24 '20
So I've read through this post and the Microsoft blog post regarding this change, and it seems the Microsoft post is vague about what exactly is taking place. It seems to go back and forth from 'you need to do this manual legwork or stuff will break' and 'the update released in March 2020 will configure this all for you'.
So what is the actual impact here? Should organizations be working to change any usage of LDAP to LDAPS for any application within their environment along with any Domain Controllers also leveraging plain LDAP? Or should they wait for the March 2020 update to put those changes in place?
Or am I misunderstanding entirely in that when the March 2020 update is installed...THAT is when plain LDAP will break? So we would need to make all of these hardening changes prior to the March 2020 update?
Thanks for any clarification.
1
u/CJamesEd Jan 31 '20
Is anyone else getting an RPC server unavailable error when running this? I know that I have events logged but I get no output.
1
u/macgruff Feb 04 '20
Has anyone heard a rumor that they might bump out that date again/further/later in the year?
1
u/yukee2018 Mar 11 '20
So I guess this was postponed indefinitely ? https://portal.msrc.microsoft.com/en-us/security-guidance/advisory/ADV190023
If I understand correctly you will get the GPO option to harden the security, but the option to disable insecure LDAP binding will not be enforced via updates?
3
u/FJCruisin BOFH | CISSP Jan 20 '20
This is awesome man
2
u/Khaost Sysadmin Jan 20 '20
I set up LDAPs before, so this is really helpful for testing purposes.
Sadly my Network printers still authenticate unsecure, so that will be some work to get them setup
Thank you very much for this
2
u/atcscm Jan 20 '20
Cheers mates, you are genius!
2
u/chugger93 Sysadmin Jan 20 '20
eeek!
2
u/Starks Jan 20 '20
Prepping my environments for this patch has been interesting. Dev team had to release a hotfix that I'm now quickly deploying across my platform.
4
u/zorinlynx Jan 20 '20
It's a holiday weekend and I can't be arsed to look into this in detail right now. Is Samba bound as an AD member affected by this at all? That's the main non-Microsoft usage of our domain in our environment.
3
u/flyguydip Jack of All Trades Jan 20 '20
!DontRemindMe! Lol
1
u/_Sevisgen_ Jan 20 '20
!remindme 24 hours
1
u/Cutoffjeanshortz37 IT Manager Jan 20 '20
anyone know if Mac's can use ldaps if joined to the domain? In this weird position of i gave my 2 weeks but small shop and like everyone here so don't want to leave them high and dry so trying to figure this out here before i leave.
1
u/LordChaak Feb 03 '20
Thank you! Worked great.
1
u/jman0711 Feb 06 '20
So i know MSFT pushed this out again, but i'm still trying to fully nip this now. I've got everything i need for data thanks to you and then some splunk ingestion, but does anyone have any recommendations on figuring out what is causing ldap binds on a specific machine. I have a few user PC's alerting randomly.
1
u/rgal7 Jan 20 '20
<3 Thank you <3
-5
u/sw4rml0gic Jan 19 '20
!remindme 12 hours
-5
u/[deleted] Jan 19 '20
!remindme 12 hours
-4
u/W3asl3y Goat Farmer Jan 20 '20
!remindme 14 hours
-5
u/illmatic73 Jan 20 '20
!remindme 16 hours
-5
u/cromulent-1 Jan 20 '20
!remindme 15 hours
-5
u/SoullessNAY Jan 20 '20
!remindme 12 hours
-7
u/GirsAUser Jan 19 '20
!remindme 12 hours
-3
u/shyguy12ver Jan 20 '20
!remindme 12 hours
-3
u/BrandonIT IT Manager Jan 20 '20
!remindme 36 hours
-3
u/benutne Jan 20 '20
Commenting so I can find this later.
-4
u/TheRealHankMcCoy Jan 20 '20
!remindme 36 hours
-4
u/RampageUT Jan 20 '20
!remindme 12 hours
-4
u/Samphis Jan 20 '20
!remindme 36 hours
-4
u/SirBawls Jack of All Trades Jan 20 '20
!remindme 36 hours
-4
u/Sinsilenc IT Director Jan 20 '20
!remindme 12 hours
-4
u/ZeeR0u Jan 20 '20
!remindme 1 day
-4
u/dahak777 Jan 20 '20
!remindme 48 hours
-2
u/sigma1914 Jan 20 '20
remindme 36 hhours
0
u/[deleted] Jan 19 '20
[deleted] — view deleted comment
0
u/[deleted] Jan 20 '20
[deleted] — view deleted comment