What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (2024)

/ #Cybersecurity
What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (1)
Manish Shivanandhan
What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (2)

Nmap is the most famous scanning tool used by penetration testers. In this article, we will look at some core features of Nmap along with a few useful commands.

Nmap is short for Network Mapper. It is an open-source Linux command-line tool that is used to scan IP addresses and ports in a network and to detect installed applications.

Nmap allows network admins to find which devices are running on their network, discover open ports and services, and detect vulnerabilities.

Gordon Lyon (pseudonym Fyodor) wrote Nmap as a tool to help map an entire network easily and to find its open ports and services.

Nmap has become hugely popular, being featured in movies like The Matrix and the popular series Mr. Robot.

There are a number of reasons why security pros prefer Nmap over other scanning tools.

First, Nmap helps you to quickly map out a network without sophisticated commands or configurations. It also supports simple commands (for example, to check if a host is up) and complex scripting through the Nmap scripting engine.

Other features of Nmap include:

  • Ability to quickly recognize all the devices including servers, routers, switches, mobile devices, etc on single or multiple networks.
  • Helps identify services running on a system including web servers, DNS servers, and other common applications. Nmap can also detect application versions with reasonable accuracy to help detect existing vulnerabilities.
  • Nmap can find information about the operating system running on devices. It can provide detailed information like OS versions, making it easier to plan additional approaches during penetration testing.
  • During security auditing and vulnerability scanning, you can use Nmap to attack systems using existing scripts from the Nmap Scripting Engine.
  • Nmap has a graphical user interface called Zenmap. It helps you develop visual mappings of a network for better usability and reporting.

Let's look at some Nmap commands. If you don't have Nmap installed, you can get it from here.

Basic scans

Scanning the list of active devices on a network is the first step in network mapping. There are two types of scans you can use for that:

  • Ping scan — Scans the list of devices up and running on a given subnet.
> nmap -sp 192.168.1.1/24
  • Scan a single host — Scans a single host for 1000 well-known ports. These ports are the ones used by popular services like SQL, SNTP, apache, and others.
> nmap scanme.nmap.org
What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (3)

Stealth scan

Stealth scanning is performed by sending an SYN packet and analyzing the response. If SYN/ACK is received, it means the port is open, and you can open a TCP connection.

However, a stealth scan never completes the 3-way handshake, which makes it hard for the target to determine the scanning system.

> nmap -sS scanme.nmap.org

You can use the ‘-sS’ command to perform a stealth scan. Remember, stealth scanning is slower and not as aggressive as the other types of scanning, so you might have to wait a while to get a response.

Version scanning

Finding application versions is a crucial part in penetration testing.

It makes your life easier since you can find an existing vulnerability from the Common Vulnerabilities and Exploits (CVE) database for a particular version of the service. You can then use it to attack a machine using an exploitation tool like Metasploit.

> nmap -sV scanme.nmap.org

To do a version scan, use the ‘-sV’ command. Nmap will provide a list of services with its versions. Do keep in mind that version scans are not always 100% accurate, but it does take you one step closer to successfully getting into a system.

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (4)

OS Scanning

In addition to the services and their versions, Nmap can provide information about the underlying operating system using TCP/IP fingerprinting. Nmap will also try to find the system uptime during an OS scan.

> nmap -sV scanme.nmap.org

You can use the additional flags like osscan-limit to limit the search to a few expected targets. Nmap will display the confidence percentage for each OS guess.

Again, OS detection is not always accurate, but it goes a long way towards helping a pen tester get closer to their target.

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (5)

Aggressive Scanning

Nmap has an aggressive mode that enables OS detection, version detection, script scanning, and traceroute. You can use the -A argument to perform an aggressive scan.

> nmap -A scanme.nmap.org

Aggressive scans provide far better information than regular scans. However, an aggressive scan also sends out more probes, and it is more likely to be detected during security audits.

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (6)

Scanning Multiple Hosts

Nmap has the capability of scanning multiple hosts simultaneously. This feature comes in real handy when you are managing vast network infrastructure.

You can scan multiple hosts through numerous approaches:

  • Write all the IP addresses in a single row to scan all of the hosts at the same time.
> nmap 192.164.1.1 192.164.0.2 192.164.0.2
  • Use the asterisk (*) to scan all of the subnets at once.
> nmap 192.164.1.*
  • Add commas to separate the addresses endings instead of typing the entire domains.
> nmap 192.164.0.1,2,3,4
  • Use a hyphen to specify a range of IP addresses
> nmap 192.164.0.0–255

Port Scanning

Port scanning is one of the most fundamental features of Nmap. You can scan for ports in several ways.

  • Using the -p param to scan for a single port
> nmap -p 973 192.164.0.1
  • If you specify the type of port, you can scan for information about a particular type of connection, for example for a TCP connection.
> nmap -p T:7777, 973 192.164.0.1
  • A range of ports can be scanned by separating them with a hyphen.
> nmap -p 76–973 192.164.0.1
  • You can also use the -top-ports flag to specify the top n ports to scan.
> nmap --top-ports 10 scanme.nmap.org

Scanning from a File

If you want to scan a large list of IP addresses, you can do it by importing a file with the list of IP addresses.

> nmap -iL /input_ips.txt

The above command will produce the scan results of all the given domains in the “input_ips.txt” file. Other than simply scanning the IP addresses, you can use additional options and flags as well.

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.

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (7)

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
What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (8)

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
What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (9)

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
What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (10)

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.

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (11)

NSE also has attack scripts that are used in attacking the network and various networking protocols.

Going through the scripting engine in-depth would be out-of-scope for this article, so here is more information about the Nmap scripting engine.

Zenmap

Zenmap is a graphical user interface for Nmap. It is a free and open-source software that helps you get up and running with Nmap.

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (12)

In addition to providing visual network mappings, Zenmap also allows you to save and search your scans for future use.

Zenmap is great for beginners who want to test the capabilities of Nmap without going through a command-line interface.

Nmap is clearly the “Swiss Army Knife” of networking, thanks to its inventory of versatile commands.

It lets you quickly scan and discover essential information about your network, hosts, ports, firewalls, and operating systems.

Nmap has numerous settings, flags, and preferences that help system administrators analyze a network in detail.

If you want to learn Nmap in-depth, here is a great resource for you.

Loved this article? Join my Newsletter and get a summary of my articles and videos every Monday.

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

ADVERTIsem*nT

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (13)
Manish Shivanandhan

Cybersecurity & Machine Learning Engineer. Loves building useful software and teaching people how to do it. More at manishmshiva.com

If you read this far, thank the author to show them you care.

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

ADVERTIsem*nT

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time (2024)

FAQs

What is Nmap and How to Use it – A Tutorial for the Greatest Scanning Tool of All Time? ›

Nmap is a powerful and versatile network scanning tool that lets you map out hosts and services on your network and provides valuable information to analyze for vulnerabilities. In this article, we'll discuss what Nmap is, demonstrate how to use its core features, and show you a few other scanning options available.

What is Nmap and what is it used for? ›

Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime.

Why is Nmap scan used? ›

Nmap is short for Network Mapper. It is an open-source Linux command-line tool that is used to scan IP addresses and ports in a network and to detect installed applications. Nmap allows network admins to find which devices are running on their network, discover open ports and services, and detect vulnerabilities.

How to run Nmap scan? ›

Executing Nmap on Windows
  1. Make sure the user you are logged in as has administrative privileges on the computer (user should be a member of the administrators group).
  2. Open a command/DOS Window. ...
  3. Change to the directory you installed Nmap into. ...
  4. Execute nmap.exe.

Why is Nmap illegal? ›

Network probing or port scanning tools are only permitted when used in conjunction with a residential home network, or if explicitly authorized by the destination host and/or network. Unauthorized port scanning, for any reason, is strictly prohibited.

Why is Nmap the best? ›

Nmap offers a wide range of scanning techniques, including TCP SYN scan, TCP connect scan, UDP scan, and more. These scanning options allow users to tailor their scans based on the specific requirements of the target network and optimize the scanning process.

How do I scan a network with Nmap? ›

How to Use Nmap to Scan a Network: A Step-by-Step Guide
  1. Install Nmap.
  2. Nmap Command Generator.
  3. Ensure You Have Permission.
  4. Select Network Range.
  5. Scan Types.
  6. Scan Option.
  7. Scanning an Entire Network Walkthrough.
  8. Disruption Mitigation.
May 11, 2024

Is port scanning illegal? ›

It is legal. However every network makes its own rules and you must abide by them. For example, whether your ISP bans port scanning on their hosts (including their all of their customers) is up to them. They might also choose to ban the transmission of associated protocols completely.

What is the most powerful Nmap scan? ›

Port scanning.

One of the most powerful features of Nmap is Nmap Scripting Engine (NSE). NSE enables users to write scripts to automate various network tasks. Nmap uses Lua, an embedded programming language, for writing scripts.

How to detect Nmap scans? ›

Log monitoring tools such as Logwatch and Swatch can certainly help, but the reality is that system logs are only marginally effective at detecting Nmap activity. Special purpose port scan detectors are a more effective approach to detecting Nmap activity. Two common examples are PortSentry and Scanlogd.

Is Nmap safe to use? ›

Yes, Nmap is generally safe to install and use, provided it is used responsibly and legally. Nmap (Network Mapper) is a powerful and widely-used open-source network scanning tool that helps in discovering and mapping networks, identifying open ports, and detecting vulnerabilities.

What is the basic command for Nmap? ›

NMAP Commands Cheat Sheet
DescriptionCommands
To get the HTTP headers of web services:nmap –script=http-title 192.168.1.0/24
Command to find web apps from specific paths:nmap –script=http-enum 192.168.1.0/24
To gather the data about page titles from HTTP services:nmap –script=http-title 192.168.10/24

How long does full Nmap scan take? ›

Estimate and Plan for Scan Time

So the total time Nmap will spend scanning the network can be roughly extrapolated by multiplying 21 minutes per host by the number of hosts online. If version detection or UDP are being done as well, you'll also have to watch the timing estimates for those.

Why do hackers use Nmap? ›

However, hackers can also use Nmap to access uncontrolled ports on a system. They can run Nmap on a targeted approach, identify vulnerabilities, and exploit them. But Nmap is not only used by hackers - IT security companies also use it to simulate potential attacks that a system may face.

How to tell if Nmap is running? ›

Use ps -aux , nmap should appear as a running process.

Do people still use Nmap? ›

Nmap users include everyone from beginners to cyber security professionals. Network administrators use Nmap (and Zenmap) to map subnets and discover hosts. Cyber security professionals use Nmap to scan target systems for open ports and services they might be running.

Should I delete Nmap? ›

Removing Nmap is a good idea if you are changing install methods (such as from source to RPM or vice versa) or if you are not using Nmap anymore and you care about the few megabytes of disk space it consumes. How to remove Nmap depends on how you installed it initially (see previous sections).

What is the difference between Nmap and Wireshark? ›

In summary, Nmap is geared towards discovering and profiling network hosts, while Wireshark is focused on capturing and analyzing the actual data flowing through a network. They can complement each other in network analysis and security assessments.

How to use Nmap to find IP addresses? ›

Instructions
  1. Install nmap by downloading it from the official website.
  2. Open the nmap tool and enter the following command, replacing the IP range and port number with the appropriate values: nmap -p <port number> -O <IP range> ...
  3. Press Enter and wait for nmap to complete the scan.

Is Nmap a port scanner? ›

Fortunately, Nmap can help inventory UDP ports. UDP scan is activated with the -sU option. It can be combined with a TCP scan type such as SYN scan ( -sS ) to check both protocols during the same run. UDP scan works by sending a UDP packet to every targeted port.

Top Articles
What Is Middle Class Income Tax Bracket in the U.S.?
Trupanion Pet Insurance Review and Pricing (2024)
Tlc Africa Deaths 2021
Amc Near My Location
Booknet.com Contract Marriage 2
Www.craigslist Augusta Ga
Hay day: Top 6 tips, tricks, and cheats to save cash and grow your farm fast!
Smokeland West Warwick
B67 Bus Time
Max 80 Orl
Iron Drop Cafe
Voyeuragency
Hair Love Salon Bradley Beach
Nj State Police Private Detective Unit
Mary Kay Lipstick Conversion Chart PDF Form - FormsPal
Best Nail Salon Rome Ga
Dark Chocolate Cherry Vegan Cinnamon Rolls
ZURU - XSHOT - Insanity Mad Mega Barrel - Speelgoedblaster - Met 72 pijltjes | bol
Rapv Springfield Ma
Danielle Ranslow Obituary
3Movierulz
Craigslist Dubuque Iowa Pets
Giantbodybuilder.com
Pixel Combat Unblocked
91 Octane Gas Prices Near Me
Ravens 24X7 Forum
Forager How-to Get Archaeology Items - Dino Egg, Anchor, Fossil, Frozen Relic, Frozen Squid, Kapala, Lava Eel, and More!
#scandalous stars | astrognossienne
Justin Mckenzie Phillip Bryant
Craigslist Lakeside Az
Whitehall Preparatory And Fitness Academy Calendar
Dr Adj Redist Cadv Prin Amex Charge
Studentvue Columbia Heights
Trap Candy Strain Leafly
Final Fantasy 7 Remake Nexus
Tyler Perry Marriage Counselor Play 123Movies
Panorama Charter Portal
511Pa
Lake Kingdom Moon 31
Beaufort SC Mugshots
Tricia Vacanti Obituary
Hovia reveals top 4 feel-good wallpaper trends for 2024
Luciane Buchanan Bio, Wiki, Age, Husband, Net Worth, Actress
Cch Staffnet
Paperlessemployee/Dollartree
Pickwick Electric Power Outage
855-539-4712
60 Days From August 16
Craigslist Sarasota Free Stuff
Lira Galore Age, Wikipedia, Height, Husband, Boyfriend, Family, Biography, Net Worth
Escape From Tarkov Supply Plans Therapist Quest Guide
Pauline Frommer's Paris 2007 (Pauline Frommer Guides) - SILO.PUB
Latest Posts
Article information

Author: Madonna Wisozk

Last Updated:

Views: 5943

Rating: 4.8 / 5 (68 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Madonna Wisozk

Birthday: 2001-02-23

Address: 656 Gerhold Summit, Sidneyberg, FL 78179-2512

Phone: +6742282696652

Job: Customer Banking Liaison

Hobby: Flower arranging, Yo-yoing, Tai chi, Rowing, Macrame, Urban exploration, Knife making

Introduction: My name is Madonna Wisozk, I am a attractive, healthy, thoughtful, faithful, open, vivacious, zany person who loves writing and wants to share my knowledge and understanding with you.