Walk-through of Optimum HTB (Hack the Box)

Introduction:

The purpose of this blog is to document the steps I took to complete hacking task of Optimum and guide people looking to practice their penetration testing skills.

Resources/Tools Used:

Process Followed:

After connecting HTB lab through VPN, I selected the Optimum (10.10.10.8) retired machine. To check the available services, I scanned the machine with nmap scanning all ports and doing a quick scan as follows:

nmap quick scan

Quick scan showed only one open port i.e. 80 (http). To detect services running on these ports and OS scanned using -A option as follows:

nmap service and OS scan

Browsed to the website and found nothing interesting there. Webpage showed a page with HFS 2.3 as the Web Server. Tried admin:admin and admin:password credentials but they did not work.

Webpage

Service detection scan also confirmed HFS 2.3 as the web server. Used searchsploit to check what exploits are available for this server.

searchsploit hfs

Used (Rejetto HTTP File Server (HFS) 2.3.x – Remote Command Execution (2) | exploits/windows/remote/39161.py) as it was flagged as remote execution and the only option scripted in python. Copied the file (39161.py) to local directory to analyze the code and modify to fit our requirements. Changed local host and local port parameter to my tun0 interface and port 4444. Saved the python script as exploit.py.

script modification

As per exploit advisory copied nc.exe to local directory.

nc.exe for hosting

Started netcat listener on port 4444 in first terminal, webserver to host nc.exe in second terminal, and executed exploit (python exploit.py 10.10.10. 80) in third terminal.

nc.exe hosted for target machine
user shell

Exploit succeeded giving us user access under the name of kostas user. Browsing to Desktop directory of kostas user, grabbed the user flag.

user flag

Tried accessing Administrator folder to grab root flag but access was denied.

Admin fodler access denied

To perform privilege escalation from user to admin access, used windows exploit suggester. For this script we need current patch level on the system. To gather patch level information, ran system info command on Optimum and copied the output locally to systeminfoo-output.txt file. Installed Windows-Exploit-Suggester (https://github.com/AonCyberLabs/Windows-Exploit-Suggester), and updated the database.

windows-exploit-suggester update

Used the xls database file generated to run against systeminfo-output.txt file generated previously from Optimum system to get recommendations for privilege escalation exploits.

windows-exploit-suggester

Used MS16-098 exploit (https://www.exploit-db.com/exploits/41020) for privilege escalation. Browsed to exploit-db page and saw the code which was windows based. There was a link for the binary as well. Downloaded the binary 41020.exe to local machine.

41020 on exploit-db

Started a webserver to host 41020.exe file so it can be downloaded on the target (Optimum) machine.

Web server hosting 41020.exe

On target machine (Optimum) downloaded the exe file using certutil command and saved it as admin-shell.exe file.

Downloading 41020.exe on Optimum

Upon successful download of exe file, executed admin-shell.exe to perform privilege escalation and get system access on Optimum.

System access

After this browsed to Desktop folder under Administrator directory to capture the root flag.

Root flag

Submitted the flags(user and root) on HTB website to own machine and increase our owned machine count.

Leave a comment

Design a site like this with WordPress.com
Get started