Cached AD Credentials
Since Microsoft's implementation of Kerberos makes use of single sign-on, password hashes must be stored somewhere in order to renew a TGT request.
In modern versions of Windows, these hashes are stored in the Local Security Authority Subsystem Service (LSASS) memory space.
If we gain access to these hashes, we could crack them to obtain the cleartext password or reuse them to perform various actions.
Although this is the end goal of our AD attack, the process is not as straightforward as it seems. Since the LSASS process is part of the operating system and runs as SYSTEM, we need SYSTEM (or local administrator) permissions to gain access to the hashes stored on a target.
Because of this, we often have to start our attack with a local privilege escalation in order to retrieve the stored hashes. To make things even more tricky, the data structures used to store the hashes in memory are not publicly documented, and they are also encrypted with an LSASS-stored key.
Nevertheless, since the extraction of cached credentials is a large attack vector against Windows and Active Directory, several tools have been created to extract the hashes. The most popular of these tools is Mimikatz.
We start a PowerShell session as Administrator. From this command prompt, we can start Mimikatz and enter privilege::debug
to engage the SeDebugPrivlege privilege, which will allow us to interact with a process owned by another account.
PS C:\Windows\system32> cd C:\Tools
PS C:\Tools> .\mimikatz.exe ...
mimikatz # privilege::debug Privilege '20' OK
Now we can run sekurlsa::logonpasswords
to dump the credentials of all logged-on users with the Sekurlsa9 module.
This should dump hashes for all users logged on to the current workstation or server, including remote logins like Remote Desktop sessions.
mimikatz # sekurlsa::logonpasswords
The output above shows all credential information stored in LSASS for the domain users.
An effective defensive technique to prevent tools such as Mimikatz from extracting hashes is to enable additional LSA Protection. The LSA includes the LSASS process. By setting a registry key, Windows prevents reading memory from this process.
We can use Mimikatz to show the tickets that are stored in memory by entering sekurlsa::tickets
.
mimikatz # sekurlsa::tickets
Authentication Id : 0 ; 656588 (00000000:000a04cc)
Session : RemoteInteractive from 2
User Name : jeff
Domain : CORP
Logon Server : DC1
Logon Time : 9/13/2022 2:43:31 AM
SID : S-1-5-21-1987370270-658905905-1781884369-1105
* Username : jeff
* Domain : CORP.COM
* Password : (null)
Group 0 - Ticket Granting Service
The output shows both a TGT and a TGS. Stealing a TGS would allow us to access only particular resources associated with those tickets. Alternatively, armed with a TGT, we could request a TGS for specific resources we want to target within the domain.
Mimikatz can also export tickets to the hard drive and import tickets into LSASS
Before covering attacks on AD authentication mechanisms, let's briefly explore the use of Public Key Infrastructure (PKI) in AD. Microsoft provides the AD role Active Directory Certificate Services (AD CS) to implement a PKI, which exchanges digital certificates between authenticated users and trusted resources.
If a server is installed as a Certification Authority (CA), it can issue and revoke digital certificates (and much more). While a deep discussion on these concepts would require its own Module, let's focus on one aspect of cached and stored objects related to AD CS.
For example, we could issue certificates for web servers to use HTTPS or to authenticate users based on certificates from the CA via Smart Cards.
These certificates may be marked as having a non-exportable private key for security reasons. If so, a private key associated with a certificate cannot be exported even with administrative privileges. However, there are various methods to export the certificate with the private key.
We can rely again on Mimikatz to accomplish this. The crypto module contains the capability to either patch the CryptoAPI18 function with crypto::capi
or KeyIso service with crypto::cng
, making non-exportable keys exportable.
Last updated