sentence
stringlengths
1
13.5k
labels
listlengths
0
15
doc_title
stringclasses
84 values
As indicated earlier, attackers have long been abusing Windows legitimate features like SMB, RPC over SMB, Windows Management Instrumentation, Windows Remote Management, and many other features to perform lateral movement activities.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 1 below highlights where lateral movement falls within the attack chain and its different stages.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
To remain stealthier, these activities would span a period ranging from many weeks to months.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 1 – Stages of Lateral movement To be able to distinguish between the admissible and malicious use of these inbuilt services, it is extremely critical for organizations to deploy advanced Threat Detection solutions.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Over the course of this blog, we will discuss various credential theft techniques used by adversaries during lateral movement.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
We will also discuss an approach that can be used to effectively detect these techniques inside the network.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Credential Theft Attacks Attackers use a variety of tools and techniques to execute credential theft attacks.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Many of these tools are open source and readily available on the internet.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Operating systems like Windows implement Single Sign
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
On (SSO) functionality, which require the user’s credentials to be stored in memory, thereby allowing the OS to seamlessly access network resource without repeatedly asking the user to re-enter those credentials.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Additionally, user credentials are stored in memory in a variety of formats like NTLM hashes, reversibly encrypted plaintext, Kerberos tickets, PINs, etc., which can be used to authenticate to services depending upon the supported authentication mechanism.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These credentials can be acquired by attackers from memory by parsing appropriate credential storage structures or using the Windows credential enumeration APIs.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Consequently, these attacks pose major security concerns, especially in the domain environment if the attacker gains access to privileged credentials which can then be reused to access critical network resources.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
In the following sections, we discuss some of the widely adapted credential stealing techniques used by malware, with respect to the Windows operating system.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Similar credential stealing techniques can also be used with other operating systems as well.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Stealing Credentials from LSASS Process Memory The Local Security Authority Subsystem Service (LSASS) process manages and stores the credentials of all the users with active Windows sessions.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These credentials stored in the LSASS process memory will allow users to access other network resource such as files shares, email servers and other remote services without asking them for the credentials again.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
LSASS process memory stores the credentials in many formats including reversibly encrypted plaintext, NTLM hashes, Kerberos Tickets (Ticket Granting Tickets, etc.).
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These credentials are generated and stored in the memory of the LSASS process when a user initiates the interactive logon to the machine such as console logon or RDP, runs a scheduled task or uses remote administration tools.
[ "T1003.001", "T1053.005" ]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The encryption and decryption of credentials is done using LsaProtectMemory and LsaUnProtectMemory respectively and hence a decryption tool using these APIs will be able to decrypt LSASS memory buffers and extract them.
[ "T1140" ]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
However, malware would need to execute with local administrator privileges and enable “SeDebugPrivilege” on the current process to be able access the LSASS process memory.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Below is a code snapshot from one of the famous credential harvesting tools, Mimikatz, enabling the required privileges on the calling thread before dumping the credentials.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 2 – Checking for required privileges We can see that the NTLM hash of the user’s credentials is revealed, and this can be brute forced offline as shown below.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Many Windows services, such as SMB, support NTLM authentication and NTLM hashes can be used directly for authentication eliminating the need for the clear text passwords.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 3 – Cracking NTLM Hashes offline Attackers avoid using freely available tools like Mimikatz directly on the target machine to harvest credentials since they are easily detected by AVs.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Instead, they use recompiled clones of it with minimal functionality to avoid noise.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Below is one such instance where malware embeds recompiled Mimikatz code with the minimal required functionality.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 4 – Credential extraction tool embedded inside malicious executable Detection can also be avoided by using several “living off the land’ mechanisms, available in many post-exploitation frameworks, to execute the credential harvesting tools directly from memory using Reflective PE injection, where the binary is n...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Yet another approach is to dump the LSASS process memory using process dumping tools, exfiltrate the dump and extract the credentials offline.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Microsoft has documented multiple ways to configure additional LSASS process protection which can prevent credentials being compromised.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Stealing Credentials from Security Accounts Manager (SAM) Database The SAM database is a file on a local hard drive that stores the credentials for all local accounts on the Windows computer.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
NT hashes for all the accounts on the local machine, including the local administrator credential hash, are stored in the SAM database.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The SAM database file is in %SystemRoot%system32/config and the hashes of the credentials are within the registry HKLM\SAM.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Attackers need to acquire elevated privileges to be able to access the credentials from the SAM database.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The example below demonstrates how the credentials from the SAM database can be revealed through a simple Meterpreter session.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 5 – Dumping SAM database Stealing Credentials from Windows Credential Manager (CredMan) Windows Credential Manager stores the Web and SMB/RDP credentials of users if they choose to save them on the Windows machine, thereby preventing the authentication mechanism from asking for those passwords again on subsequen...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These credentials are encrypted with Windows Data Protection APIs (DPAPI) CryptProtectData, either using the current user’s logon session or a generated master key, and then saved on the local hard drive.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Consequently, any process running in the context of the logged in user will be able to decrypt the credentials using CryptUnProtectData DPAPI.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
In the domain environment, these credentials can be used by attackers to pivot to other systems in the network.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Data Protection APIs provide the cryptographic functionalities that can be used to securely store credentials and keys.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These APIs are used by several other Windows components like browsers (IE/Chrome), certificates and many other applications as well.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Below is one example of how credential dumping tools like Mimikatz can be used to dump stored Chrome credentials.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 6 – Dumping browser credentials DPAPI can be abused in multiple ways.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
In the Active Directory domain joined environment, if other users have logged into the compromised machine, provided a malware is running with escalated privileges, it can extract other user’s master keys from the LSASS memory which can then be used to decrypt their secrets.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Below is a screenshot of how the master key can be extracted by using the credential dumping tool.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 7 – Extracting DPAPI Master Key Malware also tends to use multiple variants of credential enumeration APIs available within Windows.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These APIs can extract credentials from Windows Credential Manager.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Below is one instance of the malware using CredEnumerateW API to retrieve credentials and then search for terminal services passwords which It would use to pivot to other systems.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 8 – Extracting credentials using Windows API Stealing Service Account Credentials Through Kerberoasting In the domain joined environment, the Kerberos protocol has a significant role to play with respect to authentication and requesting access to services and applications.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
It provides Single-Sign-On functionality for accessing multiple shared resources within the enterprise network.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The Kerberos authentication mechanism in Active Directory involves multiple requests and responses like Ticket Granting Ticket (TGT) and Ticket Granting Service (TGS) supported by a Key Distribution Server (KDC), usually a Domain Controller.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Upon successful authentication, a user will be able to access the respective services.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Attackers gaining access to a system joined in the domain would usually look for high value assets like Active Directory Controller, Database server, SharePoint server, Web Server, etc., and these services are registered in the domain with the specific Service Principal Name (SPN) values, which is a unique identifier o...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These SPN values are used by Kerberos to map the instance with the logon account allowing the client to authenticate to the respective service.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Well known SPN values are listed out here.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Once the attacker is authenticated with any domain user credentials and has information about the SPN values of the services within the domain, they can initiate the Kerberos Ticket Granting Service request (TGS – REQ) to the Key Distribution Server with the specified SPN value.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Details on how the SPN values are registered and used in Kerberos authentication is documented here.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
TGS response from the KDC will have the Kerberos Ticket encrypted with the hash of the service account.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
This ticket can be extracted from the memory and can be brute forced offline to acquire service account credentials, allowing a domain user to gain admin level access to the service.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Kerberoasting is a well-documented attack technique listed in MITRE ATT&CK and it essentially abuses the Kerberos authentication allowing adversaries to request the TGS Tickets for the valid service accounts and brute force the ticket offline to extract the plain text credentials of the service accounts, consequently e...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
As an initial step to this lateral movement technique, the attacker would perform an internal reconnaissance to gain information about the services registered in the domain and get SPN values.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
A simple PowerShell command after importing the Active Directory PowerShell module, as shown below, can initiate the LDAP query to get information about all the user accounts from the Domain Controller with the SPN value set. Figure 9 – PowerShell command to generate LDAP query Attackers can specifically choose to scan...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
PowerShell scripts like GetUserSPNs can scan all the user SPNs in the domain or MSSQL service registered in the domain with Discover-PSMSSQLServers or Invoke-Kerberoast scripts.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Following is an example output from the script:
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 10 – Kerberoasting PowerShell script output Once an attacker has the SPN value of the SQL service, a Kerberos Ticket Granting Service Ticket request (TGS-REQ) can be initiated to the domain controller with the SPN value.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
This can be done by a couple of PowerShell commands generating KRB-TGS-REQ as shown below: Figure 11 – Kerberos TGS request Consequently, the Domain Controller sends the TGS-RESP with the ticket of the service account which will be cached in the memory and can be extracted by dumping tools like Mimikatz as a .kirbi doc...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
This can be brute forced offline by tgsrespcrack, allowing the attacker to gain unrestricted access to the service with elevated privileges.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Stealing Credentials from Active Directory Domain Service (ntdis.dit) File As indicted earlier, once an attacker has penetrated the domain network, it will be natural to progress towards targeting critical assets, such as the Active Directory controller.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The Active Directory Database Services AD DS Ntds.dit file is one of the most overlooked attack vectors in the domain environment but can have significant impact if the attacker is able to gain the domain administrative rights leading to complete domain compromise.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The Ntds.dit file is the authoritative store of credentials for all the users in the domain joined environment, storing all the information about the users, groups and memberships, including credentials (NT Hashes) of all the users in the domain with historical passwords and user’s DPAPI backup master keys.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
An Attacker with domain admin rights can gain access to the Domain Controller’s file system and acquire credentials like hashes, Kerberos tickets and other reversibly encrypted passwords of all the users joined in the domain by dumping and exfiltrating the Ntds.dit file.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
These credentials can then be used by the attacker to further access resources by using attack techniques like PTH within the network since the credentials used across other shared resource could be same.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Multiple techniques can be used to dump the Ntds.dit file from the Domain Controller locally as well as remotely and extract the NTLM hashes/DPAPI backup keys for all the domain joined users.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
One of the techniques is to use the Volume Shadow Copy Service using the vssadmin command line utility and then extract the Ntds.dit file from the volume shadow copy as shown below.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 12 – Dumping Volume shadow copy for C drive Sensitive data on Active Directory is encrypted with the Boot Key (Syskey) stored in the SYSTEM registry hive and dumping the SYSTEM registry hive is a prerequisite as well to be able to extract all the credentials.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Publicly available Active Directory auditing frameworks like DSInternals provide PowerShell cmdlets to extract the Syskey from the SYSTEM registry hive and extract all the credentials from the Ntds.dit file.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Ntds.dit can also give access to the powerful service account within the Active Directory Domain, KRBTGT (Key Distribution Centre Service account).
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Acquiring the NTLM hash of this account can enable the attacker to execute a Golden Ticket attack leading to complete domain compromise with unrestricted access to any service on the domain joined system.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Stealing Credentials Through a DCSync Attack – From Domain user to Domain Admin A DCSync attack is a method of credential acquisition which allows an attacker to impersonate the Domain Controller and can consequently replicate all the Active Directory objects to the impersonating client remotely, without requiring the ...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
By impersonating the Domain Controller, the attacker could acquire the NTLM hash of the KRBTGT service account, enabling them to gain access to all the shared resources and applications in the domain joined environment.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
To be able to execute this credential stealing technique, an attacker would have to compromise the user account with the required permissions, specifically DS-Replication-Get-Changes and DS-Replication-Get-Changes-All, as shown below.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 13 – User with privileges Once the attacker compromises the user account with the required privileges, Pass-The-Hash attacks can be executed to spawn a command shell with the forged logon session.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Credential dumping tools like Mimikatz do this by enumerating all the user logon sessions and replacing the user credentials with the stolen usernames and NTLM hashes provided, in the current logon session.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Behind the scenes, this is executed by duplicating the current process’s access token, replacing the user credentials pointed by duplicated access token and subsequently using the modified access token to start a new process with the stolen credentials which will be used for network authentication.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
This is as shown below for example user “DCPrivUser”.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 14 – Pass-the-Hash attack Further, as indicated below, any subsequent NTLM authentication from the logon session will use the stolen credentials to authenticate to domain joined systems like the Active Directory Controller.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Attackers can now initiate the AD user objects Replication request to the Domain Controller using Directory Replication Services Remote Protocol (DRSUAPI).
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
DRSUAPI is the RPC protocol used for replication of AD objects.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
With DCERPC bind request to DRSUAPI, an RPC call to DSGetNCChanges will replicate all the user AD objects to the impersonating client.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Attackers would usually target the KRBTGT account since acquiring the NTLM hash of this account will enable them to execute a Golden Ticket attack resulting in unrestricted access to domain services and applications.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 15 – DCSync Attack As indicated earlier, with the NTLM hash of the KRBTGT account, adversaries can initiate a Golden Ticket attack (Pass-the-Ticket) by injecting the forged Kerberos tickets into the current session which can be used to authenticate to any service with the client that supports pass the ticket (fo...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Figure 16 – Golden ticket with forged Kerberos ticket Detecting Credential Stealing Attacks with Network Deception
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
The credential theft techniques we discussed in the previous sections are just the tip of the iceberg.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Adversaries can use many other sophisticated credential stealing techniques to take advantage of system misconfigurations and legitimate administrative tools and protocols and, at the same time, remain undetected for a longer period.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
With many other event management solutions with SIEMs, used in conjunction with other network security solutions, it becomes a challenge for administrators to distinguish malicious use of legitimate tools and services from lateral movement.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Perimeter solutions have their limitations in terms of visibility once the attacker crosses the network boundary and is inside the domain environment.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
It is extremely critical for organizations to protect and monitor critical network assets like the Domain Controller, Database server, Exchange Servers, build systems and other applications or services, as compromising these systems will result in significant damages.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Therefore, enterprise networks must deploy a solution to detect credential stealing attacks as they can be used to pivot to other systems on the network and move laterally once an attacker establishes an attack path to a high value target.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
If the deployment of a solution within the critical zones of the network can detect the use of stolen credentials before adversaries can reach their target, the critical assets could still be prevented from being compromised.
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense
Network Deception is one such deployment within the domain environment where, using the MITRE Shield techniques like decoy systems and network, decoy credentials, decoy accounts, decoy contents, could potentially help detect lateral movement early in the adversary’s attack path to the target asset and at the same time,...
[]
Detecting Credential Stealing Attacks Through Active InNetwork Defense