Installing and Running a Basic Nmap Scan
In this first step, you will learn how to install and use nmap, a powerful tool for network scanning, to identify open ports on a target system. Port scanning is a fundamental skill in reconnaissance, helping you discover which services are running on a machine and potentially uncover vulnerabilities. This step is designed for beginners, and we will guide you through every detail.
When you open the terminal in the LabEx VM environment, you will be automatically connected to the Kali Linux container's shell. There is no need to manually start the container or enter the shell; the environment is already set up for you.
Before we start, let's understand what nmap does. nmap, short for Network Mapper, is a tool used to discover hosts and services on a network by sending packets and analyzing responses. Open ports often indicate running services, such as web servers or SSH, which can be entry points for further analysis.
Now, let's install nmap and perform a basic scan. Follow these instructions carefully:
-
First, update the package list to ensure you can install the latest version of nmap. Type the following command in the terminal and press Enter:
apt update
This command refreshes the list of available packages. It may take a few seconds to complete, and you will see output showing the update process.
-
Next, install nmap by typing the following command and pressing Enter:
apt install -y nmap
The -y flag automatically confirms the installation without prompting you. Wait for the installation to complete; it should take only a short time. You will see output indicating the progress of the installation.
-
Once nmap is installed, let's run a basic scan on localhost (your own container, IP address 127.0.0.1), which is a safe target for practice. Type the following command and press Enter:
nmap localhost
This command scans the most common ports on localhost. After a few seconds, you will see output similar to the following (actual output may vary):
Starting Nmap 7.91 ( https://nmap.org ) at ...
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00010s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
80/tcp open http
...
Nmap done: 1 IP address (1 host up) scanned in 0.05 seconds
In this output, Host is up confirms the target is reachable. The table lists open ports, their state (open means accessible), and the associated service (like http on port 80). This information helps you understand what services are running on the system.
This step has introduced you to installing and using nmap for basic port scanning. You've taken the first step in reconnaissance by identifying open ports on a safe target. In the next step, we will build on this by saving the scan results for further analysis. Make sure you are comfortable with running the nmap command before moving forward.