Hack The Box - Lame Walkthrough without Metasploit

Enumeration
First we start by running nmap against the target

Since FTP port is open and seems to allow Anonymous login we will try to log in and see if we can find anything

We found nothing there, next thing we can see in our initial enumeration is that Samba is running with version 3.0.20-Debian, with a fast google search we will find that it is vulnerable to a Remote Heap Overflow https://www.exploit-db.com/exploits/16320
But that is a Metasploit module and we want to do it without it... if we read the exploit it says that its exploiting a vulnerability by specifying a username containing shell meta characters, executing commands... and no authentication is needed to exploit this vulnerability, with this information we can make our python script to exploit this samba version.
Exploitation
Creating the script
This is the skeleton of the python script we will use to exploit this Samba version
Creating the Payload
For the payload we will use msfvenom to create a reverse shell that we will capture with netcat:
Putting everything together
Now we start a listener on another shell

We might run into an error while executing the script

In order to fix it we have to install the following python module if we are missing it:
Now we can run it again.. and if we have our listener ready we should be able to get a shell back
Pwnd
We got a shell back, the first thing we look for is to make it interactive, for that matter we will see if the machine has python with
In this particular case that will be enought, we can use the following command to spawn an interactive shell

Now we can grab our flag ;)
Last updated
Was this helpful?