Backdoor is an easy rated machine on HackTheBox created by hkabubaker17. For the user part we will abuse a wordpress plugin vulnerable to LFI to figure out gdbserver is running and listening on all interfaces of the target. After obtaining a shell we are able to escalate by attaching to a root screen session.
User
As usual we start our enumeration with a nmap scan against all ports, followed by a script and version detection scan against the open ports to gain an initial overview of the attack surface.
Nmap
All ports
1 |
|
Script and version
1 |
|
LFI
Port 1337 from the nmap results seems very interesting but the port does not seem to answer to any data. Going over to port 80 we see a worpress blog running named Backdoor
.
After poking around at the website we see that we can list the plugins directory.
The installed plugin seems to be vulnerable to LFI in the filedownload
path.
1 |
|
1 |
|
1 |
|
Sending a request to repeater in burp we can quickly confirm this.
The found credentials don’t fit for anything though, log poisoning doesn’t seem possible and we seem to not be able to read an id_rsa. The best shot seems to be the process running on port 1337. One option the get information about the process is to retrieve its cmdline
. We can fuzz for all processes with a PID of < 5000 using a short bash script and curl.
1 |
|
After cleaning the list we see that gdbserver
is running on 1337. (If you didn’t find the process in the result you might have to increase the PID after verifying the port is open).
1 |
|
GDB server
To obtain a shell on gdbserver
metasploit is a quick option. We set the rhost, rport, tun0, payload and run the exploit, resulting in a reverse shell on the target as the user user.
1 |
|
Root
We earlier saw in the processes that a while loop is running starting a new detached screen sessions as the root user. Checking the screen binary it has the suid bit set meaning be are probably able to attach to the session.
1 |
|
First we spawn a terminal device using python. Then we attach to the session following the naming convention username/sessionname. This drops us in a screen session as the root user and we can read the flag.
1 |
|