DEV Community

Cover image for How to scan a port and import the results using Metasploitable and Kali Linux
Md Shykat
Md Shykat

Posted on

How to scan a port and import the results using Metasploitable and Kali Linux

To scan a port and import the results using Metasploitable (a vulnerable virtual machine for security training) and Kali Linux (a penetration testing operating system), you can follow these steps:

Step 1: Identify the Target

Find the Metasploitable IP Address:

Log in to Metasploitable using default credentials (msfadmin/msfadmin).
Use the command ifconfig to find its IP address (e.g., 192.168.1.101).
Ping the Target from Kali:

Open a terminal in Kali Linux.

Use ping [Metasploitable IP] to verify connectivity.

kali terminals

Kali linux root terminal

Step 2: Perform a Port Scan

Using Nmap:
Run an Nmap scan from Kali Linux:

bash

nmap -sS -sV -O 192.168.38.129 -oX M1
Enter fullscreen mode Exit fullscreen mode
  1. -sS: Performs a SYN scan. This is a stealthy scan method that sends SYN packets to identify open ports without completing the TCP handshake.

  2. -sV: Performs service version detection to determine the software and version running on the open ports.

  3. -O: Enables OS detection to identify the target's operating system based on response characteristics.

  4. 192.168.38.129: The target IP address to be scanned.

  5. -oX M1: Outputs the scan results in XML format and saves it to a file named M1. This format is useful for importing into tools like Metasploit.

Review Scan Results: The scan results will list open ports and services running on Metasploitable.

Step 3: Import Results into Metasploit

Start Metasploit Framework on Kali Linux:

bash

msfconsole
Enter fullscreen mode Exit fullscreen mode

Import the Nmap scan results:

bash

db_import /path/to/M1
Enter fullscreen mode Exit fullscreen mode

Ensure the database is initialized; run db_status to check. If it's not running, initialize it with:

bash

msfdb init
Enter fullscreen mode Exit fullscreen mode

Verify the imported hosts and services:

bash

hosts
services
Enter fullscreen mode Exit fullscreen mode

Step 5: Analyze and Plan Exploitation

List Vulnerabilities: Use Metasploit's auxiliary scanners to identify potential vulnerabilities based on the open ports and services.

Exploit the Target:

Use appropriate Metasploit modules to exploit vulnerabilities found during the scanning phase.

Top comments (0)