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 Sneaky.

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.

Note: Only write-ups of retired HTB machines are allowed. The machine in this article, named Sneaky, is retired.

The walkthrough

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 Sneaky machine IP is 10.10.10.20.
  3. We will adopt the same methodology of performing penetration testing as we’ve used previously. 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 learn more about the services running on this machine. [CLICK IMAGES TO ENLARGE]
    <<nmap -sC -sV -oA Sneaky 10.10.10.20>>

  5. As we can see, we only have port 80 listed from the normal ones available.
  6. Let’s enumerate on port 80. We can see this in the page below.
  7. Let’s try to brute-force this to enumerate other directories as well.
    <<gobuster -u 10.10.10.20 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt>>
  8. We got a hit on /dev directory, which gives us the page below:
  9. Some initial testing showed that SQL injection is possible. So a trivial SQL injection got us in.
  10.  We got two names and a link to the key.
  11. Below is the key we have in the portal. Let’s save it locally. Despite saving it locally, we do not have a port to log into.
  12. Back we go to full port enumeration. We got the below ports.
  13. We got snmp open, so we can do a snmp walk
    <<snmpwalk -v2c -c public 10.10.10.20 > snmp.txt>>
  14. The result indicates that there are IPv6 interfaces available. We’ll use ENVX to grab all the interfaces and we get the below interfaces. We’ll use the correct one below to log in.
  15. As shown below, we can log in using the saved key and the discovered IPv6 interface.
  16. We enumerate to grab the user.txt flag.
  17. Further enumerating for escalating privilege, we can see that the suid bit is set on following files.
    <<find / -perm 4000 2>/dev/null >>

  18. Looking into the chal file, it seems like it is a candidate for buffer overflow.
  19. Generating a pattern of 400 using pattern_create.
    <<pattern_create.rb -l 400>>

  20. We pass the pattern to the binary using GDB.
  21. We now collect the location from above and pass it to the pattern_offset file.
    <<pattern_offset.rb -q {location}>>

  22. Now we have the offset, we need to find the EIP location. Let’s do that with random As with GDB, as shown below.
  23. As we can see, all the As are in the location range below.
  24. After some trial and error, we see that below is the EIP and whole script that can be used to overflow the buffer and execute the shell code to spawn /bin/sh.
  25. Running that, we can see that we got a shell with an effective ID of root.
    <<chal ${python exp.py}>>

  26. We enumerate to grab the root flag.


This is a straightforward machine with lot of enumeration involved to grab the IPv6 interfaces, which then requires trivial buffer overflow to grab the root flag and shell.

We will continue this series soon with more such interesting HTB machines.