Nmap, which stands for "Network Mapper," is an open source tool that lets you perform scans on local and remote networks. Nmap is very powerful when it comes to discovering network protocols, scanning open ports, detecting operating systems running on remote machines, etc. The tool is used by network administrators to inventory network devices, monitor remote host status, save the scan results for later use, and so on.
The Nmap suite includes an advanced graphical user interface and results viewer (Zenmap), a flexible data transfer, redirection, and debugging tool (Ncat), a utility for comparing scan results (Ndiff), and a packet generation and response analysis tool (Nping).
Besides being free, Nmap is very flexible, portable, well-documented, and easy to use. In the following post, we'll walk you through on how to install Nmap, use it, and, most important, get more to know about your network.
Substitute dnf for yum if you are on Red Hat Enterprise Linux 7 or newer. After installing Nmap, you can run the nmap command without arguments to display all of its options. You also should consult the Nmap man page by running man nmap.
While Nmap man pages are well-written and provide many examples, there are specific things you won't find in the man pages. For example, what if we wanted to store IP addresses from the above output to a file? This is something specific and does not belong in the man pages of Nmap. We have to parse the output ourselves and extract IP addresses only.
At the moment of writing, I am connected to my server via SSH. To demonstrate how packet tracing is done using Nmap and what the output of such a trace looks like we are going to use the following Nmap syntax to produce the following output:
By default, Nmap runs an rDNS (reverse-DNS) resolution on any responsive host. Let's see if we can gather some information about a specific network and remain anonymous. The anonymous part is because we'll use public DNS servers, namely 8.8.4.4 and 8.8.8.8, to perform the recursive query.
As mentioned earlier, Nmap is equipped with many advanced features, one of which is NSE (Nmap Scripting Engine) scripts. Using NSE scripts with Nmap allows you to scan different hosts and find vulnerabilities in services running on the host and possibly log in by brute-forcing these services.
A Web Application Firewall (WAF) is specifically designed to protect websites from SQL injection, cross-site scripting, malformed HTTP packets, etc. Using Nmap, we can detect if a website is protected by such a WAF. The following displays the usage of an NSE script and its arguments:
Once again, Nmap is often used by system administrators to inventory their environment, discover weaknesses in their network, and so protect their systems from intruders. Intruders, on the other hand, can do the same to explore a remote system and try to gather as much information as possible about such a system.
Assume that some unauthorized person has scanned your network and found a few open ports/services. This person could then pass some NSE scripts to Nmap and see if these services are vulnerable. Here is what is going to happen:
Nmap is a very powerful system inventory and port scanning tool that can be used for good and bad purposes. It depends on which hat you are wearing. The best way to learn Nmap is to read man pages, use examples shown in the man pages, and experiment with the NSE scripts. Also, try Zenmap. If you are interested in knowing more about port scanning and the science behind it, see the Nmap documentation.
Valentin is a system engineer with more than six years of experience in networking, storage, high-performing clusters, and automation.He is involved in different open source projects like bash, Fedora, Ceph, FreeBSD and is a member of Red Hat Accelerators. More about me
The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. The content published on this site are community contributions and are for informational purpose only AND ARE NOT, AND ARE NOT INTENDED TO BE, RED HAT DOCUMENTATION, SUPPORT, OR ADVICE.
Nmap Network Scanning is the official guide to the Nmap SecurityScanner, a free and open source utility used by millions of people fornetwork discovery, administration, and security auditing. Fromexplaining port scanning basics for novices to detailing low-levelpacket crafting methods used by advanced hackers, this book by Nmap'soriginal author suits all levels of security and networkingprofessionals. The reference guide documents every Nmap feature andoption, while the remainder demonstrates how to apply them to quicklysolve real-world tasks. Examples and diagrams show actualcommunication on the wire. Topics include subverting firewalls andintrusion detection systems, optimizing Nmap performance, andautomating common networking tasks with the Nmap Scripting Engine.
Using different scanning techniques, Nmap can help you identify the devices, services, and operating systems active on the network. With this information, you can perform a more comprehensive penetration test to uncover any vulnerabilities in the system.
This article will show you how to use Nmap to scan a network and explain the different scan types and options. We will then walk you through scanning an entire network and show you which scans and options to use.
Say goodbye to the hassle of trying to remember the exact syntax for your Nmap commands! With our Nmap Command Generator, you can simply say what you need Nmap to do, and we will generate the command for you.
Also, before beginning, ensure you have the correct IP addresses for the network you are authorized to test. Misconfigurations or misunderstandings about the target IP range can lead to scanning or testing systems outside your authorized scope, which could lead to legal issues or unintended disruptions.
Once you have the correct permissions to scan the network with Nmap, your next step is to ensure you have the correct IPs. This could be a specific list of addresses or the whole network, also known as a subnet.
CIDR notation, in simple terms, is a way to describe a group of IP addresses. In our example, 192.168.1.0 is the beginning of the group, and the /24 tells you how many addresses are included in the subnet. Our subnet has 256 addresses, 254 of which are usable for hosts.
Next, we will demonstrate how to scan an entire network. We'll check for live IP addresses, determine OS versions, identify common services, and uncover any existing vulnerabilities. We'll also output the scan results to files for future reference.
Our first step is to check the network for any live hosts, as this will enable us to focus our scanning on only the necessary hosts. We will do this by sending a ping to each host on the network. If we get a response, we can assume the host is live.
Now that we have our list of live hosts, our next step is to check for operating systems. We need to extract the IP addresses from the saved file and create a new one. You can use the following command to create a new file called ip-addresses.txt that will include only the live IP addresses.
Nmap checks for the OS of each target by sending a series of specially crafted TCP and UDP packets and then analyzes the responses. Different operating systems send different types of responses. Nmap uses a database of known profiles to compare the response it receives.
Now that we have determined what operating systems are running on some of the hosts, we can move on to checking for common services running. This is beneficial because it allows you to identify the specific services and versions running on the target, providing valuable context about potential vulnerabilities.
Our Nmap scan reveals the different services and even versions of those services running on the host. This is incredibly valuable information, as different versions of services can have different vulnerabilities. With this information, you can create a plan moving forward.
Next, we will run a vulnerability scan on our live hosts to identify potential weaknesses that could be exploited. This scan will leverage the Nmap scripting engine to check for a wide range of known vulnerabilities.
As you can see, the Nmap scripting engine provides us with a wealth of information that we can use better to understand our target system and its potential vulnerabilities. Whether it's outdated software, detecting misconfigurations, or even potential entry points into the system, the Nmap vuln scan can help us create a plan of attack.
We need to first warn you about the potential risks involved while performing Nmap scans. While these tasks are essential to a penetration test, they can also overwhelm or disrupt a network if not done properly.
Learning to use Nmap to scan a network entails many different elements. We have discussed ensuring you have the correct permission to perform your scans, selecting your network range, and showing you different scan types and options.
Yes, Nmap scans can indeed be detected, which can occur in several ways. Nmap generates unusual traffic patterns during its scans, quickly sending packets to various ports.
Certain types of scans, such as the SYN scan, involve Nmap sending specific types of packets that are rarely seen in regular network traffic. Additionally, Nmap typically attempts to connect to multiple ports on a single system, which is generally considered abnormal behavior and can be a clear sign of a scan.
So, how might you use Nmap if not for security? By inventorying and documenting a network, you enable maintenance of audits and licensing records, accurate and efficient configuration management, and a solid troubleshooting reference.
This article explains some options and tricks for using Nmap for nonsecurity tasks. It begins with a brief overview of basic Nmap use and then expands into outputting results to files and using Zenmap, as well as a few Ansible specifics.
Admins can control the time it takes Nmap to scan in many ways. One method is by using timings. By adding the -T1, -T2, -T3, -T4 or -T5 options, you can speed up the scan at the risk of possibly less accurate results. Consider these timings if scanning a large network segment. The -T1 option is the slowest of those listed, and -T5 is the quickest.
795a8134c1