RDP - Remote Desktop Protocol

Khái niệm

Phát triển bởi Microsoft, RDP được thiết kế để cho phép kết nối giao diện đồ họa giữa các máy tính qua mạng. Để thiết lập kết nối như vậy RDP client software được sử dụng và đồng thời the remote computer được yêu cầu cần vận hành phần mềm RDP server. Thiết lập này cho phép kiểm soát và truy cập liền mạch môi trường desktop của máy tính ở xa, về cơ bản là đưa giao diện của nó đến thiết bị local của người dùng.

Default port: 3389

Khai thác

Enumeration

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

It checks the available encryption and DoS vulnerability (without causing DoS to the service) and obtains NTLM Windows info (versions).

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

Connect with known 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

Check known credentials against RDP services

rdp_check.py from impacket cho bạn biết một số thông tin xác thực có hợp lệ cho RDP service hay không:

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

Attacks

Sesion stealing

Với quyền System bạn có thể truy cập bất kỳ phiên RDP được mở nào mà không cần biết password của chủ sở hữu

Quan trọng: Khi truy cập vào một phiên RDP đang active, bạn sẽ kickoff user đang sử dụng phiên đó

Sticky-keys & Utilman

Kết hợp kỹ thuật trên vs stickykeys hoặc utilman bạn có thể truy cập CMD quản trị và bất kì phiên RDP anytime

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

Nếu ai đó từ một miền khác hoặc với đặc quyền cao hơn đăng nhập qua RDP tới PC nơi bạn là Admin, bạn có thể inject beacon của bạn vào trong RDP session process đó và hoạt động như người đó

https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/rdp-sessions-abuse

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

Detection:

Theo dõi log RDP Access:

Windows Advanced Audit Policy nên bật cách chính sách sau để thu thập sự kiện:

  • Logon/Logoff – Audit Logon = Success and Failed

  • Logon/Logoff – Other Logon/Logoff Events = Success and Failed

Logic query chứa nhiều thông tin chi tiết về mọi xác thực đối với hệ thống

  • Event Log = Security

  • Event ID = 4624 (success)

  • Event ID = 4625 (failed)

  • Logon Type = 10 (RDP)

  • Account Name = The user name logging off

  • Workstation Name = This will be from the log of system being logged off from

Logic query sau chứa một số chi tiết về xác thực phiên đối với hệ thống:

  • Event Log = Security

  • Event ID = 4778 (connect)

  • Event ID = 4779 (disconnect)

  • Account Name = The user name logging off

  • Session Name = RDP-Tcp#3

  • Client Name = This will be the system name of the source system making the RDP connection

  • Client Address = This will be the IP address of the source system making the RDP connection

Logic query sau chứa một số chi tiết về RDP connections tới hệ thống (Event ID 24 (disconnect) sẽ được tạo ngay sau khi xóa log và ngắt kết nối.):

  • Event Log = Microsoft-Windows-TerminalServices-LocalSessionManager

  • Event ID = 21 (RDP connect)

  • Event ID = 24 (RDP disconnect)

  • User = The user that made the RDP connection

  • Source Network Address = The system where the RDP connection originated

  • Message = The connection type

Ngoài ra:

Event Log = Microsoft-Windows-TerminalServices-RemoteConnectionManager

  • Event ID = 1149 (RDP connect)

  • User = The user that made the RDP connection

  • Source Network Address = The system where the RDP connection originated

Event Log = Microsoft-Windows-TerminalServices-RDPClient

  • Event ID = 1024 (RDP connection attempt)

  • Event ID = 1102 (RDP connect)

  • Message = The system where the RDP connection originated

https://research.nccgroup.com/2021/10/21/detecting-and-protecting-when-remote-desktop-protocol-rdp-is-open-to-the-internet/

Reduction/Prevention

Remote Desktop Gateway: cung cấp SSL (mã hóa RDP qua port TCP 443 và UDP 3391)

Virtual Private Network (VPN): Sử dụng RDP đằng sau VPN

Jump Host: Sử dụng jump host được bảo vệ bởi MFA để xác thực trước khi vào hệ thống nội bộ qua RDP

Cloud RDP: Sử dụng môi trường đám mây lưu trữ giải pháp từ xa cung cấp MFA để đảm bảo các kết nối đáng tin cậy trở lại tổ chức

Change the RDP Listening Port

Hạn chế IP Address

Last updated