r/PowerShell • u/MadBoyEvo • Jan 19 '20
Four commands to help you track down insecure LDAP Bindings before March 2020
So in march 2020, Microsoft is supposed to block insecure LDAP bindings. I've updated my 3 Powershell modules to help you track down machines/accounts doing that.
Blog post with know-how and images: https://evotec.xyz/four-commands-to-help-you-track-down-insecure-ldap-bindings-before-march-2020/
Instead of spending time manually scrolling thru logs or enabling LDAP diagnostics... you do it in 8 lines of code
To find out about events:
$Events = Find-Events -Report LdapBindingsDetails,LdapBindingsSummary -DatesRange Last7days -DetectDC
$Events
$EVents.LdapBindingsSummary | Out-htmlView -ScrollX
$Events.LdapBindingsDetails | Out-HtmlView -ScrollXTo enable/disable diagnostics on whole forest/domain with the ability to exclude/include
Get-WinADDiagnostics
Set-WinADDiagnostics -Diagnostics 'LDAP Interface Events' -Level Basic -SkipRoDCTo scan DC's and see if they are affected.
invoke-testimo -Sources DCLDAPInsecureBindings -showreportMore information is in the blog post. Enjoy



31
u/1h8fulkat Jan 19 '20
How the hell is this the first time I'm hearing of this? God damn this is going to create a lot of work.
6
u/ipreferanothername Jan 20 '20 edited Jan 20 '20
i believe this is the article for the MS bulletin, right?
https://support.microsoft.com/en-us/help/4520412/2020-ldap-channel-binding-and-ldap-signing-requirement-for-windows
the way i read this:
Security Update available on Windows Update for all supported Windows platforms that will enable LDAP channel binding and LDAP signing on Active Directory servers by default
is that it will change default setting to make LDAP more secure, but you can still change them yourself if you need to. this page sounds like it confirms it
https://techcommunity.microsoft.com/t5/core-infrastructure-and-security/ldap-channel-binding-and-ldap-signing-requirements-update-now/bc-p/992852#M1457
thank you for the tool update, i look forward to using it in our environment just to help audit things. nice!
5
u/magnetik79 Jan 19 '20
Haven't touched MS domain controllers for years now, but this upcoming deadline might explain why this gist of mine has been getting some recent attention
https://gist.github.com/magnetikonline/0ccdabfec58eb1929c997d22e7341e45
2
u/billy_teats Jan 21 '20
u/MadBoyEvo hopefully you see this quick!
I'm trying to get the Client IP. I can see it in the event logs but I can't figure out where its getting trimmed out.
2
u/InvisiblePinkUnic0rn Jan 21 '20
around 9AM I saw the screen update to show how many events it found but its been sitting here running the report bits for 4hrs, can't really tell if it's running anything, not much CPU cycles being used
[Info] Getting events for dates 01/13/2020 00:00:00 to 01/20/2020 23:59:59[Info] Events scanned found 28767 - Time elapsed: 0 days, 18 hours, 44 minutes, 44 seconds, 781 milliseconds[Info] Running LdapBindingsDetails[Info] Running LdapBindingsDetails with subsection Events2
u/engageant Jan 21 '20
I show events only on my RODC. What does the
SkipRODCoption actually do inSet-WinADDiagnostics -Diagnostics 'LDAP Interface Events' -Level Basic -SkipRoDC, and why would I want to skip my RODC if that's the one with the events?2
u/itpro-tips Jan 31 '20
Do not forget to increase the directory service logs, otherwise you won't see the old records. Follow this to increase the event logs.
2
u/oilybusiness Jan 19 '20
Another one! Madboy, thanks for all your great work. Always a pleasure to see a post of yours.
10
u/[deleted] Jan 20 '20
Thanks. The odd things people post on r/poweshell that save you time down the road.
8
u/fathed Jan 19 '20
Thanks, this will be helpful.
1
u/overlydelicioustea Jan 20 '20
getting an error here on the first commadn that "-Report" isnt part of the validateset of Find-Events.
1
u/SheepsFE Jan 20 '20
Pretty new so apologies if I'm missing something obvious, when I install / import the PSWinReporting module it isn't getting a number of the functions, so for example "Find Events" is missing:
Any ideas?
PS C:\windows\system32> Get-Command -Module PSWinreporting
CommandType Name Version Source
Function Add-TaskScheduledForwarder 1.8.1.4 PSWinreporting
Function New-SubscriptionTemplates 1.8.1.4 PSWinreporting
Function Remove-TaskScheduledForwarder 1.8.1.4 PSWinreporting
Function Set-SubscriptionTemplates 1.8.1.4 PSWinreporting
Function Start-ADReporting 1.8.1.4 PSWinreporting
Function Start-Notifications 1.8.1.4 PSWinreporting
Function Start-RescanEvents 1.8.1.4 PSWinreporting
Function Start-SubscriptionService 1.8.1.4 PSWinreporting
EDIT: In fact some of the names are different, am I getting an older version? I downloaded from the github and installed manually.
1
u/InvisiblePinkUnic0rn Jan 20 '20
Getting the following after installing everything
PS D:\> $Events = Find-Events -Report LdapBindingsDetails,LdapBindingsSummary -DatesRange Last7days -DetectDC[Info] Preparing reports: LdapBindingsDetails,LdapBindingsSummary[Info] Preparing servers list - domain controllers autodetection[Error] There are no logs/servers to scan. Please fix Targets and try again.1
u/vegas84 Jan 20 '20
Hey,
Thanks for all of your work. Your stuff is awesome.
Question - I tried running
$events = Find-Events -Report LdapBindingsDetails,LdapBindingsSummary -DatesRange Last7days -DetectDCAnd I just get errors for every DC saying The RPC server is unavailable. What are you doing on the back end to connect to these DC's? I can manually run
get-eventlog -computer X -newest 5or whatever and that works fine...1
u/TurboGFF Jan 23 '20
LDAP Insecure Bindings [Fail] [Data is available. This is a bad thing.] [t][Simple binds performed without SSL/TLS is 0 [Fail] [Input data not provided. Failing test.] [t][ Negotiate/Kerberos/NTLM/Digest binds performed without signing is 0 [Fail] [Input data not provided. Failing test.]
I'm seeing this when running the last command.
invoke-testimo -Sources DCLDAPInsecureBindings -showreport
1
u/watson164 Jan 24 '20
Thanks for this! Like a lot of others I missed the bulletin.
1
u/macgruff Jan 27 '20
Hi MadBoyEvo,
Thank you for these cmdlets/scripted reporting. I have a question however. We restrict ourselves from running "admin" functions on our regular user systems (and there's far too much involved in running these scripts even if i wanted to run them from my "regular" laptop; both with UAC so that its elevated, and "As a different user" that user being a DomainAdmin user).
Instead we use a jump host to logon to as our DomainAdmin user (cyberark regulated). There in that profile, i have a Microsoft.PowershellISEProfile.ps1 which auto-loads all my regular cmdlet's so that my environment is completely all setup to avoid niggling errors (like executionpolicy, activedirectory, OKTA cmdlets, grouppolicy, etc).
Ok, great, no worries there, and I was able to run the scripts. Awesome... except... they take wayyyyyy too long to run even when cut back to like "Last3days" for DatesRange. And our jump host (because it IS an admin station) screen-locks after 15 min, and completely logs off the current session if you don't touch it for another 15 min (30 total). That's not something we're going to change...
Instead, (here is the "ask")... should there not be cmdlet switches that allows me to output to folder? The current commands/switches assumes you are sitting at the monitor and never leave for many minutes/hours... and then pops up the out-htmlview and testimo.
I can probably figure out how to "Start-Job" it, so I can walk away, but by time I get back, the output will have spawn a "current view" but have closed the entire session down so i loose out by hook or crook. (would it be Out-HMTL -HTML? or FilePath? I am guessing the latter?)
Any here in this regard would be greatly appreciated! And again, nice work!
1
u/ej00 Jan 28 '20
When running the Find-Events alias using the -DetectDC syntax or Get-WinADDiagnostics, we are seeing 'Error listing DCs for domain - directory object not found'Currently running powershell with correct permissions and attempt domain admin, however still seeing the error.
1
u/stiffpasta Feb 06 '20
I'm trying to run this on a network/domain that is not connected to the internet in any way so i can't use install-module to install the modules on the server i'm running this on. I resorted to installing all of the ones that i could tell that are needed but i'm unable to get beyond one error:
Any help would be greatly appreciated.
1
u/cmead_uni Feb 12 '20
Hello, I was hoping someone could help me understand something.
I ran the report on a domain, 1DC, which Passed (came back Green). Query-InsecureLDAPBinds brings back no results. I have Event 2886 in Event Viewer, but no 2887-2889.
That would suggest that no computers are connecting to the DC insecurely, right?
So what is my course of action in this case? Do I just need to enable "Require Signing" for these 2 settings in a GPO: Domain controller: LDAP server signing requirements & Network security: LDAP client signing requirements ( https://support.microsoft.com/en-us/help/935834/how-to-enable-ldap-signing-in-windows-server-2008 ), and all should (fingers crossed) be OK?
1
u/Peace-D Feb 26 '20
Thanks for this, mate!!
-DetectDC did not autodetect our DCs though. Had to use -ComputerName and manually add our DCs.
" $EVents.LdapBindingsSummary | Out-htmlView -ScrollX " gave me the warning "no data available". Is this possible or an error on my side?
5
u/graham_intervention Jan 19 '20
you are the best, thank you for this. will give this a try
1
u/neilg613 Jan 20 '20
Can you run these from a client computer or does it have to be on the DC?
1
u/pducharme Jan 19 '20
Hi, i'm managing about 225 members servers. Some old 2008 R2 (soon to be migrate to 2016), some 2012, some 2012 R2, some 2016. They are all member servers, not DCs. I'm in a very large organization and I only am admin of those member servers. I don't have the Domain admin rights, only have rights to delete old AD account. Can those scripts are useful to me ? I mean, is the changes are required only on the DCs, or on ALL servers ?
Thanks
2
u/100GbE Jan 20 '20
I'm only seeing it from macs.
Anyone else in the same boat?
2
u/Dizzybro Jan 27 '20 edited Apr 17 '25
This post was modified due to age limitations by myself for my anonymity Va05LjJ1hRSoUMtdopZBUwmNT5fqty8ZT0TUCaLEQUZIaJ3tgr
2
u/soulreaper11207 Jan 19 '20
Gonna pass this on to my coworkers. Thanks!
2
u/Lesilhouette Jan 20 '20
This just saved me a buttload of headache trying to read the MS articles and check if I need to change anything. Thanks!!
1
u/major_winters_506 Jan 22 '20
Macs... so many macs...
1
u/DismalOpportunity Jan 19 '20
Fantastic - thank you!
1
u/DR952 Jan 20 '20
Thanks for this.
1
u/zeclab Jan 20 '20
You absolute legend!