🕶️
VICEINTELPRO
GitHub: HorrorClause
  • In Tenebris Videmus
  • 🚩CTFs
    • 💾Hack the Box
      • 🏫Academy
        • Command Injection Assessment
        • XSS Assessment
        • Web Attacks Assessment
    • Try Hack Me
      • In Progress
  • 📖Documents
  • 👨‍🏫HOW-TOs
    • Obisidian How-To
    • Setup Mandiant FLARE VM
  • 📑Security Fundamentals
    • Security Controls
      • Physical Security
      • Endpoint Security
      • Email Security
      • Network Security
      • AAA Controls
    • Networking 101
      • OSI Model
      • Network Fundamentals
      • Network Devices
      • Network Tools
      • Protocols and Ports
    • 👨‍💼Management Principles
      • Risk
      • Policies and Procedures
      • Compliance and Frameworks
      • Change and Patch Management
  • 🛡️Security Concepts
    • ⚠️Risk Assessment Models
      • DREAD Risk Assessment Model
      • STRIDE Threat Model
      • Common Vulnerability Scoring System (CVSS)
    • Pentesting
      • Common Terms
      • AV Identification-Evasion
      • Introduction to Payloads
      • Automating Payloads & Delivery with Metasploit
      • Shells Jack Us In, Payloads Deliver Us Shells
      • Web Shells
      • Pentesting Overview
      • Penetration Testing Process
    • 🐛Vulnerability Assessment
      • Common Vulnerabilities and Exposures (CVE)
      • Common Vulnerability Scoring System (CVSS)
      • Assessment Standards
      • Vulnerability Assessment
      • Vulnerability Scanning
      • Reporting
      • 🎯Nessus
        • Getting Started with Nessus
        • Nessus Scan
        • Working with Nessus Scan Output
        • Advanced Settings
        • Scanning Issues
      • 🦴OpenVAS (Greenbone)
        • Getting Started with OpenVAS
        • OpenVAS
        • Exporting Results
    • Passwords
      • Password Managers
      • Password Policies
      • Password Security Fundamentals
    • Frameworks
    • GRC
    • Logon Types
    • What is Dev-Null ?
  • ⚔️Offensive Security
    • OSINT
      • OSINT - Websites
      • Google Dorks
    • 🔫Attacking Common Services
      • The Concept of Attacks
      • Interacting with Common Services
      • Finding Sensitive Information
      • Attacking DNS
      • Attacking Email Services
      • Attacking FTP
      • Attacking RDP
      • Attacking SMB
      • Attacking SQL Databases
      • Cheat Sheet - Attacking Common Services
      • Service Misconfigurations
    • 🔪Attacking Web Apps with Ffuf
      • Web Fuzzing
      • Directory Fuzzing
      • Page Fuzzing
      • Recursive Fuzzing
      • DNS Records
      • Sub-domain Fuzzing
      • Vhost Fuzzing
      • Filtering Results
      • Parameter Fuzzing - GET
      • Parameter Fuzzing - POST
      • Value Fuzzing
    • ☁️Cloud
      • AWS
        • AWS S3 Buckets
    • 💉Command Injection
      • Command Injection Cheat Sheet
      • Intro to Command Injections
      • Detection
      • Injecting Commands
      • Other Injection Operators
      • Identifying Filters
      • Bypassing Space Filters
      • Bypassing Other Blacklisted Characters
      • Bypassing Blacklisted Commands
      • Advanced Command Obfuscation
      • Evasion Tools
      • Command Injection Prevention
    • Containers
      • Docker
    • ❌Cross-Site Scripting (XSS)
      • Introduction to XSS
      • Stored XSS
      • Reflected XSS
      • DOM XSS
      • XSS Discovery
      • Defacing
      • Phishing
      • Session Hijacking
      • XSS Prevention
    • Directory Busting
      • DirB
      • DirBuster
      • Ffuf
      • Gobuster
    • 🅰️DNS
      • DNSRecon
      • Fierce
    • File Inclusion
      • Local File Inclusion Cheatsheet
      • Intro to File Inclusion
      • Local File Inclusion (LFI)
      • Basic Bypass
      • PHP Filters
      • PHP Wrappers
      • Remote File Inclusion (RFI)
      • LFI and File Uploads
      • Log Poisoning
      • Automated Scanning
      • File Inclusion Prevention
    • File Transfers
      • Transferring Files
      • File Transfer - Quick Commands
      • Living off the Land
      • Windows File Transfer Methods
      • Linux File Transfer Methods
      • Catching Files over HTTP(S)
      • Transferring Files with Code
      • Miscellaneous File Transfer Methods
      • Protected File Transfers
      • Mounting Encrypted VHD Drives
      • Mounting VHD in Kali
      • File Transfer Detection
    • File Upload Attacks
      • File Upload Cheatsheet
      • Absent Validation
      • Upload Exploitation
      • Client-Side Validation
      • Blacklist Filters
      • Whitelist Filters
      • Type Filters
      • Limited File Uploads
      • Other Upload Attacks
      • Preventing File Upload Vulnerabilities
    • 👣Footprinting
      • Linux Remote Management Protocols
      • Windows Remote Management Protocols
      • Enumeration
        • Enumeration Methodology
        • 🖥️Host Based
          • Quick Commands
          • DNS
          • FTP
          • IMAP-POP3
          • IPMI
          • MSSQL
          • MySQL
          • NFS
          • Oracle TNS
          • SMB
  • Powershell
    • Powershell CheatSheet
  • Python
    • Map
    • Anonymous Functions
    • Recursion
      • ZipMap
      • Nested Sum
      • Recursion on a Tree
      • Count Nested Levels
      • Longest Word
    • Function Transformations
      • More Transformations
      • Why Transform?
    • Closures
    • Currying
    • Decorators
    • Sum Types
    • Enums
    • Match
    • Regex
  • Kusto (KQL)
    • SQL and KQL Comparison
    • Using the Where and Sort Operators
    • KQL Queries
  • HTML
  • Insecure File Uploads
Powered by GitBook
On this page
  • RDP
  • Footprinting the Service
  • WinRM
  • Footprinting the Service
  • WMI
  • Footprinting the Service
  1. Offensive Security
  2. Footprinting

Windows Remote Management Protocols

PreviousLinux Remote Management ProtocolsNextEnumeration

Last updated 3 months ago

Related Sites:

Windows servers can be managed locally using Server Manager administration tasks on remote servers. Remote management is enabled by default starting with Windows Server 2016. Remote management is a component of the Windows hardware management features that manage server hardware locally and remotely. These features include a service that implements the WS-Management protocol, hardware diagnostics and control through baseboard management controllers, and a COM API and script objects that enable us to write applications that communicate remotely through the WS-Management protocol.

The main components used for remote management of Windows and Windows servers are the following:

  • Remote Desktop Protocol (RDP)

  • Windows Remote Management (WinRM)

  • Windows Management Instrumentation (WMI)

RDP


Port:3389

The (RDP) is a protocol developed by Microsoft for remote access to a computer running the Windows operating system. This protocol allows display and control commands to be transmitted via the GUI encrypted over IP networks. RDP works at the application layer in the TCP/IP reference model, typically utilizing TCP port 3389 as the transport protocol. However, the connectionless UDP protocol can use port 3389 also for remote administration.

For an RDP session to be established, both the network firewall and the firewall on the server must allow connections from the outside. If (NAT) is used on the route between client and server, as is often the case with Internet connections, the remote computer needs the public IP address to reach the server. In addition, port forwarding must be set up on the NAT router in the direction of the server.

RDP has handled (TLS/SSL) since Windows Vista, which means that all data, and especially the login process, is protected in the network by its good encryption. However, many Windows systems do not insist on this but still accept inadequate encryption via . Nevertheless, even with this, an attacker is still far from being locked out because the identity-providing certificates are merely self-signed by default. This means that the client cannot distinguish a genuine certificate from a forged one and generates a certificate warning for the user.

The Remote Desktop service is installed by default on Windows servers and does not require additional external applications. This service can be activated using the Server Manager and comes with the default setting to allow connections to the service only to hosts with (NLA).

Footprinting the Service

Scanning the RDP service can quickly give us a lot of information about the host. For example, we can determine if NLA is enabled on the server or not, the product version, and the hostname.

Nmap

d3lvx@htb[/htb]$ nmap -sV -sC 10.129.201.248 -p3389 --script rdp*  

Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-06 15:45 CET 
Nmap scan report for 10.129.201.248 
Host is up (0.036s latency).  

PORT     STATE SERVICE       VERSION 
3389/tcp open  ms-wbt-server Microsoft Terminal Services 
| rdp-enum-encryption:  
|   Security layer 
|     CredSSP (NLA): SUCCESS 
|     CredSSP with Early User Auth: SUCCESS 
|_    RDSTLS: SUCCESS 
| rdp-ntlm-info:  
|   Target_Name: ILF-SQL-01 
|   NetBIOS_Domain_Name: ILF-SQL-01 
|   NetBIOS_Computer_Name: ILF-SQL-01 
|   DNS_Domain_Name: ILF-SQL-01 
|   DNS_Computer_Name: ILF-SQL-01 
|   Product_Version: 10.0.17763 
|_  System_Time: 2021-11-06T13:46:00+00:00 
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows  

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 8.26 seconds

d3lvx$ nmap -sV -sC 10.129.201.248 -p3389 --packet-trace --disable-arp-ping -n  

Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-06 16:23 CET 
SENT (0.2506s) ICMP [10.10.14.20 > 10.129.201.248 Echo request (type=8/code=0) id=8338 seq=0] IP [ttl=53 id=5122 iplen=28 ] 

SENT (0.2507s) TCP 10.10.14.20:55516 > 10.129.201.248:443 S ttl=42 id=24195 iplen=44  seq=1926233369 win=1024 <mss 1460> 

SENT (0.2507s) TCP 10.10.14.20:55516 > 10.129.201.248:80 A ttl=55 id=50395 iplen=40  seq=0 win=1024 

SENT (0.2517s) ICMP [10.10.14.20 > 10.129.201.248 Timestamp request (type=13/code=0) id=8247 seq=0 orig=0 recv=0 trans=0] IP [ttl=38 id=62695 iplen=40 ] 

RCVD (0.2814s) ICMP [10.129.201.248 > 10.10.14.20 Echo reply (type=0/code=0) id=8338 seq=0] IP [ttl=127 id=38158 iplen=28 ] 

SENT (0.3264s) TCP 10.10.14.20:55772 > 10.129.201.248:3389 S ttl=56 id=274 iplen=44  seq=2635590698 win=1024 <mss 1460> 

RCVD (0.3565s) TCP 10.129.201.248:3389 > 10.10.14.20:55772 SA ttl=127 id=38162 iplen=44  seq=3526777417 win=64000 <mss 1357> 

NSOCK INFO [0.4500s] nsock_iod_new2(): nsock_iod_new (IOD \#1) 
NSOCK INFO [0.4500s] nsock_connect_tcp(): TCP connection requested to 10.129.201.248:3389 (IOD \#1) EID 8 
NSOCK INFO [0.4820s] nsock_trace_handler_callback(): Callback: CONNECT SUCCESS for EID 8 [10.129.201.248:3389] Service scan sending probe NULL to 10.129.201.248:3389 (tcp) 
NSOCK INFO [0.4830s] nsock_read(): Read request from IOD \#1 [10.129.201.248:3389] (timeout: 6000ms) EID 18 
NSOCK INFO [6.4880s] nsock_trace_handler_callback(): Callback: READ TIMEOUT for EID 18 [10.129.201.248:3389] Service scan sending probe TerminalServerCookie to 10.129.201.248:3389 (tcp) 
NSOCK INFO [6.4880s] nsock_write(): Write request for 42 bytes to IOD \#1 EID 27 [10.129.201.248:3389] 
NSOCK INFO [6.4880s] nsock_read(): Read request from IOD \#1 [10.129.201.248:3389] (timeout: 5000ms) EID 34 
NSOCK INFO [6.4880s] nsock_trace_handler_callback(): Callback: WRITE SUCCESS for EID 27 [10.129.201.248:3389] 
NSOCK INFO [6.5240s] nsock_trace_handler_callback(): Callback: READ SUCCESS for EID 34 [10.129.201.248:3389] (19 bytes): .........4......... 

Service scan match (Probe TerminalServerCookie matched with TerminalServerCookie line 13640): 10.129.201.248:3389 is ms-wbt-server.  Version: |Microsoft Terminal Services|||  

...SNIP...  

NSOCK INFO [6.5610s] nsock_write(): Write request for 54 bytes to IOD \#1 EID 27 [10.129.201.248:3389] NSE: TCP 10.10.14.20:36630 > 10.129.201.248:3389 | 00000000: 03 00 00 2a 25 e0 00 00 00 00 00 43 6f 6f 6b 69    *%      Cooki 00000010: 65 3a 20 6d 73 74 73 68 61 73 68 3d 6e 6d 61 70 e: mstshash=nmap 00000020: 0d 0a 01 00 08 00 0b 00 00 00    

...SNIP...  

NSOCK INFO [6.6820s] nsock_write(): Write request for 57 bytes to IOD \#2 EID 67 [10.129.201.248:3389] 
NSOCK INFO [6.6820s] nsock_trace_handler_callback(): Callback: WRITE SUCCESS for EID 67 [10.129.201.248:3389] 
NSE: TCP 10.10.14.20:36630 > 10.129.201.248:3389 | SEND 
NSOCK INFO [6.6820s] nsock_read(): Read request from IOD \#2 [10.129.201.248:3389] (timeout: 5000ms) EID 74 
NSOCK INFO [6.7180s] nsock_trace_handler_callback(): Callback: READ SUCCESS for EID 74 [10.129.201.248:3389] (211 bytes) 
NSE: TCP 10.10.14.20:36630 < 10.129.201.248:3389 |  
00000000: 30 81 d0 a0 03 02 01 06 a1 81 c8 30 81 c5 30 81 0          0  0 
00000010: c2 a0 81 bf 04 81 bc 4e 54 4c 4d 53 53 50 00 02        NTLMSSP 
00000020: 00 00 00 14 00 14 00 38 00 00 00 35 82 8a e2 b9        8   5 
00000030: 73 b0 b3 91 9f 1b 0d 00 00 00 00 00 00 00 00 70 s              p 
00000040: 00 70 00 4c 00 00 00 0a 00 63 45 00 00 00 0f 49  p L     cE    I 
00000050: 00 4c 00 46 00 2d 00 53 00 51 00 4c 00 2d 00 30  L F - S Q L - 0 
00000060: 00 31 00 02 00 14 00 49 00 4c 00 46 00 2d 00 53  1     I L F - S 00000070: 00 51 00 4c 00 2d 00 30 00 31 00 01 00 14 00 49  Q L - 0 1     I 00000080: 00 4c 00 46 00 2d 00 53 00 51 00 4c 00 2d 00 30  L F - S Q L - 0 00000090: 00 31 00 04 00 14 00 49 00 4c 00 46 00 2d 00 53  1     I L F - S 000000a0: 00 51 00 4c 00 2d 00 30 00 31 00 03 00 14 00 49  Q L - 0 1     I 000000b0: 00 4c 00 46 00 2d 00 53 00 51 00 4c 00 2d 00 30  L F - S Q L - 0 000000c0: 00 31 00 07 00 08 00 1d b3 e8 f2 19 d3 d7 01 00  1 000000d0: 00 00 00  ...SNIP...

RDP Security Check - Installation

d3lvx@htb[/htb]$ sudo cpan  

Loading internal logger. Log::Log4perl recommended for better logging  

CPAN.pm requires configuration, but most of it can be done automatically. If you answer 'no' below, you will enter an interactive dialog for each configuration option instead.  

Would you like to configure as much as possible automatically? [yes] yes   

Autoconfiguration complete.  

commit: wrote '/root/.cpan/CPAN/MyConfig.pm'  

You can re-run configuration any time with 'o conf init' in the CPAN shell  

cpan shell -- CPAN exploration and modules installation (v2.27) Enter 'h' for help.   

cpan[1]> install Encoding::BER  

Fetching with LWP: 
http://www.cpan.org/authors/01mailrc.txt.gz 
Reading '/root/.cpan/sources/authors/01mailrc.txt.gz' ............................................................................DONE ...SNIP...

RDP Security Check

d3lvx@htb[/htb]$ git clone https://github.com/CiscoCXSecurity/rdp-sec-check.git && cd rdp-sec-check $ ./rdp-sec-check.pl 10.129.201.248  

Starting rdp-sec-check v0.9-beta ( http://labs.portcullis.co.uk/application/rdp-sec-check/ ) at Sun Nov  7 16:50:32 2021  

[+] Scanning 1 hosts  

Target:    10.129.201.248 
IP:        10.129.201.248 
Port:      3389  

[+] Checking supported protocols  

[-] Checking if RDP Security (PROTOCOL_RDP) is supported...Not supported - HYBRID_REQUIRED_BY_SERVER 
[-] Checking if TLS Security (PROTOCOL_SSL) is supported...Not supported - HYBRID_REQUIRED_BY_SERVER 
[-] Checking if CredSSP Security (PROTOCOL_HYBRID) is supported [uses NLA]...Supported  

[+] Checking RDP Security Layer  

[-] Checking RDP Security Layer with encryption ENCRYPTION_METHOD_NONE...Not supported 
[-] Checking RDP Security Layer with encryption ENCRYPTION_METHOD_40BIT...Not supported 
[-] Checking RDP Security Layer with encryption ENCRYPTION_METHOD_128BIT...Not supported 
[-] Checking RDP Security Layer with encryption ENCRYPTION_METHOD_56BIT...Not supported 
[-] Checking RDP Security Layer with encryption ENCRYPTION_METHOD_FIPS...Not supported  

[+] Summary of protocol support  

[-] 10.129.201.248:3389 supports PROTOCOL_SSL   : FALSE 
[-] 10.129.201.248:3389 supports PROTOCOL_HYBRID: TRUE 
[-] 10.129.201.248:3389 supports PROTOCOL_RDP   : FALSE  

[+] Summary of RDP encryption support  

[-] 10.129.201.248:3389 supports ENCRYPTION_METHOD_NONE   : FALSE 
[-] 10.129.201.248:3389 supports ENCRYPTION_METHOD_40BIT  : FALSE 
[-] 10.129.201.248:3389 supports ENCRYPTION_METHOD_128BIT : FALSE 
[-] 10.129.201.248:3389 supports ENCRYPTION_METHOD_56BIT  : FALSE 
[-] 10.129.201.248:3389 supports ENCRYPTION_METHOD_FIPS   : FALSE  

[+] Summary of security issues   rdp-sec-check v0.9-beta completed at Sun Nov  7 16:50:33 2021

Authentication and connection to such RDP servers can be made in several ways. For example, we can connect to RDP servers on Linux using xfreerdp, rdesktop, or Remmina and interact with the GUI of the server accordingly.

Initiate an RDP Session

d3lvx$ xfreerdp /u:cry0l1t3 /p:"P455w0rd!" /v:10.129.201.248

After successful authentication, a new window will appear with access to the server's desktop to which we have connected.

WinRM

Ports:5985 5986 HTTPS

The Windows Remote Management (WinRM) is a simple Windows integrated remote management protocol based on the command line. WinRM uses the Simple Object Access Protocol (SOAP) to establish connections to remote hosts and their applications. Therefore, WinRM must be explicitly enabled and configured starting with Windows 10. WinRM relies on TCP ports 5985 and 5986 for communication, with the last port 5986 using HTTPS, as ports 80 and 443 were previously used for this task. However, since port 80 was mainly blocked for security reasons, the newer ports 5985 and 5986 are used today.

Another component that fits WinRM for administration is Windows Remote Shell (WinRS), which lets us execute arbitrary commands on the remote system. The program is even included on Windows 7 by default. Thus, with WinRM, it is possible to execute a remote command on another server.

Services like remote sessions using PowerShell and event log merging require WinRM. It is enabled by default starting with the Windows Server 2012 version, but it must first be configured for older server versions and clients, and the necessary firewall exceptions created.

Footprinting the Service

As we already know, WinRM uses TCP ports 5985 (HTTP) and 5986 (HTTPS) by default, which we can scan using Nmap. However, often we will see that only HTTP (TCP 5985) is used instead of HTTPS (TCP 5986).

Nmap WinRM

d3lvx$ nmap -sV -sC 10.129.201.248 -p5985,5986 --disable-arp-ping -n

Starting Nmap 7.92 ( https://nmap.org ) at 2021-11-06 16:31 CET Nmap scan report for 10.129.201.248 
Host is up (0.030s latency).  

PORT     STATE SERVICE VERSION 
5985/tcp open  http    Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) 
|_http-title: Not Found 
|_http-server-header: Microsoft-HTTPAPI/2.0 
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows  

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 7.34 seconds

d3lvx$ evil-winrm -i 10.129.201.248 -u Cry0l1t3 -p P455w0rD!  

Evil-WinRM shell v3.3  

Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine  

Data: For more information, check Evil-WinRM Github: https://github.com/Hackplayers/evil-winrm#Remote-path-completion  

Info: Establishing connection to remote endpoint  

*Evil-WinRM* PS C:\Users\Cry0l1t3\Documents>

WMI


Windows Management Instrumentation (WMI) is Microsoft's implementation and also an extension of the Common Information Model (CIM), core functionality of the standardized Web-Based Enterprise Management (WBEM) for the Windows platform. WMI allows read and write access to almost all settings on Windows systems. Understandably, this makes it the most critical interface in the Windows environment for the administration and remote maintenance of Windows computers, regardless of whether they are PCs or servers. WMI is typically accessed via PowerShell, VBScript, or the Windows Management Instrumentation Console (WMIC). WMI is not a single program but consists of several programs and various databases, also known as repositories.

Footprinting the Service


d3lvx$ /usr/share/doc/python3-impacket/examples/wmiexec.py Cry0l1t3:"P455w0rD!"@10.129.201.248 "hostname"  

Impacket v0.9.22 - Copyright 2020 SecureAuth Corporation  

[*] SMBv3.0 dialect used 
ILF-SQL-01

Again, it is necessary to mention that the knowledge gained from installing these services and playing around with the configurations on our own Windows Server VM for gaining experience and developing the functional principle and the administrator's point of view cannot be replaced by reading manuals. Therefore, we strongly recommend setting up your own Windows Server, experimenting with the settings, and scanning these services repeatedly to see the differences in the results.

In addition, we can use --packet-trace to track the individual packages and inspect their contents manually. We can see that the RDP cookies (mstshash=nmap) used by Nmap to interact with the RDP server can be identified by threat hunters and various security services such as (EDR), and can lock us out as penetration testers on hardened networks.

A Perl script named has also been developed by that can unauthentically identify the security settings of RDP servers based on the handshakes.

If we want to find out whether one or more remote servers can be reached via WinRM, we can easily do this with the help of PowerShell. The cmdlet is responsible for this, and the host's name in question is passed to it. In Linux-based environments, we can use the tool called , another penetration testing tool designed to interact with WinRM.

The initialization of the WMI communication always takes place on TCP port 135, and after the successful establishment of the connection, the communication is moved to a random port. For example, the program from the Impacket toolkit can be used for this.

⚔️
👣
RDPSecCheck
WMIExec.py
evil-winrm
Remote Desktop Protocol
Network Address Translation
Transport Layer Security
RDP Security
Network level authentication
Endpoint Detection and Response
rdp-sec-check.pl
Cisco CX Security Labs
Test-WsMan
evil-winrm
wmiexec.py