Track progress with nmap -v --stats-every 5s 192.168.1.0/24
In this step, we will learn how to track the progress of an Nmap scan using the -v
(verbose) and --stats-every
options. These options provide real-time feedback on the scan's progress, which is especially useful for long-running scans.
The -v
option increases the verbosity level of Nmap's output. With -v
, Nmap will display more information about the scan, including the probes being sent, the responses received, and the status of each host. You can use -vv
for even more verbose output.
The --stats-every
option allows you to specify how often Nmap should print statistics about the scan's progress. The value is specified in seconds (s), minutes (m), or hours (h). For example, --stats-every 5s
will print statistics every 5 seconds.
Let's understand why tracking progress is important. When scanning large networks, Nmap scans can take a significant amount of time. Without progress information, it can be difficult to know how far along the scan is and whether it's making progress. The -v
and --stats-every
options provide valuable insights into the scan's status.
Now, let's perform a scan with progress tracking. We'll use the nmap -v --stats-every 5s 192.168.1.0/24
command to scan the 192.168.1.0/24 network and print statistics every 5 seconds.
Open your terminal in the LabEx VM. Make sure you are in the ~/project
directory.
Execute the following command:
sudo nmap -v --stats-every 5s 192.168.1.0/24
This command tells Nmap to scan all IP addresses in the 192.168.1.0/24 range, display verbose output, and print statistics every 5 seconds.
The output will show the progress of the scan, including the number of hosts scanned, the number of hosts up, and the estimated time remaining.
Example output (will vary based on your network):
Starting Nmap 7.80 ( https://nmap.org ) at 2023-10-27 10:20 UTC
Initiating Ping Scan at 10:20
Scanning 256 hosts [2 ports/host]
Completed Ping Scan at 10:20, 0.23s elapsed (256 total hosts)
Initiating Parallel DNS resolution of 256 hosts. at 10:20
Completed Parallel DNS resolution of 256 hosts. at 10:20, 1.42s elapsed
Initiating SYN Stealth Scan at 10:20
Scanning 256 hosts [1000 ports/host]
5s elapsed; 0 hosts completed (0.00/s). 0 hosts up.
10s elapsed; 0 hosts completed (0.00/s). 0 hosts up.
15s elapsed; 0 hosts completed (0.00/s). 0 hosts up.
20s elapsed; 1 hosts completed (0.04/s). 1 hosts up.
Nmap scan report for 192.168.1.1
Host is up (0.00029s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
80/tcp open http
25s elapsed; 1 hosts completed (0.04/s). 1 hosts up.
Nmap scan report for 192.168.1.100
Host is up (0.00032s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
22/tcp open ssh
30s elapsed; 2 hosts completed (0.07/s). 2 hosts up.
Nmap done: 256 IP addresses (2 hosts up) scanned in 32.50 seconds
This output shows the progress of the scan every 5 seconds. You can see the number of hosts completed, the scan rate (hosts/s), and the number of hosts that are up. The scan also reports open ports as they are discovered.