Keep Calm and Hack The Box
Keep Calm and Hack The Box
Keep Calm and Hack The Box
Sonya Moisset
Hack The Box (HTB) is an online platform allowing you
to test your penetration testing skills. It contains several
challenges that are constantly updated. Some of them
simulating real world scenarios and some of them
leaning more towards a CTF style of challenge.
Note. Only write-ups of retired HTB machines are allowed.
Lame is the first machine published on Hack The Box and is for
beginners, requiring only one exploit to obtain root access.
We will use the following tools to pawn the box on a Kali Linux box
nmap
zenmap
searchsploit
metasploit
Step 1 - Scanning the network
The first step before exploiting a machine is to do a little bit of
scanning and reconnaissance.
This is one of the most important parts as it will determine what you
can try to exploit afterwards. It is always better to spend more time on
that phase to get as much information as you could.
I will use Nmap (Network Mapper). Nmap is a free and open source
utility for network discovery and security auditing. It uses raw IP
packets to determine what hosts are available on the network, what
services those hosts are offering, what operating systems they are
running, what type of packet filters/firewalls are in use, and dozens of
other characteristics.
There are many commands you can use with this tool to scan the
network. If you want to learn more about it, you can have a look at the
documentation here
nmap -A -v 10.10.10.3
-A: Enable OS detection, version detection, script scanning, and
traceroute
-v: Increase verbosity level
10.10.10.3: IP address of the Lame box
If you find the results a little bit too overwhelming, you can move to
the Ports/Hosts tab to only get the open ports
exploit/unix/ftp/vsftpd_234_backdoor
I use the following command for the exploit
use exploit/unix/ftp/vsftpd_234_backdoor
This will launch the exploit. I use this command to display the
available options
show options
You can see that the remote host (RHOSTS) is not yet set. I will set
both the remote host and the target as these two pieces of information
are needed to run the exploit
I use the following command to set the remote host using the IP
address of HTB Lame box
set TARGET 0
We can now run the exploit
Unfortunately we can see that even if the exploit is completed, no
session was created. The vulnerability has been patched as mentioned
here, in the description of the exploit.
exploit/multi/samba/usermap_script
You can also find it on the Exploit Database website
https://www.exploit-db.com/exploits/16320
The description of the exploit
This module exploits a command execution vulerability in Samba
versions 3.0.20 through 3.0.25rc3 when using the non-default
"username map script" configuration option. By specifying a
username containing shell meta characters, attackers can execute
arbitrary commands.
No authentication is needed to exploit this vulnerability since this
option is used to map usernames prior to authentication!
Back on Metasploit where I use the command
use exploit/multi/samba/usermap_script
This will launch the exploit. I use the following command to display
the available options
show options
You can see that the remote host (RHOSTS) is not yet set.
I use the following command to set the remote host using the IP
address of HTB Lame box
whoami
We have root access to the machine. We got the power! Let's start
navigating the folders
cd home
We don't have that much info here, let's be more specific with the
command
ls -la
We can see that there's a folder called makis. Let's see what's inside!
We found the user.txt file! To read the content of the file I use the
command
cat user.txt
Now that we have the user flag, let's find the root flag!
cd ~
To check where you are, you can use the following command
pwd
Here we see that we're at the /root level and if we list the files/folders
we find the root.txt file!
To read the content of the file I use the command
cat root.txt
Congrats! You found both flags!