Assignment 4
Lab Exercise: Exploi ng a Vulnerability in Target VM using Metasploit and SQLMap
Objec ve:
You will use Metasploit to exploit a known vulnerability in a target system, followed by SQLMap for
iden fying and exploi ng SQL injec on vulnerabili es.
Requirements:
A acker Machine: Kali Linux (or any machine with Metasploit and SQLMap installed)
Target Machine: Metasploitable 2 or OWASP Juice Shop (configured on a separate VM)
Network connec on between a acker and target machine
Part 1: Exploi ng a Known Vulnerability Using Metasploit
Step 1: Open Metasploit Framework
1. On Kali Linux, open the terminal and start Metasploit:
Step 2: Perform Reconnaissance
1. Scan the target machine to discover open ports and services using Nmap:
This will show services running on the target machine and iden fy possible vulnerabili es.
Step 3: Select an Exploit
1. Based on the Nmap scan, iden fy a vulnerable service. For example, if the target has an
unpatched VSFTPD 2.3.4 service, it's vulnerable to a backdoor exploit.
2. In Metasploit, search for the corresponding exploit:
If the service is vulnerable, you should see something like exploit/unix/ p/vs pd_234_backdoor.
Step 4: Configure the Exploit
1. Use the exploit module:
2. Set the target’s IP address:
3. Check if addi onal se ngs (like the target port) need to be adjusted using show op ons. Set
the appropriate port (if not 21 for FTP):
Step 5: Execute the Exploit
Run the exploit
If successful, this will grant you a shell on the target machine. You can use commands like whoami, ls,
and pwd to navigate the compromised system.
Part 2: SQL Injec on A ack Using SQLMap
Step 1: Iden fy a SQL Injec on Vulnerability
1. Visit the vulnerable web applica on (e.g., Metasploitable 2 has DVWA or OWASP Juice Shop) and
look for a login page or input form that could be vulnerable to SQL injec on.
2. Test for a basic SQL injec on vulnerability. Enter a simple payload like:
If the form is vulnerable, you may bypass the login, indica ng a poten al SQL injec on flaw.
Step 2: Using SQLMap to Automate SQL Injec on
1. Open the terminal in Kali Linux.
2. Run SQLMap against the target web applica on’s vulnerable URL or form field. For example:
-u: Specifies the URL
--dbs: Enumerates the available databases
3. SQLMap will test various SQL injec on techniques on the URL provided. If successful, it will
display the databases present on the target.
Step 3: Extract Data
1. To list tables from a specific database (e.g., dvwa):
2. To extract data from a table (e.g., users)
This will dump the contents of the users table, poten ally exposing usernames, passwords, and other
sensi ve informa on.