Reconnaissance with Nmap
Introduction: From Theory to Tools
Welcome back! In our previous lesson, we outlined the five phases of the penetration testing lifecycle: Reconnaissance, Scanning, Exploitation, Post-Exploitation, and Reporting. Now, we are moving from theory into practice by entering the Scanning phase. While reconnaissance involves gathering passive information, scanning is where we actively interact with the target system to identify potential entry points.
To do this, we will use Nmap (Network Mapper), the industry standard for network discovery and security auditing. Nmap allows us to map out a network, finding which hosts are up and what services they are offering. In this lesson, we will use Nmap to scan our target "Pastebin" application, discover that it is running on port 3000, identify it as a Node.js application, and uncover specific configuration weaknesses that an attacker could exploit.
Basic Port Scanning: Finding Open Doors
The first step in analyzing a specific machine is identifying which ports are open. Think of an IP address as a house address and ports as the doors and windows. To enter the house, you first need to know which doors are unlocked. In networking terms, a port is a communication endpoint; if a port is "open," it means a service (like a web server or database) is listening for connections.
We need to scan ports because every open port represents a potential attack surface. If we miss an open port, we might miss the only vulnerable service on the machine. Therefore, it is best practice to scan all possible ports to ensure we have a complete picture of the target.
Here is how we perform a comprehensive port scan using Nmap:
Let's break down this command:
nmap: The command to run the tool.-p-: This tellsNmapto scan all 65,535TCPports, not just the most common 1,000.--min-rate=1000: This instructsNmapto send packets at a rate of at least 1,000 per second, significantly speeding up the scan. Be cautious about setting this value too high; an excessively fast scan rate can reduce accuracy, potentially causingNmapto misidentify or skip ports entirely.localhost: The target we are scanning.
In the CodeSignal environment, this scan will run quickly. You might see output similar to this:
This output tells us that Port 3000 is open. Nmap guesses the service name based on standard assignments (in this case, it might guess ppp or hbci), but this is just a guess based on the port number. To know what is actually running, we need more advanced commands.
