Stealth scan
A Stealth scan operates by dispatching an SYN packet and then analyzing the received response. If an SYN/ACK is received in return, it indicates that the port is open, enabling a TCP connection.
However, the intriguing aspect of a stealth scan is that it never completes the 3-way handshake, making it quite challenging for the target device to pinpoint the scanning system.
nmap -sS scanme.nmap.org
For executing a stealth scan, you can deploy the ‘-sS’ command. It's essential to note that stealth scans tend to be more time-consuming and aren't as aggressive as other scanning techniques. Thus, a tad bit of patience might be required for results.
Version scanning
Ascertaining application versions forms a pivotal component in the realm of penetration testing. Having this information on hand can greatly streamline the process. For instance, if you know a particular version of a service, you can easily look up any associated vulnerabilities from the Common Vulnerabilities and Exploits (CVE) database. This data can then be harnessed to assail a system using a tool like Metasploit.
nmap -sV scanme.nmap.org
For initiating a version scan, the ‘-sV’ command is your go-to. While Nmap will furnish a list of services along with their respective versions, it's prudent to remember that these scans might not always be impeccably accurate. Nonetheless, it does edge you closer to achieving a successful system breach.
OS Scanning
An essential feature of Nmap is its ability to deduce the operating system running on a target device. This is achieved using TCP/IP fingerprinting. During this OS scanning process, Nmap makes an attempt to also discern the system's uptime.
nmap -sV scanme.nmap.org
If you wish to refine your OS scanning process, you can employ additional flags such as osscan-limit. This limits the search to specific, anticipated targets. Following the scan, Nmap presents its findings, specifying the level of confidence (as a percentage) for each OS deduction.
It's worth noting that while OS detection can be invaluable, it might not always be pinpoint accurate. However, it undeniably assists penetration testers in narrowing down their approach.
Intensive Scanning
One of the advanced features of Nmap is its intensive scanning mode. By using the -A parameter, you can activate a comprehensive scan that encompasses OS detection, version identification, script-based scanning, and even traceroute functionality.
nmap -A scanme.nmap.org
Though intensive scans yield more detailed information compared to standard scans, there's a catch. These scans dispatch a higher number of probes, elevating the risk of detection, especially if security monitoring tools are active on the network.
Scanning Multiple Hosts
The versatility of Nmap allows it to scan multiple targets concurrently, proving invaluable for those overseeing extensive network environments.
Several methods facilitate multi-host scanning:
nmap 192.164.1.1 192.164.0.2 192.164.0.2
Using the asterisk () notation allows you to scan an entire subnet in one go.
nmap 192.164.1.
Instead of writing out full IP addresses, you can distinguish different host endings with commas.
nmap 192.164.0.1,2,3,4
To scan a range of IP addresses, employ the hyphen notation.
nmap 192.164.0.0–255
Port Scanning
The essence of Nmap lies in its robust port scanning capabilities, offering multiple scanning methods.
To scan a specific port, use the -p parameter:
nmap -p 973 192.164.0.1
Specify the port type for targeted scans, like the TCP connection, for instance.
nmap -p T:7777, 973 192.164.0.1
Scanning a range of ports is effortless with the hyphen separator.
nmap -p 76–973 192.164.0.1
You can focus on the most commonly used ports using the --top-ports flag:
nmap --top-ports 10 scanme.nmap.org
Scanning from a File
For extensive scans across numerous IP addresses, Nmap allows for file imports containing your list of IPs.
nmap -iL /input_ips.txt
This command processes and returns scans for all the IP addresses listed in the “input_ips.txt” file. Beyond basic scans, you can enrich the process with supplementary options and flags to customize your reconnaissance.
Verbosity and Exporting Scan Results
Penetration testing can last days or even weeks. Exporting Nmap results can be useful to avoid redundant work and to help with creating final reports. Let’s look at some ways to export Nmap scan results.
Verbose Output
nmap -v scanme.nmap.org
The verbose output provides additional information about the scan being performed. It is useful to monitor step by step actions Nmap performs on a network, especially if you are an outsider scanning a client’s network.
Normal output
Nmap scans can also be exported to a text file. It will be slightly different from the original command line output, but it will capture all the essential scan results.
nmap -oN output.txt scanme.nmap.org
XML output
Nmap scans can also be exported to XML. It is also the preferred file format of most pen-testing tools, making it easily parsable when importing scan results.
nmap -oX output.xml scanme.nmap.org
Multiple Formats
You can also export the scan results in all the available formats at once using the -oA command.
nmap -oA output scanme.nmap.org
The above command will export the scan result in three files — output.xml, output. Nmap and output.gnmap.
Nmap Help
Nmap has a built-in help command that lists all the flags and options you can use. It is often handy given the number of command-line arguments Nmap comes with.
nmap -h
Nmap Scripting Engine
Nmap Scripting Engine (NSE) is an incredibly powerful tool that you can use to write scripts and automate numerous networking features.
You can find plenty of scripts distributed across Nmap, or write your own script based on your requirements. You can even modify existing scripts using the Lua programming language.
0 Comments