Exploiting Redis 4.0.9 for RCE & Webmin 1.910 for PrivEsc

3 minute read

  3 minute read

HTB - Postman

alt text

It’s an easy-to-use box. We will exploit the Redis service to obtain the first interactive shell. Then, we will go up to the next user by reviewing further. We will use the documented CVE 2019–12840 vulnerability on the root shell to exploit the Webmin server.


Recon

nmap -Pn --open -sC -sV -p- -T4 10.10.10.160 

alt text

From the nmap scan, I discovered uncommon ports that are 6379 and 10000, Redis key-value store 4.0.9 and http MiniServ 1.910 (Webmin httpd) respectively.


Exploit

Then, I found Redis RCE exploit from Packet Storm Security. We could exploit unauthenticated Redis server by writing a content inside the memory of Redis server. We have to create our own SSH keys and insert the public key inside the Redis server to be able SSH into the box.

alt text

Writing the Public Key into Memory using redis-CLI:

alt text

Redis user to Matt:

After that we can SSH into redis user on the box. However, we could not read user.txt yet. We need to escalate to Matt user first.

alt text

alt text

While doing enumeration, we found id_rsa.bak file in /opt that is an id_rsa backup for user Matt.

alt text

Then, we copied the id_rsa content into our local machine to crack the key.

alt text

Cracking id_rsa key:

We have to convert the format using john utility called ssh2john first before cracking the key. ssh2john can converts the private key to a format that john can crack it.

alt text

We are able to crack the key and got computer2008 as the key.

alt text

Then, we tried to SSH as user Matt but the connection was closed by the server.

alt text

However, we could escalate into Matt by substitute user and read the user.txt flag.

alt text


Privilege escalation

Based on nmap scan, we found that Webmin 1.910 service on port 10000 was up. By using searchsploit, we found RCE exploit in Metasploit module.

alt text

We filled all the required setting for the module using same credential for Matt user and got root shell.

alt text

alt text