certsync Research

certsync Research

Summary

A new technique has been discovered for remotely dumping passwords from a Domain Controller without needing to use the commonly abused API for the Directory Replication Service (DRSUAPI).

Abuse of the DRSUAPI is a well-known attack and by removing the need to use this mechanism the certsync tool is able to dump password hashes in a new way.

There is no privilege escalation within this tool or technique and therefore an attacker needs to already be in a position with Certificate Admin or Domain Admin rights. When the tool is run successfully every NTLM password hash in AD can be dumped to a text file.

This is another example of an attack technique that relies on abusing the older and less secure NTLM authentication mechanism.

Attack Flow

The tool uses the following steps:

  1. Creates a list of all user accounts, Certificate Authorities (CA) from LDAP
  2. Dumps the CA certificate and private key using the Certificate Admin or Domain Admin credentials supplied
  3. Locally forges certificate for every user
  4. Uses a technique to retrieve the hash from the Privileged Attribute Certificate (PAC). This is done for every user in the domain by default
  5. Outputs the NTLM password hash for re-use later

Technical Details

Run Certsync

Once setup certsync only needs to be supplied with credentials and have access to the victim/test environment.

No alt text provided for this image
certsync running with default parameters

As can be seen above we need to supply the following on the command line for this work;

We then get an output of all the NTLM hashes for all users by default. However, we can use the -ldap-filter flag to restrict which accounts we retrieve the password hash for. In the example below we only target the Domain Admin users, this makes the tool a tiny bit stealthier but not by much.

No alt text provided for this image


No alt text provided for this image
certsync only dumping the password hashes for Domain Admin users

Current Detections

No alt text provided for this image

This is not a stealthy technique and produces a significant amount of log artifacts on your Domain Controllers. For an environment with 88 user accounts our detections generated 98 alerts across 11 distinct detections. Below are the detections that were triggered.

No alt text provided for this image
Log Based Detections

Detection Example for Command Line Logging

Below is an example alarm that was triggered as part of our testing and shows the SYSTEM account is actually responsible for the certificate key backup on the CA, not the initially compromised user.

No alt text provided for this image

Logs

The two most important log types for this detection are command line logging and Kerberos auditing.

4769 A Kerberos service ticket was requested

Used to detect the various Kerberos tickets an attacker attempts to request once they have the certificate.

4768 A Kerberos authentication ticket (TGT) was requested

Used to detect the various Kerberos tickets an attacker attempts to request once they have the certificate.

4688 New Process Created

This can be used to see the abnormal Command Prompt being spawned from services.exe. It can also be used to detect the backup of the certificates.

Logs from Attacking IP

Below we can see a snapshot of the logs coming from our attacking IP address of 10.1.1.60. There is a huge amount of logs related to Kerberos and they are being generated for numerous accounts in our environment.

No alt text provided for this image

Other Detections

Defender for Identity

A product which is being more commonly deployed is Microsoft Defender for Identity. This is installed on all Domain Controllers within an environment. From there it can assist with detecting various AD abuses and when correlated with other logs and alarms can be a powerful detection engine.

Below are the specific Defender for Identity alerts that triggered when the certsync tool was run.

No alt text provided for this image
Defender for Identity Alerts

Detection Quality

The majority of the detections for this technique are directly related to the TTP and behaviors inherent in its use. Therefore, an attacker using this will have a difficult time in hiding their true behavior.

No alt text provided for this image

The bolded detections are the new ones created as part of this research. The non-bolded are part of the standard Seamless Intelligence ruleset.

References

Attack Tool

https://github.com/zblurx/certsync

UnPAC the hash

https://www.thehacker.recipes/ad/movement/kerberos/unpac-the-hash

DRSUAPI

https://blogs.manageengine.com/it-security/2020/09/29/advanced-active-directory-attacks-simulating-domain-controller-behavior.html

What Is the Kerberos PAC?

https://blog.netwrix.com/2023/01/10/what-is-the-kerberos-pac/

Great breakdown and explanation of that new technique Tristan

To view or add a comment, sign in

More articles by Tristan Bennett

  • Command Obfuscation

    Recently a great resource was released for command obfuscation - https://argfuscator.net/ Which came about from a…

  • CVE-2022-26923 - Attack and Detections

    SUMMARY Microsoft released a patch for an issue that can be exploited within a Domain environment running Certificate…

    1 Comment
  • Playing With Empire 3 - Part 2

    Updated - Setup Kali 2020 & Empire 3 BC-SECURITY took over development of Empire sometime in 2019 and have continued to…

  • Mining With SQLs

    RDP, NSSM, Install.bat, Update.

  • Playing With Empire - Part 1

    Even though Empire is no longer being actively developed, it's still well worth having in your development/research…

  • PowerShell Script Block Logging

    PowerShell’s “Script Block Logging” is still so trivial to bypass, so for anyone playing with post exploitation tools…

Others also viewed

Explore content categories