VulnHub Write-Up Kioptrix Level 1

How I obtained root access on the Kioptrix Level 1 virtual machine from VulnHub.

Introduction

I am a frequent visitor of several information security communities and blogs. Whenever someone asks a question along the lines of “Are there any real world vulnerable by design challenges” the Kioptrix series keeps getting mentioned. I thought I’d bite the bullet and see what the Kioptrix challenges are all about starting with Kioptrix Level 1 which can be downloaded here.

Tools Used

  • Netdiscover
  • Nmap
  • Searchsploit
  • Grep
  • Python SimpleHTTPServer
  • Wget
  • Gcc

Enumeration: Netdiscover

As the Kioptrix series are virtual machines in a downloadable and self-hosted format the machine gets an IP address from DHCP when it starts. This means that unlike online challenges such as Hack The Box the IP address of the machine is somewhat “unknown” beforehand.

The first thing to know is the local network address by using the ifconfig command. 800x400

Knowing the network address and subnet mask Netdiscover can be leveraged to do some ARP reconnaissance and find other hosts on the local network. 800x400

The Kioptrix machine is hosted on the VMware software so it is safe to assume that the last entry in the list is the target as the MAC Vendor column indicates a MAC address associated with VMware. 800x400

Enumeration: Nmap

Running an initial scan with Nmap against the discovered IP address reveals ports 22, 80, 111, 139, 443 and 1024 are open. 800x400

Running a targeted service scan against ports 22, 80, 111, 139, 443 and 1024 reveals the Apache 1.3.20 webserver running on a flavour of RedHat Linux. The mod_ssl 2.8.4 and OpenSSL 0.9.6b modules are also loaded. 800x400

Enumeration: Searchsploit

A quick search with searchsploit for mod_ssl 2.8 reveals several public exploits for mod_ssl 2.8.7 and lower versions. 800x400

Copying the exploit from the local exploit database to investigate and modify it where necessary. 800x400

For the exploit to compile correctly the libssl1.0-dev library needs to be installed on the attacking machine. 800x400

The exploit needs a few modifications to work and compile correctly. I copy the exploit keeping the original file for reference. 800x400

The exploit needs the following two include statements “#include <openssl/rc4.h>” and “#include <openssl/md5.h>” added to the exploit code. 800x400

Furthermore, to prevent compilation warnings change “unsigned char *p, *end;” to “const unsigned char *p, *end;”. 800x400

Compiling the exploit with gcc. 800x400

Exploitation: Initial Shell

The exploit supports several different target operating systems and Apache versions. Grep can be leveraged to narrow down the long list of results as the previous Nmap scan indicated that the Kioptrix machine is most likely a flavour of RedHat Linux with Apache version 1.3.20. 800x400

Executing the modified exploit results in a low privileged shell as the Apache user. 800x400

Privilege Escalation

Investigating the target operating system and kernel version reveals both are severely out of date indicating a privilege escalation exploit is most likely available for the machine. 800x400

A quick search with searchsploit for Linux Kernel 2.4 RedHat reveals several public exploits. 800x400

Copying the exploit from the local exploit database to investigate and modify it where necessary. 800x400

Verifying if gcc is available on the target to compile the exploit locally. 800x400

Copying the exploit and preparing the Python SimpleHTTPServer on port 80 to serve the exploit over HTTP. 800x400

Now that the Python SimpleHTTPServer is running wget can be leveraged to download the exploit on the target. The exploit is also compiled with gcc and made executable with the chmod +x command. 800x400

Exploitation: Root

Executing the exploit on kioptrix.level1 results in root level access and a full compromise of the machine. 800x400

Conclusion

Kioptrix Level 1 is the first machine in the series and a fun challenge for beginning security professionals.

The machine is straight forward to enumerate and with a little research not hard to compromise. While the machine is old (it was released in 2010) it teaches valuable lessons in enumeration and finding and modifying publicly available exploits, skills every beginning security professional should develop and strive to master.


© 2018. All rights reserved.