# NTDS.DIT

**NTDS.DIT** 文件是域控制器上存储 AD 数据的数据库，包含了域内对象的所有信息，例如用户，组，计算机，以及其他对象。更重要的是，该文件还存储域中所有用户的密码哈希，包括域管理员的。该文件位于 **C:\\Windows\\NTDS\\ntds.dit**。

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-05/scaled-1680-/RrYkP0MPtKbG2ciM-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-05/RrYkP0MPtKbG2ciM-image.png)

在获得特定权限后，我们可以通过以下方式利用：

##### **复制 NTDS.DIT 文件**

在获得了域管理员之后，我们可以在域控制器上复制 NTDS.DIT 文件。但是类似于复制 SAM 数据库，因为 NTDS.DIT 在被实时使用，因此是被锁定的状态。我们依旧可以通过**卷影拷贝技术**来获得 NTDS.DIT文件。

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-05/scaled-1680-/H8CcTE0LUxWNdsC9-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-05/H8CcTE0LUxWNdsC9-image.png)

下载 **C:\\Windows\\System32\\Config\\SYSTEM** 以及 **C:\\Windows\\NTDS\\ntds.dit**。

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-05/scaled-1680-/b1i8avM2gYlvjkMB-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-05/b1i8avM2gYlvjkMB-image.png)

最后使用 Impacket 中的 secretdump 来离线解析

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-05/scaled-1680-/tFkxYHr7vvZ8UDTJ-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-05/tFkxYHr7vvZ8UDTJ-image.png)

##### **使用工具远程导出**

有了域管理员的凭证后，我们可以使用诸如 impacket 之类的工具通过 RPC 协议远程导出 NTDS.DIT 中的哈希。

[![image.png](https://raven-medicine.com/uploads/images/gallery/2023-05/scaled-1680-/uV8euuIaySfnNBSn-image.png)](https://raven-medicine.com/uploads/images/gallery/2023-05/uV8euuIaySfnNBSn-image.png)