repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
shadow-credentials.mdMarkdown75 lines4.8 KiBsource raw download

title: "Shadow Credentials" section: "Windows" sectionSlug: "windows-hardening" sourcePath: "src/windows-hardening/active-directory-methodology/acl-persistence-abuse/shadow-credentials.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/windows-hardening/active-directory-methodology/acl-persistence-abuse/shadow-credentials.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Shadow Credentials#

Intro #

Check the original post for all the information about this technique.[1]

In summary, control of a user's or computer's msDS-KeyCredentialLink can let an attacker add a key credential, authenticate as that object with PKINIT, and—when the KDC and account support the necessary flows—use the resulting ticket with S4U2Self/user-to-user to recover the object's NT hash.[1]

In the post, a method is outlined for setting up public-private key authentication credentials to acquire a unique Service Ticket that includes the target's NTLM hash. This process involves the encrypted NTLM_SUPPLEMENTAL_CREDENTIAL within the Privilege Attribute Certificate (PAC), which can be decrypted.[1]

Requirements#

To apply this technique, certain conditions must be met:[1]

Abuse#

The abuse of Key Trust for computer objects encompasses steps beyond obtaining a Ticket Granting Ticket (TGT) and the NTLM hash. The options include:[1]

  1. Creating an RC4 silver ticket to act as privileged users on the intended host.
  2. Using the TGT with S4U2Self for impersonation of privileged users, necessitating alterations to the Service Ticket to add a service class to the service name.

A significant advantage of Key Trust abuse is its limitation to the attacker-generated private key, avoiding delegation to potentially vulnerable accounts and not requiring the creation of a computer account, which could be challenging to remove.[1]

Tools#

### Whisker

Whisker uses DSInternals to manipulate msDS-KeyCredentialLink from C#. Whisker and its Python counterpart pyWhisker support adding, listing, removing, and clearing key credentials.[2][4]

Whisker functions include:

Whisker.exe add /target:computername$ /domain:constoso.local /dc:dc1.contoso.local /path:C:\path\to\file.pfx /password:P@ssword1

pyWhisker#

pyWhisker brings the workflow to UNIX-like systems with Impacket and PyDSInternals, including list/add/remove and JSON import/export operations.[4]

python3 pywhisker.py -d "domain.local" -u "user1" -p "complexpassword" --target "user2" --action "list"

ShadowSpray#

ShadowSpray enumerates domain objects over which the operator has rights such as GenericWrite/GenericAll, attempts to add key credentials broadly, and includes cleanup/recursive modes. Broad spraying is disruptive and conspicuous; use explicit targets and retain each added DeviceID for precise removal.[3]

References#