<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Practical Windows Security</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/russellt/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/russellt/feed.xml</link>
    <description>Russell Tomkins - Microsoft Premier Field Engineer</description>
    <lastBuildDate>Thu, 11 May 2017 23:37:06 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Introducing Project Sauron - Centralised Storage of Windows Events - Domain Controller Edition</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/project-sauron-introduction</link>
      <pubDate>Tue, 09 May 2017 03:23:33 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">http://blogs.technet.microsoft.com/russellt/?p=475</guid>
      <description><![CDATA[(Nearly) every customer I visit is lacking comprehensive security auditing in their downlevel DEV...]]></description>
      <content:encoded><![CDATA[(Nearly) every customer I visit is lacking comprehensive security auditing in their downlevel DEV and UAT environments and sometimes even in their production environment. This scenario exists for a number of reasons. For some larger customers, the security logs roll so quickly that it's considered "<em>too hard</em>" to even bother trying to archive them without a <a href="https://en.wikipedia.org/wiki/SIEM">SIEM </a>in place. Sometimes they have a project already <em>"planned" or</em> "<em>in-flight</em>" to deploy &lt;insert product name here&gt; that will capture all the required events but it is still months away (or longer). One that i'm hearing a lot more of lately <em>"we used to store everything but our SIEM is now to expensive and we can only store some of it</em>". I find this one so amusing since the cost of large volume storage has dropped so dramatically.

&nbsp;
<div>Without an effective security audit trail, the ability to discover when changes were made or possibly even track a breach during a security incident response becomes near impossible.</div>
&nbsp;

Project Sauron aims to resolve a number of these issues using the built-in security capabilities of Windows to store the appropriate events.

&nbsp;

Windows Event Forwarding is in no way new, however the ability to create custom destination for forwarded events has always been difficult. My previous blog post explained <a href="http://blogs.technet.microsoft.com/russellt/2016/05/18/creating-custom-windows-event-forwarding-logs/">how to create custom event logs</a><span> for this purpose however it was quite tedious to build anything greater than a few destinations and I wanted to create lots of destinations, not just a few.</span>
<div></div>
Using the Project Sauron Framework, the deployment of centralised Windows Event Collector (WEC) server becomes almost simple. Using custom WEC subscriptions, the required events are forwarded into dedicated event channels and dedicated .evtx file. Creation and deployment of your own custom solution (would love to hear your ideas) or re-using one the pre-built solutions can have you operational in matter of hours not months. The diagram below gives an example of how the framework can be used.

[caption id="attachment_535" align="alignleft" width="1024"]<a href="https://msdnshared.blob.core.windows.net/media/2017/05/Overview2.jpg"><img width="1024" height="638" class="size-large wp-image-535" alt="Project Sauron Overview" src="https://msdnshared.blob.core.windows.net/media/2017/05/Overview2-1024x638.jpg" /></a> Project Sauron Overview[/caption]

<div></div>
<div></div>
<div>I want to be very clear, Project Sauron is in no way intended to be a SIEM. It's goals are to:</div>
<ul>
 	<li>Allow organisations to forward and store specific events of different values and frequency events into separate buckets for basic viewing and/or future import into a SIEM</li>
 	<li>Provide rudimentary viewing buckets for quick glance at low volume but high value long term events</li>
 	<li>Enable the capability to collect security audit events in DEV/TEST style environments that for whatever reason are not monitored by a SIEM.</li>
 	<li>Reduce the attack surface of high value assets by eliminating the requirement for yet another C2 agent with local system privileges.</li>
 	<li>Enable highly network isolated environments that can't connect to on-premises SIEM's or a cloud security monitoring solution keeping the native format to allow manual future analysis through manual imports and analysis.</li>
</ul>
WEC subscriptions are based on XPath filters in which we define which particular events we want our clients to forward to the collector. Conveniently, Event Viewer Custom Views use exactly the same filtering mechanisms as well and we exploit this relationship as part of the framework.

I commonly see Event Viewer custom views used on Domain Controllers to filter out the noise of security logs and that is how this all began. A customer was targeting multiple DC's one-by-one with a custom view to piece together a change that been made all the whilst racing against the pending security log overwrite that was coming in the next 20 minutes (this was a 100,000+ user organisation with a standard 2GB security log on the DCs). I figured, why not send those particular events of interest to a dedicated channel on a WEC server.

By spending the time to craft the appropriate XPath filters, we can then build the corresponding dedicated event log channel .evtx file and subsequently a WEC subscription to bring it all together. With the appropriate WEF/WEC configuration and the Event Channels along with WEC Subscriptions enabled, the configured source machines will begin to forward their events. Low volume events such as eg.. user and group creation may take 3 years to fill up the dedicated 1GB default .evtx file whereas high volume events like Kerberos TGS requestions might take 3 hours and be archived create a new 1GB .evtx file.

[caption id="attachment_536" align="aligncenter" width="874"]<a href="https://msdnshared.blob.core.windows.net/media/2017/05/Custom-Views-and-Channels.jpg"><img width="874" height="692" class=" wp-image-536" alt="Custom Event Views (Left) and Custom Event Channels (Right)" src="https://msdnshared.blob.core.windows.net/media/2017/05/Custom-Views-and-Channels-1024x811.jpg" /></a> Custom Event Views (Left) and Custom Event Channels (Right)[/caption]

By spending the time to craft and validate the appropriate XPath filters, we now have the building blocks to build the corresponding event channels with associated .evtx log file.

Whilst custom event views (displayed on the left) are simply .XML files that live in the <em>"%programdata%\Microsoft\Event Viewer\Views"</em> folder on your machine and their display mimics the file system folder structure, Custom event channels (displayed on the right) require the construction of a dedicated  manifest file and the compilation of a .DLL to allow Windows to create them.

The framework simplifies the creation of all of these components by executing multiple scripts against a master input CSV file which defines the events and their configuration.

<strong>Whats in the Framework?</strong>

The scripts in framework perform the following tasks with the master Input CSV file.
<ol>
 	<li>Create the custom views .xml files and place them in %programdata%</li>
 	<li>Creates the manifest file and provides instructions to use the Windows SDK to compile and load the .dll</li>
 	<li>Prepares the Event Channels b to receive events and subsequently archive the existing .evtx once it hits 1GB</li>
 	<li>Import the WEC subscription configurations ready to be enabled (manual intervention required to enable by default)</li>
</ol>
I will go through the full process in a future blog posts, but if you want to get started, the following steps will give you an idea of how the solution operates.
<div><strong>Quickest Start - No Configuration Changes</strong>
1. Grab the latest release of Project Sauron from<a href="https://github.com/russelltomkins/Project-Sauron/releases"> https://github.com/russelltomkins/Project-Sauron/releases</a></div>
<div>2. Extract the "Domain Controllers" custom views to <em>"%programdata%\Microsoft\Event Viewer\Views" </em>on your management host.</div>
<div>3. As an appropriately privileged user, Open Event Viewer and target a Domain Controller. Peruse through the custom views to understand the types of events that would be forwarded from each Domain Controller to the collector.</div>
<div></div>
<div><b>Quick Start - WEC Server and Domain Controller Changes</b></div>
<div>Prep - The WEC server and Domain Controllers must be prepped to have the WEC server configured and WEF on the Domain Controllers succesfully talking to it. Details of the requirements can be found in Jessicas' blog <a href="https://blogs.technet.microsoft.com/jepayne/2015/11/23/monitoring-what-matters-windows-event-forwarding-for-everyone-even-if-you-already-have-a-siem/">post here.</a></div>
<div>1. Grab the latest release of Project Sauron from <a href="https://github.com/russelltomkins/Project-Sauron/releases">https://github.com/russelltomkins/Project-Sauron/releases</a> and extract to a folder on your nomiated WEC subscription server.</div>
<div>2. Copy the DCEvents.dll and DCEvents.man file to <em>"C:\Windows\System32"</em></div>
<div>3. Launch an administrative PowerShell and change to the directory with the Project Sauron files
4. Load the custom events channels by executing "<em>wevtutil.exe im c:\windows\system32\dcevents.man</em>"</div>
<div>5. Prepare the custom event channels by Executing <em>".\Prepare-EventChannels.ps1 -InputFile DCEvents.csv -LogRootPath D:\Logs".</em> If you omit the -LogRootPath paremeter, the script will default to "<em>D:\Logs</em>" as the location for the .evtx files.</div>
<div>6. Create and import (disabled) the WEC subscriptions by executing <em>".\Create-Subscriptions.ps1 -InputFile .\DCEvents.csv</em>".</div>
<div>7. Choose and enable the WEC subscriptions you wish to enable. There is no "select-all" but you can select the first subscription, hold SHIFT and select the last subscription then right-click enable.</div>
<div></div>
<div>

[caption id="attachment_525" align="aligncenter" width="1024"]<a href="https://msdnshared.blob.core.windows.net/media/2017/05/Subscriptions.jpg"><img width="1024" height="338" class="wp-image-525 size-large" alt="WEC Subscriptions" src="https://msdnshared.blob.core.windows.net/media/2017/05/Subscriptions-1024x338.jpg" /></a> Enabled WEC Subscriptions with 1 DC connected[/caption]

</div>
<div></div>
<div>Once the Domain Controllers connect to the WEC server, they will receive the appropriate subscriptions and begin to sending the appropriate events.</div>
<div></div>
<div>Some quick notes:</div>
<ul>
 	<li>Your Domain Controllers in this scenario need to have the appropriate <a href="https://docs.microsoft.com/en-us/windows/device-security/auditing/advanced-security-audit-policy-settings">Advanced Audit Subcategories</a> enabled.</li>
 	<li>You don't have to enable every subscription at once. Enable a single subscription or just a category eg.. the Object Management category to understand how it works.</li>
 	<li>The logs folder will have NTFS compression enabled. This reduces .evtx size by roughly half</li>
 	<li>
<div>Once an individual .evtx log file hits 1GB, it will be archived by the Event Log service and a new one created.</div></li>
 	<li>ZIP Compressing the .evtx file will result in an rough 60-70MB file.</li>
 	<li>If your having issues, check the "Windows Event-Forwarder" plugin on the DC to confirm it has connect the WEC server and succesfully received subscriptions.</li>
 	<li>A script to manage the compression of the archived (non-active) .evtx files is nearly completed.</li>
 	<li>All .PS1 and the pre-canned .DLL file is AuthentiCode signed. Your machines will (should) not trust my signing certificate by default but should validate they have not been tampered with.</li>
</ul>
The Future
<ul>
 	<li>A domain members version (preview custom view in release 1.3) which covers the events from Jessica's MSAU 2015 Ignite session <a href="https://blogs.technet.microsoft.com/jepayne/2015/11/23/monitoring-what-matters-windows-event-forwarding-for-everyone-even-if-you-already-have-a-siem/">Monitoring what matters – Windows Event Forwarding for everyone (even if you already have a SIEM.)</a></li>
 	<li>A pre-canned .DLL for AD Certificate Services (AD-CS) to collate Issued, Pending, Revoked certificate and service operations.</li>
 	<li>Custom views for the WEC server to allow further quick discovery eg... Show RC4, AES128 and AES256 Kerberos AS requests</li>
</ul>
Phew ... there is soo much more to all of this, but hopefully once you get it running it's value will be apparent, even it is just keeping events around to import into a future SIEM.
<div>Please let me know what you think in the comments or improvements/ideas via the <a href="https://github.com/russelltomkins/Project-Sauron">GitHub repository </a>which I'm still slowly learning how to use.</div>
<div></div>
<div>More posts to come</div>
<div></div>
<div>Russ</div>]]></content:encoded>
    </item>
    <item>
      <title>Creating Custom Secure LDAP Certificates for Domain Controllers with Auto Renewal</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/custom-ldap-certs</link>
      <pubDate>Fri, 03 Jun 2016 22:34:06 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">http://blogs.technet.microsoft.com/russellt/?p=385</guid>
      <description><![CDATA[Working with customers each week on securing their Active Directories, there are some procedures you...]]></description>
      <content:encoded><![CDATA[Working with customers each week on securing their Active Directories, there are some procedures you end up doing regularly. Installing and configuring custom certificates onto Domain Controllers to enable LDAP over TLS for me is one of them. The primary reason for enabling this functionality is to allow third-party applications that aren’t capable of performing secure binds or encrypted LDAP sessions (over TCP 389) to connect securely. Trust me, there are plenty of <a href="http://blogs.technet.microsoft.com/russellt/2016/01/13/identifying-clear-text-ldap-binds-to-your-dcs/" target="_blank">applications that need it</a>.

[caption id="attachment_415" align="alignright" width="516"]<img class="wp-image-415" src="https://msdnshared.blob.core.windows.net/media/2016/06/CustomLDAP.jpg" alt="Custom LDAP Certificates Example" width="516" height="426" /> Example Deployment Scenario[/caption]

Along with deploying these certificates, most customers like to place some form of load balancer in-front of these DCs to ensure applications will always have high-availability access. This method generally involves a custom alias such as "ldap.domain.com" targeted at the load balancers with connections then forwarded to a subset of DCs.

<strong>Important Note:</strong> The load balancer method of enabling highly available LDAP access is <strong>NOT </strong>supported by Microsoft, but it does work. To be fully supported, applications need to be using our documented methods to locating and binding to DC's. If an application is misbehaving, be ready to abandon this configuration if deeper application troubleshooting is required.

As with all TLS connections, if you attempt to connect to any server where the subject name mismatches, the connection will fail validation. Most admins are familiar with the errors associated with this scenario when deploying HTTPS. So to allow our application servers to bind securely to a custom LDAP DNS name and ensure connections are valid with the correct name, we need to ensure the custom LDAP DNS name is present in our Domain Controller certificates. Easy enough to do with some prep, impossible to do automatically. But that's why your here right?

Our Domain Controllers by default will use one of the 3 built-in certificate templates for LDAP over TLS purposes. These templates were introduced consecutively with each OS release. The templates are the:
<ul>
	<li><em>Domain Controller</em> (Windows Server 2000)</li>
	<li><em>Domain Controller Authentication</em> (Windows Server 2003)</li>
	<li><em>Kerberos Authentication</em> (Windows Server 2008 and above)</li>
</ul>
Our modern domain controllers can use any one these 3 certificate templates, however we really want your DC's to be using the Kerberos Authentication template. By default, it includes multiple SAN entries that represent the Domain Controller, Active Directory Domain FQDN and the Active Directory NetBIOS name. Additionally it contains a new Enhanced Key Usage to allow strict KDC validation to be enabled on all modern clients that are performing smart-card based (PKINIT) logons.

This walk through is going to leverage a fairly unknown feature of the auto enrollment component in Windows that allows certificates requested from an Offline Template (that is one where you provide the subject names in the Certificate Signing Request or CSR) to be automatically renewed without CA certificate manager intervention. The method described can actually be used for any certificate template where you want the auto enrollment component to automatically renew certificates and keep the existing subject names.

Note. This procedure only works for machines and Enterprise Issuing CA’s that are at least Windows 7 /2008 R2 or above.

Lets get started.
<h2>Certificate Authority - Certificate Template Prep</h2>
To make this work, we need a slightly modified version of the "Kerberos Authentication" template. In this example, we are going to configure a custom template for our "Special DCs" DC’s that are going to be targeted by our load balancers. All other DC’s will continue to use standard Kerberos Authentication template.
<ol>
	<li>On your Enterprise Issuing CA, open "certsrv.msc" and right-click the "Certificate Templates" folder and select "Manage". This will show you all the templates present in the Active Directory forest.</li>
	<li>Scroll down until your find "Kerberos Authentication<em>"</em>. Right-click it and select "Duplicate"</li>
	<li>If you are on 2012/2012R2, you will be presented with the compatibility screen. Unless you know what you’re doing with version 3/4 templates, simply select "Windows Server 2008 R2" and "Windows 7/Windows Server 2008 R2" for both of the options and select OK on the confirmation prompts.</li>
	<li>On the "General" tab, give your new template the name "Kerberos Authentication (Offline Request)". In production environments, prefixing the name with a few letters can help group your active templates together in the UI, recommended but optional.</li>
	<li>Now, to make it an Offline Template, simply head over the "Subject Name" tab and select the top radio box "Supply in the Request". Click OK on the security warning prompt. Please read an understand this prompt. In our scenario, only DCs have the ability to request this certificate, but with other certificate templates, the ticking of this box should be done only if restricted and trusted users can request the template.

[caption id="attachment_455" align="aligncenter" width="300"]<a href="https://msdnshared.blob.core.windows.net/media/2016/06/UseSubject.png"><img class="wp-image-455 size-medium" src="https://msdnshared.blob.core.windows.net/media/2016/06/UseSubject-300x176.png" alt="Use Subject in Auto Enrollment Renewals" width="300" height="176" /></a> Use Subject in Auto Enrollment Renewals[/caption]</li>
	<li style="text-align: left">Also on the "Subject Name" tab, tick the "Use subject information from existing certificate for autoenrollment renewal requests". This tick box is critical to the “magic sauce” that allows the CA Policy engine to reuse the existing certificate subject name values instead of being provided as brand new ones in the CSR. (This is an offline request, the names can't be built from Active Directory)</li>
	<li>Next, open the "Security" tab and remove the “Enroll” security right from "Domain Controllers","Enterprise Domain Controllers" and "Enterprise Read-only Domain Controllers”.</li>
	<li>Add new ACE’s for each of the special DC’s (or possibly a security group with them in) that are to receive the custom certificates and ensure they have the “Read" and "Enroll” security right only. Check that no other entries include Enroll or Autoenroll except administrative user groups. Make sure you enable "Computer Objects" in the select objects prompt.</li>
	<li>Optional. For advanced players, head over to the "Superseded Templates" tab and add the "Domain Controller", "Domain Controller Authentication" and "Kerberos Authentication" templates to the list. This will "archive" any certificates from those templates when this new one is enrolled. Note. Archived = hidden, not deleted.</li>
	<li>Close the new template to save it.</li>
	<li>Now that our new template for the "special" DC's is ready to go, open the original “Kerberos Authentication” template and the security tab. Add the Deny “Enroll” and "Auto Enroll" right to the special DC’s you are giving custom certificates to. This will stop them from getting the standard Kerberos Authentication certificates during the auto enrolment process.</li>
	<li>As per normal, we need to actually issue the template. Right-Click "Certificate Templates" again and select "New" and "Certificate Template to Issue"</li>
	<li>From the list, select your newly minted "Kerberos Authentication (Offline Request)" template and click OK.</li>
	<li>Optional - If both the original "Online" and our new "Offline Kerberos Authentication" templates are present in the issuance list, remove the older "Domain Controller" and "Domain Controller Authentication" templates. Simply right-click them and select "Delete". This doesn't remove template itself from Active Directory, just their issuance from this particular CA. If you have multiple CAs, it's a good idea to remove their issuance form them as well. Should you issue the "Kerberos Authentication" templates from multiple CAs? You can, but not really required.</li>
</ol>
<h2>Domain Controller - GPO Prep</h2>
OK, so I'm not going to into to much depth on this one as it's pretty simple. Auto Enrollment is usually configured in a Domain Controller Policy by the GPO settings at this location " \Computer Configuration\Windows Settings\Security Settings\Public Key Policies\Certificate Services Client – Auto-Enrollment". Most orgs already have this enabled and you simply need to confirm that both the first and second check box "Update certificates that use certificate templates" is enabled.

It's completely up to you if you want this GPO purely targeted at your special DCs or all of your DCs

<strong>Warning. </strong>If you are enabling Auto Enrollment for the first time, you may receive other "unexpected" certificates on your DC's. You can prevent this by analysing the security tab of all certificate templates currently being issued by your CAs and ensuring that any of the "Domain Controller" computer groups have not been granted the "Auto Enroll" security right. But that wouldn't happen because you know the security DACLS of all your templates right? No? ... well pencil some time for a quick review in the near future.

[caption id="attachment_425" align="aligncenter" width="300"]<a href="https://msdnshared.blob.core.windows.net/media/2016/06/GPOOptions.png"><img class="wp-image-425 size-medium" src="https://msdnshared.blob.core.windows.net/media/2016/06/GPOOptions-300x161.png" alt="GPOOptions" width="300" height="161" /></a> Auto Enrollment Group Policy Settings[/caption]
<h2> Domain Controller - Initial Enrollment</h2>
Because we need to provide the extra subject names, the initial certificate enrollment for our special DCs must be performed manually.
<ol>
	<li> On one of our special Domain Controllers, Open "certlm.msc". If it's a 2008 R2 DC, you will need to open "mmc.exe" and add the "Certificates" snap-in targeting the local computer.</li>
	<li>Right-Click the "Personal" store and select "Request New Certificate". Click "Next" twice until the screen with available templates appears. Select the check box next to our "Kerberos Authentication (Offline Request)" Template and then click the hyperlink "More Information is required ...." below the name.</li>
	<li>Leave the "Subject Name" blank, but add the following to the alternative name section. The first 3 are the names that are added automatically with the built-int template. The last one is our new custom name. They are all of the type "DNS"FQDN of the AD Domain Controller
FQDN of the AD Domain
NetBIOS name of the AD Domain
<strong>Your new custom secure LDAP DNS name
</strong>

[caption id="attachment_435" align="aligncenter" width="300"]<a href="https://msdnshared.blob.core.windows.net/media/2016/06/SubjectAltNames.png"><img class="size-medium wp-image-435" src="https://msdnshared.blob.core.windows.net/media/2016/06/SubjectAltNames-300x181.png" alt="Subject Alternative Names" width="300" height="181" /></a> Subject Alternative Names[/caption]

<strong> </strong></li>
	<li>Click "OK" once you have finished adding the names and then "Enroll" to send the CSR to the Enterprise Issuing CA for issuance.</li>
	<li>When complete, expand the Personal -&gt; Certificates folder and check out your shiny new cert. Double-click the certificate to open it and confirm the names present in the Subject Alternate Name extension. If there are multiple certificates, you can scroll the console window to the right to see the template names.</li>
	<li> Repeat the process on the other special DCs you wish to create a custom secure LDAP certificate for.</li>
</ol>
<h2>Domain Controller - Verifying renewal will work</h2>
So at this point, your special DCs should have the appropriate certificate, but we want to make sure our new automatic enrollment renewal plumbing works. We don't want auto enrollment renewal to fail in ~11 months’ time due to a slight mis-configuration. We can easily confirm that everything is configured well by increasing the "major version" of the certificate template. When we increase this value, it's a signal to the Auto Enrollment client on the machine that the CA administrator has requested re-issuance of certificates based on that particular template.

This is where the first and second tick boxes in the auto enrollment client GPO configuration is critical, without it, this particular logic branch will never execute. You may also remember we didn't initially allow auto enrollment for our special DCs from our new template, this was to stop them from attempting auto enrollment, we need to enable this now. (Sidenote, it's perfect valid configuration to enable auto enrollment for offline templates. The machines will simply show a balloon pop-up when an administrator logs requesting intervention to provide the subject names)
<ol>
	<li>Open “certsrv.msc” on your Enterprise Issuing CA and right-click the “Certificate Template” folder and select "Manage" to open the Certificate Templates Console.</li>
	<li>Open the security tab of our "Kerberos Authentication (Offline Request)" template and simply add the “Auto-Enroll” security right/flag to the existing ACEs for our special DCs. This will allow the auto enrollment client on our special DCs to now consider this template as part of its automatic renewal process and also monitor the template version for update requests. Close the certificate template properties to save it.</li>
	<li>Right-click our "Kerberos Authentication (Offline Request)" template and select "Reenroll All Certificate Holders". If you have a keen eye, you will notice the version will change from something like 100.2 to 101.0. The minor version (the second number) will increase every time you make a change to the certificate template. Increasing the minor version won't affect already issued certificates. Increasing the major however instructs clients with the second auto enrolment client check box enabled to renew this certificate at their next update cycle. We want to trigger this to ensure everything works a treat.</li>
	<li>Back on your DC, feel free to wait around until this occurs or you can run "certutil -pulse". If you really love your GUI, in the certificates console, right-click "Certificates - Local Computer" at the top of the left-hand tree and select "All Tasks" -&gt; "Automatically Enroll and Retrieve Certificates"</li>
	<li>It may take a few minutes, but once it's completed (all going well), you should be able to analyse the "Certificate Template" field in your "Kerberos Authentication (Offline Request)" certificate and see the major version field matches the increased version of your certificate template. If the version hasn't increased, confirm your GPO and certificate template settings. See below on how to view your older archived certificates (including any superseded ones)</li>
	<li>Once again, validate all your subject names are correct and expected. The next section can make things a little easier.

[caption id="attachment_445" align="aligncenter" width="1024"]<a href="https://msdnshared.blob.core.windows.net/media/2016/06/TemplateVersion.png"><img class="size-large wp-image-445" src="https://msdnshared.blob.core.windows.net/media/2016/06/TemplateVersion-1024x236.png" alt="Old and New Template Versions" width="1024" height="236" /></a> Old and New Template Versions[/caption]</li>
</ol>
<h2> LDAP/S (TCP 636) Validation</h2>
One of the good (or possibly bad?) functions of Domain Controllers is that they will pretty much immediately start using the brand new "Kerberos Authentication" certificates for their LDAP/S connections. Because of this, you can check immediately if the certificate is being presented correctly. The easiest way is to download my <a href="https://gallery.technet.microsoft.com/Domain-Controller-TLS-6a50a3d2" target="_blank">Domain Controller LDAP/S Certificate Audit </a>script and directly query all of your DC's. The script will output both to screen and a .CSV for easy analysis.

We primarily want to check that our special DCs have the appropriate updated Subject, V2 Template and EKU extensions with our new values. Not a bad time to confirm the remainder of our DCs are using Kerberos Authentication template certificates as well.
<h2>Some Pre-emptive Q&amp;A's</h2>
Q: I only have a few Domain Controllers, can I simply apply this guide to all of them?
A. Yup, even if you have 300 DCs, you can perform this guide on all of them if you wish. It will just take you a while.

Q. What if I want a number of custom LDAP DNS names? Say a unique one for multiple DCs in each of my data-centre locations?
A: Simple. The renewal will simply follow whatever name you enrol in the original enrolment, so simply configure the appropriate custom name on the appropriate DCs

Q: I'm feeling nostalgic and want view my older archived certificates, how can I see them?
A: In the certificates console, right-click the root of the tree then select "view" -&gt; "options". Tick the "Archived Certificates" button. They will now show up in the personal store again with an "A" in the "Status" column. If you configured supersedence, those certificates will also be flagged as archived.

Q: OK, I'm feeling both nostalgic AND I really want to reactivate my old certificates (for various reasons)
A: No problems, open up a PowerShell prompt and do the following. You should also prevent the template from being re-issued otherwise it will just come back.
<pre style="padding-left: 30px">cd Cert:\LocalMachine\My
ls -force
$Cert = Get-Item &lt;ThumbprintOfNewCert&gt;
$Cert.Archived = $True
$Cert = Get-Item &lt;ThumbprintOfOldCert&gt;
$Cert.Archived = $False</pre>
<h2> Wrapping Up</h2>
Not much more to it then that. Your special DCs will now have TLS certificates that have your extra secure LDAP DNS name included and your remaining DCs will have a vanilla Kerberos Authentication certificate with names automatically generated from Active Directory. The critical part of this process is to confirm that the renewal component works as expected. If this section fails, your going to have an outage in 12 months when your certificates expire because they don't renew correctly.

If you have gotten this far, you should also check out my other blog post on <a href="https://blogs.technet.microsoft.com/russellt/2016/04/29/get-crlfreshness/" target="_blank">CRL-Freshness </a>for ensuring the CRLs that support your Domain Controllers certificates are always fresh and up to date.

As always, leave a comment if you found this useful or something doesn't work as expected

Russ <a href="http://twitter.com/russelltomkins" target="_blank">@russelltomkins</a>]]></content:encoded>
    </item>
    <item>
      <title>Understanding and Remediating "PASSWD_NOTREQD"</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/passwd_notreqd</link>
      <pubDate>Thu, 26 May 2016 23:31:25 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">http://blogs.technet.microsoft.com/russellt/?p=338</guid>
      <description><![CDATA[In my previous post on querying the userAccountControl attribute, I noted one of the flags I want to...]]></description>
      <content:encoded><![CDATA[In my previous post on <a href="https://blogs.technet.microsoft.com/russellt/2016/01/27/querying-useraccountcontrol-configurations/">querying the userAccountControl attribute</a>, I noted one of the flags I want to ensure you understood was the PASSWD_NOTREQD or "Password Not Required" flag. As the name suggests, this flag allows you to have a fully functioning account with a <strong>blank</strong> password (even with a valid domain password policy in place).

In my time performing AD security assessments, I would estimate I've seen nearly 300,000 accounts with this flag set. Out of those accounts, I have only ever seen 5 unprivileged active accounts that had blank passwords set. So yes I want you to remediate the affected accounts, but even if a quick audit shows a large number of them present in your domains, it's probably not as bad as you think.
<h2>How does it happen?</h2>
This issue most commonly arises due to identity management systems that create accounts with the flag set, set a password but fail the last step of removing the flag. Our in-built tools such AD Users and Computers perform all the appropriate steps to remove the flag.

To actually have an enabled account with a blank password, the following things need to occur:
<ol>
	<li>You need to have PASSWD_NOTREQD enabled on your userAccountControl attribute and</li>
	<li>Have a password not set at creation time <strong>OR</strong> have privileged user exercise the "Reset-Password" security right and simply press enter on the password change prompt to grant the account a blank password.</li>
</ol>
<h2>So I have "X" amount of accounts in my report, can you tell me how many have blank passwords?</h2>
Not directly, there is no interface to query if an account has a blank password <strong>BUT</strong> if we try to remove the flag on an enabled account and the password is blank, we will get an error because the DC definitely knows it won't meet the password length/complexity requirements of your domain (its blank duh!)

The following flow chart shows you the behavior that will occur when we try to remove the PNR flag from an account. The outcome depends on the current status of the account and if the current password is blank or not.

<a href="https://msdnshared.blob.core.windows.net/media/2016/05/Flow.jpg"><img class="alignright size-large wp-image-345" src="https://msdnshared.blob.core.windows.net/media/2016/05/Flow-1024x290.jpg" alt="Remove PNR Flow" width="1024" height="290" /></a>
<h2>Cleanup Aisle 3</h2>
The following script can be used to help identify (again) and then attempt to remove the PASSWD_NOTREQD flag on all affected accounts. It will visually report the findings using Out-Grid then confirm if you want to proceed. Along with visual feedback, it will also export the affected accounts and reset status to a .CSV for further investigation.
<pre># Report on Affected Accounts
$StatusLog = @()
Get-ADUser -Filter 'useraccountcontrol -band 32' -Properties "passwordnotrequired","useraccountcontrol","msDS-LastSuccessfulInteractiveLogonTime","lastLogonTimestamp" | Select-Object -Property DistinguishedName,Enabled,PasswordNotRequired,"msDS-LastSuccessfulInteractiveLogonTime","lastLogonTimestamp" | Out-GridView -Wait
# Attempt to remediate and log output
$Response = Read-Host "`nDo you want to attempt to remove PASSWD_NOTREQD from the listed accounts?"
If($Response.ToLower() -eq "y"){
 ForEach ($Account in (Get-ADUser -Filter 'useraccountcontrol -band 32')){
 $Status = "" | Select Status,Account 
 $Status.Account = $Account 
 Get-ADUser $Account | Set-ADUser -PasswordNotRequired $False -ErrorAction SilentlyContinue
 If($?){
 Write-Host "Succesfully removed PASSWD_NOTREQD from $Account" -ForeGroundColor Green
 $Status.Status = "Success"
 }
 Else{
 Write-Host "Failed to remove PASSWD_NOTREQD from $Account" -ForeGroundColor Red
 $Status.Status = "Failure"
 }
 $StatusLog += $Status
 }
}
Write-Host $StatusLog.Count "accounts processed. Refer to FIX_PASSWD_NOTREQD.csv for full details"
$StatusLog | Export-CSV -NoTypeInformation FIX_PASSWD_NOTREQD.csv

</pre>
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/PSOutput.png"><img class="alignright size-large wp-image-355" src="https://msdnshared.blob.core.windows.net/media/2016/05/PSOutput-1024x167.png" alt="Remediate-PNR Output" width="1024" height="167" /></a>
<h3></h3>
<h2>Final Words</h2>
So hopefully every identified account successfully has the PASSWD_NOTREQD flag removed and you feel a little easier knowing all of your user accounts have a password of some kind. If an account has failed (and you have permissions to modify it), there is a good chance it is both enabled and has a blank password. Press CTRL+ALT+DEL on domain member and try to login with a blank password.

Wait a few weeks after your initial clean-up and then check again. If any more accounts pop-up, you obviously have another system or operational process to remediate as well as some accounts to clean up.

<strong>Note:</strong> If any of the disabled accounts had a blank password, and your try to <b>enable</b> them in the future, you will receive an error saying the don't meet the password policy requirements. Simply set a password that meets requirements and then you will be able to enable it as expected.

If you find any blank passwords in your domains, let me know in the comments below.

Russ

&nbsp;

&nbsp;

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Creating Custom Windows Event Forwarding Logs</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/creating-custom-windows-event-forwarding-logs</link>
      <pubDate>Wed, 18 May 2016 23:07:39 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">http://blogs.technet.microsoft.com/russellt/?p=215</guid>
      <description><![CDATA[You may have noticed recently that *we* Microsoft security people have kind of fallen in love with...]]></description>
      <content:encoded><![CDATA[You may have noticed recently that *we* Microsoft security people have kind of fallen in love with Windows Event Forwarding (WEF). Why? Its built into Windows itself, easily configurable and can collect a very large amount of course or finely filtered events (including existing events) from any domain joined machine with less then 30 minutes of effort.

When demonstrating WEF to customers, one of the most common questions I receive is "<strong>I don't want everything in Forwarded Events, can I create separate logs for my subscriptions?"</strong> The answer is yes, but it takes a little bit of effort. Once complete, you can create as many custom "buckets" for your forwarded events as you like. Let's start.

Firstly, a large amount of credit goes to <strong>Ted Hardy</strong> for providing the majority of the process for this. I'm really just playing technical writer here.

Before we start, you will need a few things.
<ul>
	<li>If you don't have it already laying around, grab a copy of the <a href="https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk">Windows SDK for your OS</a>. Why? We need to compile a .dll. I'm not a programmer and I don't understand what resource and link files are, but thankfully you don't really need to.</li>
	<li><a href="https://msdnshared.blob.core.windows.net/media/2016/05/CustomEventChannels.txt">Right-click to download the template </a>"manifest" file from this blog post and rename it to .man from .txt.</li>
	<li>A machine to configure all of this on. I used a throw away virtual machine with Windows Server 2012 R2 and the Windows 8.1 SDK from above to perform these steps.</li>
</ul>
<h2>Create our Custom Event DLL and Manifest</h2>
<ol>
	<li>Go ahead and install your Windows SDK to your machine. I only applied the core SDK itself to the default install location.</li>
	<li>Now open the Manifest Generator which you will find at "C:\Program Files (x86)\Windows Kits\8.1\bin\x64\ecmangen.exe"</li>
	<li>Open the starter template manifest file from above. The screen should look something like this<a href="https://msdnshared.blob.core.windows.net/media/2016/05/ECManGen-2.png"><img class="aligncenter wp-image-225 size-full" src="https://msdnshared.blob.core.windows.net/media/2016/05/ECManGen-2.png" alt="ECManGen" width="872" height="543" /></a></li>
	<li>The channels you see here are really the goal. Any channels you create here are will show up in Event Viewer and also be available for selection in our event collector subscriptions.</li>
	<li>Modify the Name and Symbols to your hearts content. You can add a maximum of 8 channels per provider.</li>
	<li>If you want, feel free to also change the "WEC" at the root of the events section to something else.</li>
	<li>Save the .man file to somewhere on your drive. For the next few steps, I used the path "C:\ECMan" on my machine</li>
	<li>Now execute the following commands to build our .dll
<pre>cd\ECMan
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\mc.exe" C:\ECMan\CustomEventChannels.man
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\mc.exe" -css CustomEventChannels.DummyEvent C:\ECMan\CustomEventChannels.man
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\rc.exe" C:\ECMan\CustomEventChannels.rc
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /win32res:C:\ECMan\CustomEventChannels.res /unsafe /target:library /out:C:\ECMan\CustomEventChannels.dll C:\ECMan\CustomEventChannels.cs</pre>
</li>
	<li>The output of the folder post processing  should now look like the following<img class="aligncenter size-full wp-image-236" src="https://msdnshared.blob.core.windows.net/media/2016/05/ECManGenFileOutput.png" alt="ECManGenFileOutput" width="653" height="449" /></li>
	<li>Take a copy of the highlighted .man and .dll files and place them in your "C:\Windows\System32" folder on your Windows Event Collector server.</li>
	<li>We don't need this machine any more (unless you want to create more)</li>
</ol>
<h2>Load It Up</h2>
<ol>
	<li>Open an elevated command prompt, and execute the following
<pre>wevtutil im c:\Windows\system32\CustomEventChannels.man</pre>
</li>
	<li> If everything goes well, there should be zero console feedback. Now open Event Viewer (re-launch if it's already open) and you should now have your new custom folders ready to select in your WEC subscriptions (the pic below was taken after the subscription was configured and the log receiving events)<a href="https://msdnshared.blob.core.windows.net/media/2016/05/CustomLogs.png"><img class=" size-full wp-image-275 aligncenter" src="https://msdnshared.blob.core.windows.net/media/2016/05/CustomLogs.png" alt="CustomLogs" width="798" height="558" /></a></li>
	<li>The last thing before we start using them in anger, is to actually give the logs some configuration. The following commands will do the job easily for us. Below is an example for moving the WEC-Domain-Controllers custom log to E:\Logs and configuration a maximum size of 1GB. You can also right-click the log and configure the standard properties that way too.
<pre>wevtutil sl WEC-Domain-Controllers /lfn:E:\Logs\WEC-Domain-Controllers.evtx
wevtutil sl WEC-Domain-Controllers /ms:1073741824</pre>
</li>
	<li>The last piece of the puzzle is simply telling our event subscriptions to dump the events there instead of our old friend Forwarded Events.</li>
</ol>
<a href="https://msdnshared.blob.core.windows.net/media/2016/05/Subscription.png"><img class="aligncenter wp-image-285 size-full" src="https://msdnshared.blob.core.windows.net/media/2016/05/Subscription.png" alt="Subscription" width="592" height="496" /></a>

And there we have it, custom event logs for you to use with your Windows Event Forwarding solution. There is nothing to stop from your creating more event channels using the starter template, you will however have to update the provider properties with a new Name, GUID and updated paths for .dll files to ensure they are unique.

Happy Event Forwarding :)
Russ]]></content:encoded>
    </item>
    <item>
      <title>CRL Freshness PowerShell cmdlet</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/get-crlfreshness</link>
      <pubDate>Fri, 29 Apr 2016 22:38:45 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">http://blogs.technet.microsoft.com/russellt/?p=115</guid>
      <description><![CDATA[Overview
One of the critical functions of running a healthy PKI is ensuring that certificate...]]></description>
      <content:encoded><![CDATA[<h2><a href="https://msdnshared.blob.core.windows.net/media/2016/04/capture20160429205147798.png"><img class="  wp-image-196 alignright" src="https://msdnshared.blob.core.windows.net/media/2016/04/capture20160429205147798.png" alt="capture20160429205147798" width="333" height="419" /></a> Overview</h2>
One of the critical functions of running a healthy PKI is ensuring that certificate revocation data is always available and always fresh. Nearly every customer I work with has experienced some form of application or system outage due to CRL's not being fresh or available.

Most PKI administrators overcome the availability issue by either including multiple CRL distribution points into their certificates or placing them behind a network load balancers. In principal, this approach works extremely well, however it is still critical to ensure that all paths have fresh and up-to-date CRL information.
<h2>Short Version</h2>
It's a PowerShell cmdlet for you to check for both availability and freshness of all HTTP based CRL's, even those behind load balancers. Full log and email based alerts. Customize it to meet your needs. After importing the module, a "get-help get-crlfreshness" will give you everything you need, detailed steps further below.

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/CRLFreshCheck.psm1_.txt">Download the script here</a> and rename to .psm1 before using import-module.
<h2>What does the cmdlet actually do?</h2>
Designed for the monitoring base CRLs via HTTP paths, it allows admins to directly query the status of a CDP and CRL freshness for either a single or batch of CDP's that are critical for your organisation. It allows for the directory querying of web servers via IP address (whilst preserving the host header) so you can confirm that all web servers have fresh CRL data available no matter which one the load balancer directs clients to.

The primary mechanism for determining if a CRL is expiring is comparing the "Next CRL Publish" extension against the current time.  This extension when present, indicates the next time when a CA intends to publish an updated version of the CRL. The script will flag a CRL as "expiring" if the current time is more than 30 minutes after this time.

Not all CAs will publish this extension into their CRLs. In this scenario, the script will simply default to give warnings at 4 days from the CRL expiration. The cmdlet also has the ability to completely override the warning period with a value of your choosing. This can be useful if as above the "Next CRL Publish" is missing or you only want to receive a warning when the time gets closer to the CRL actually expiring.

If any errors are found, the script will simply send an email using the details configured in the PowerShell module itself.
<h2>First Steps</h2>
<a href="https://msdnshared.blob.core.windows.net/media/2016/04/CRLFreshCheck.psm1_.txt">Download the script here</a> and strip the .txt from the extension. Update the file (it's just text) with the appropriate email sender/recepient and server fields to ensure you will receive email alerts in the event of errors.

During testing, you might also want to manually set the time forward to confirm logging and alerting behaviour. You can do this at approximately line 95. Don't forget to remove it prior to production use.

Oh ... I live in the land down under, our days are more pushy and come before the months in our dates. I have absolutely no idea how this will work in other locales. I used .ToLocalTime() where possible, so hopefully it's cool. Drop me a comment if you have issues.
<h2>Checking a single CDP</h2>
As the cmdlet is distributed in a PowerShell module, the first thing we need to do is import the module then execute the cmdlet itself. The single mode execution has 3 parameters with only the "CDP" parameter being mandatory. The following command demonstrates the basic usage with all parameters:
<p style="padding-left: 30px"><strong>CDP</strong> - The URL path to the CRL file to be checked.
<strong>ServerIP</strong> - The IP to use directly. If omitted, a DNS lookup is performed.
<strong>WarningHours</strong> - Use to define or override the warning period</p>

<pre style="padding-left: 30px">Import-Module .\CRLFreshCheck.psm1 -Function Get-CRLFreshness
Get-CRLFreshness -CDP "http://crl.microsoft.com/pki/mscorp/crl/msitwww2.crl"</pre>
The following shows the result of the script. If there were any errors, it would attempt to send an email alerting you.

[caption id="attachment_135" align="aligncenter" width="1024"]<a href="https://msdnshared.blob.core.windows.net/media/2016/04/capture20160428125312709.png"><img class="wp-image-135 size-large" src="https://msdnshared.blob.core.windows.net/media/2016/04/capture20160428125312709-1024x354.png" alt="" width="1024" height="354" /></a> Get-CRLFreshness[/caption]
<h2>A Real World Example</h2>
Using the batch mode of the cmdlet, we can queue up multiple CDP's to check and confirm that all the CRL in your CDP's are fresh and available. The following example will demonstrate using the script to check a couple of our most common public CAs, "Microsoft IT SSL SHA1" and "Microsoft IT SSL SHA2".

The diagram below shows the basic CDP design as stated in their certificate chains. At present, both of the Issuing CA's distribute copies of their CRL's to multiple web servers. A quick DNS lookup shows that "crl.microsoft.com" is available on 2 IP's and "mscrl.microsoft.com" is available on one. Now, this is only the public view, there may be even more servers in the back-end, but this view is a good demonstration platform to show you how the script works. Note: These IP addresses listed below will most likely change in the future.

<img class="alignnone wp-image-125" src="https://msdnshared.blob.core.windows.net/media/2016/04/CRLFreshChecks-1024x508.jpg" alt="CRL Fresh Check Sample PKI" width="909" height="451" />

&nbsp;

To use batch mode in the cmdlet, we need to first create a simple CSV file (in this case MSIT.csv) which will give all the inputs for the cmdlets to run. Even if not used, ServerIP and Warning hours need to be included as a blank and the integer zero respectively.
<pre style="padding-left: 30px">CASubjectCN,CDP,ServerIP,WarningHours
Baltimore CyberTrust Root,http://cdp1.public-trust.com/CRL/Omniroot2025.crl,,0
Baltimore CyberTrust Root,http://cdp1.public-trust.com/CRL/Omniroot2025.crl,117.18.237.191,120
Microsoft IT SSL SHA1,http://crl.microsoft.com/pki/mscorp/crl/msitwww1.crl,,0
Microsoft IT SSL SHA1,http://crl.microsoft.com/pki/mscorp/crl/msitwww1.crl,23.205.115.152,0
Microsoft IT SSL SHA1,http://crl.microsoft.com/pki/mscorp/crl/msitwww1.crl,23.205.115.144,0
Microsoft IT SSL SHA1,http://mscrl.microsoft.com/pki/mscorp/crl/msitwww1.crl,,0
Microsoft IT SSL SHA1,http://mscrl.microsoft.com/pki/mscorp/crl/msitwww1.crl,68.232.45.201,0
Microsoft IT SSL SHA2,http://crl.microsoft.com/pki/mscorp/crl/msitwww2.crl,,0
Microsoft IT SSL SHA2,http://crl.microsoft.com/pki/mscorp/crl/msitwww2.crl,23.205.115.152,0
Microsoft IT SSL SHA2,http://crl.microsoft.com/pki/mscorp/crl/msitwww2.crl,23.205.115.144,0
Microsoft IT SSL SHA2,http://mscrl.microsoft.com/pki/mscorp/crl/msitwww2.crl,,0
Microsoft IT SSL SHA2,http://mscrl.microsoft.com/pki/mscorp/crl/msitwww2.crl,68.232.45.201,0</pre>
And now we can simply execute the cmdlet in batch mode against our MSIT.csv file.
<pre style="padding-left: 30px">Import-Module .\CRLFreshCheck.psm1 -Function Get-CRLFreshness
Get-CRLFreshness -Batch -InputFIle .\MSIT.csv</pre>
As per the output below, it will attempt to download each of the CRL's from the server and paths listed in the CSV. Any failures will be sent by email and also logged in the log file. A sample log file the gets generated can be seen here in the <a title="Get-CRLFreshness.log" href="https://msdnshared.blob.core.windows.net/media/2016/04/CRLFreshCheck.txt">CRLFreshCheck.log</a>.

<a href="https://msdnshared.blob.core.windows.net/media/2016/04/Get-CRLFreshness-Batch.png"><img class="aligncenter wp-image-175" src="https://msdnshared.blob.core.windows.net/media/2016/04/Get-CRLFreshness-Batch-1024x969.png" alt="Get-CRLFreshness-Batch" width="1024" height="969" /></a>
<h2>Wrapping Up</h2>
Hopefully you will find the script useful in your environment. Even if you only have a single CDP location, the script can help monitor for any issues that may arise. I would love to hear from you if your using the script in production, success stories are even better!

Russ]]></content:encoded>
    </item>
    <item>
      <title>Querying UserAccountControl Configurations</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/querying-useraccountcontrol-configurations</link>
      <pubDate>Wed, 27 Jan 2016 20:48:38 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">http://blogs.technet.microsoft.com/russellt/?p=81</guid>
      <description><![CDATA[One of the checks we perform as part of our AD security assessments is looking for security...]]></description>
      <content:encoded><![CDATA[One of the checks we perform as part of our AD security assessments is looking for security principals that have certain security configurations. A number of these settings are stored as a bitwise value on both user and computer objects as part of the userAccountControl attribute. Full details of all the settings for this attribute are located in t<a href="https://msdn.microsoft.com/en-us/library/aa772300(v=vs.85).aspx" target="_blank">his MSDN article</a>.

Some of the common values that most people recognise are:
<ul>
	<li>Password Never Expires (DONT_EXPIRE_PASSWD)</li>
	<li>User Cannot Change Password (PASSWD_CANT_CHANGE)</li>
	<li>Account is Disabled (ACCOUNTDISABLE)</li>
</ul>
From a security perspective the above values are all important, but as an AD admin, you should also be very interested in any accounts with the following flags:
<ul>
	<li><a href="https://blogs.technet.microsoft.com/russellt/2016/05/26/passwd_notreqd/" target="_blank">Password Not Required (PASSWD_NOTREQD)</a></li>
	<li>Account is Sensitive and Cannot be Delegated (NOT_DELEGATED)</li>
	<li>Account is Trusted For Kerberos Delegation (TRUSTED_FOR_DELEGATION)</li>
	<li>Account is Trusted for Kerberos Delegation with Protocol Transition (TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION)</li>
</ul>
I will definitely be talking about these in more detail in upcoming posts, but in the mean time, the script below can help you with your discovery of principals
<h3>Query UserAccountControl Script</h3>
Download here -&gt; <a title="Query-UserAccountControl.ps1" href="https://github.com/russelltomkins/Active-Directory/blob/master/Query-UserAccountControl.ps1" target="_blank">Query-UserAccountControl.ps1</a>

The script will loop through each of the corresponding User Account Control flags, and create 2 ".csv" files for each of them. One will be for user accounts, prefixed with a "U-" and  the other will be for computer accounts, prefixed with a "C-".

The output folder should resemble something like the following:

<a href="https://msdnshared.blob.core.windows.net/media/2016/01/Query-UserAccountControlOutput.jpg"><img class=" size-medium wp-image-91 aligncenter" src="https://msdnshared.blob.core.windows.net/media/2016/01/Query-UserAccountControlOutput-273x300.jpg" alt="Query-UserAccountControlOutput" width="273" height="300" /></a>

The script is pretty easy to execute, simple call it directly and optionally provide a server name. It will default to the localhost if a name is not provided.
<pre style="padding-left: 30px">.\Query-UserAccountControl.ps1 -Server "dc1.contoso.com"
Note: Some files will always be empty as their flags are not used. Account Lockout is such an example.</pre>
I hope this script is useful in your first steps to understanding any AD accounts that may be mis-configured and need to be remediated. Special care should of course be taken for those that are privileged from both Active Directory and your application perspectives.

Russ]]></content:encoded>
    </item>
    <item>
      <title>Identifying Clear Text LDAP binds to your DC's</title>
      <link>https://docs.microsoft.com/archive/blogs/russellt/identifying-clear-text-ldap-binds-to-your-dcs</link>
      <pubDate>Wed, 13 Jan 2016 23:01:58 GMT</pubDate>
      <dc:creator><![CDATA[Russell Tomkins [MSFT]]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/russellt/?p=51</guid>
      <description><![CDATA[If I told you that there was a 90% plus chance that your Domain Controllers allowed...]]></description>
      <content:encoded><![CDATA[If I told you that there was a 90% plus chance that your Domain Controllers allowed receiving credentials in clear text over your network, you would probably wouldn't believe me. If I went a step further and told you that nearly half of the customers I visit for AD security assessments not only allowed them, but had extremely privileged accounts such as Domain Admins credentials traversing the network in clear text, you would probably think "that wouldn't happen on my network", well that's what they all told me too :)

With a little bit of effort, you can reveal this common scenario very easily.

[Update] If you have 2008 R2, you need this <a href="https://support.microsoft.com/en-us/help/2777658/an-update-is-available-that-changes-client-bind-type-information-in-event-id-2889-in-windows-server-2008-r2">hotfix </a>to ensure the events have the flag which identifies Simple vs Unsigned binds.
<h3>A Simple Check</h3>
The first step to understanding if your affected is to look for Event ID <a target="_blank" href="https://technet.microsoft.com/en-us/library/dd941829(v=ws.10).aspx" title="2886">2886</a> and <a target="_blank" href="https://technet.microsoft.com/en-us/library/dd941856(v=ws.10).aspx" title="2887">2887</a> in your Directory Service log. If any of your Domain Controllers have the 2886 event present, it indicates that LDAP signing is not being enforced by your DC and it is possible to perform a simple (clear text) LDAP bind over a non-encrypted connection. This configuration is controlled by the security option "Domain controller: LDAP server signing requirements". I nearly always find this setting set to "None".

Our next port of call is the 2887 event. This event occurs every 24 hours and will report how many unsigned and clear text binds have occurred to this DC. If you have any numbers greater than zero, you have some homework to do. Luckily, the rest of this post will help you do just that.

The core of the issue is this, when an application performs a simple LDAP bind, the username and password is transmitted in clear text in the very first packet. The DC doesn't even have a chance to prevent this exposure from occurring.  If this connection is <strong>not</strong> encrypted at a lower layer such as TLS or IPSec, it may be intercepted and a bad day may soon follow.
<h3> OK, how badly am I affected?</h3>
Thankfully, we have the ability to increase our "LDAP Interface Events" diagnostic levels on a DC to report when these insecure binds occur. The commands for enabling and disabling are below. <strong>Warning: </strong>This setting has the ability to create a large number of events into the Directory Service event log. It will also log a number of other LDAP interface errors which may seem extremely alarming, these are normal and don't freak out too much when you see them. I highly recommend enabling this diagnostic level for a very short period of time (like 1o minutes) during your initial discovery phase. Once you have identified (and remediated) the noisiest offenders, you can begin enabling it for longer periods each time.
<pre style="padding-left: 30px"># Enable Simple LDAP Bind Logging 
Reg Add HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics /v "16 LDAP Interface Events" /t REG_DWORD /d 2</pre>
<pre style="padding-left: 30px"># Disable Simple LDAP Bind Logging.
Reg Add HKLM\SYSTEM\CurrentControlSet\Services\NTDS\Diagnostics /v "16 LDAP Interface Events" /t REG_DWORD /d 0

Note: You may need replace the double quotes after copy+paste.</pre>
Once we have the <a target="_blank" href="https://technet.microsoft.com/en-us/library/dd941849(v=ws.10).aspx" title="2889">2889 </a>events logged, we can examine them and determine which IP addresses and user accounts are binding insecurely. Looking through them all one by one may take awhile, the following are some resources to help you along.
<h3>Custom Event View</h3>
Download here -&gt; <a target="_blank" href="https://github.com/russelltomkins/Active-Directory/blob/master/LDAP%20Signing%20Events%20Custom%20View.xml" title="LDAP Signing Events Custom View.xml">LDAP Signing Events Custom View.xml</a>

This custom event view that can help you easily isolate "LDAP Signing Events" on your DC's Once imported, it will create a nice filtered view of all of the relevant LDAP signing events (2886 through 2889). Follow these steps to import it.
<ol>
 	<li>Open Event Viewer.</li>
 	<li>Right-click "Custom Views" then select "Import Custom View".</li>
 	<li>Provide a path to the downloaded .xml file. Feel free to rename it/change the description and location as you see fit.</li>
 	<li>If you are doing this on a management server (and you should be) you will get an error about the service channel being missing. Once you bind to the appropriate Domain Controller, it will show the appropriate events.</li>
</ol>
If there are no events, awesome! But as per above, if we have 2886 and 2887 events, we need to investigate. With diagnostics enabled, the 2889 events will also show up (possibly in large quantities) in this view.
<h3>Insecure LDAP Binds Query Script</h3>
Download here -&gt; <a target="_blank" href="https://github.com/russelltomkins/Active-Directory/blob/master/Query-InsecureLDAPBinds.ps1" title="Query-InsecureLDAPBinds.ps1">Query-InsecureLDAPBinds.ps1</a>

The second resource is a simple PowerShell script that will parse and extract the relevant data from the logged 2889 events on your DC into a nice .csv By default, it will only query for 2889 events that occurred in the past 24 hours. You can override this if you wish to go further (or shorter if there is lots of noise)
<pre style="padding-left: 30px">.\Query-InsecureLDAPBinds.ps1 -ComputerName dc1.contoso.com -Hours 24</pre>
The output .CSV will include IP Addresses, Ports, Username and the binding type. This can help quickly narrow down the affected user accounts and begin your remediation. It should look the following:
<pre style="padding-left: 30px">"IPAddress","Port","User","BindType"
"10.0.0.3","60901","CONTOSO\Administrator","Simple"
"[::1]","65445","CONTOSO\Administrator","Simple"</pre>
<h3>Fixing Your Applications</h3>
Sometimes fixing the offending applications is as simple as ticking a "Secure Connection" or "Secure Bind" checkbox inside the applications config. Sometimes this may require the use of certificates on your DC to allow TLS binds to them over TCP 636.

If the application has no way binding securely, throw it out. OK, sometimes thats not always possible, but if your application vendor won't provide a secure way to do LDAP binds, you will need to get a little extreme and encrypt the whole TCP stream between the application and DC using IPSEC with ESP. Thankfully most modern applications have some kind of ability to perform secure LDAP connections and we don't need to go this far.

Once you have cleaned up the main offenders (both by privilege and total count) you can repeat the diagnostics process for a little longer each time to track down the overnight scheduled tasks and processes and other connections that happen only periodically. It's a slow process but required before you block these binds entirely.
<h3>Conclusion</h3>
Hopefully you stop reading reading this post because your DC's "Require Signing" for their LDAP configuration. If not, you should now be well aware of the culprits in your environment and on your way to remediating them. In a future post I will explain the process of actually preventing these weak LDAP binds and also monitoring for applications still attempting them (and exposing their credentials in the process)

Russ]]></content:encoded>
    </item>
  </channel>
</rss>