19. Enumeration - SSH (22) _ RDP (3389)

The well-known OpenBSD SSH (OpenSSH) server on Linux distributions is an open-source fork of the original and commercial SSH server from SSH Communication Security. Accordingly, there are two competing protocols: SSH-1 and SSH-2. SSH-2, also known as SSH version 2, is a more advanced protocol than SSH version 1 in encryption, speed, stability, and security. For example, SSH-1 is vulnerable to MITM attacks, whereas SSH-2 is not. We can imagine that we want to manage a remote host. This can be done via the command line or GUI. Besides, we can also use the SSH protocol to send commands to the desired system, transfer files, or do port forwarding. Therefore, we need to connect to it using the SSH protocol and authenticate ourselves to it. In total, OpenSSH has six different authentication methods:

  1. Password authentication
  2. Public-key authentication
  3. Host-based authentication
  4. Keyboard authentication
  5. Challenge-response authentication
  6. GSSAPI authentication

![](/img/Pasted image 20240716224545.png|1000)

Dangerous

Setting Description
PasswordAuthentication yes Allows password-based authentication.
PermitEmptyPasswords yes Allows the use of empty passwords.
PermitRootLogin yes Allows to log in as the root user.
Protocol 1 Uses an outdated version of encryption.
X11Forwarding yes Allows X11 forwarding for GUI applications.
AllowTcpForwarding yes Allows forwarding of TCP ports.
PermitTunnel Allows tunneling.
DebianBanner yes Displays a specific banner when logging in.

Hardening guide

https://www.ssh-audit.com/hardening_guides.html

specify authentication method:

 ssh -v cry0l1t3@10.129.14.132 -o PreferredAuthentications=password

footprinting

One of the tools we can use to fingerprint the SSH server is ssh-audit. It checks the client-side and server-side configuration and shows some general information and which encryption algorithms are still used by the client and server. Of course, this could be exploited by attacking the server or client at the cryptic level later.

stejwes@htb[/htb]$ git clone https://github.com/jtesta/ssh-audit.git && cd ssh-audit
stejwes@htb[/htb]$ ./ssh-audit.py 10.129.14.132

RDP - Enumeration

A Perl script named rdp-sec-check.pl has also been developed by Cisco CX Security Labs that can unauthentically identify the security settings of RDP servers based on the handshakes.

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 Endpoint Detection and Response (EDR), and can lock us out as penetration testers on hardened networks.

RDP Security Check - Installation

  Windows Remote Management Protocols

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

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.

nmap -sV -sC 10.129.201.248 -p3389 --script rdp*

initiate rdp session

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