Comprehensive Nmap Cheatsheet for Security Analysts

📱 Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Nmap?

Nmap (Network Mapper) is a powerful open-source tool for network exploration and security auditing. It helps security professionals identify live hosts, open ports, and running services on a network, making it an essential tool for both SOC analysts and penetration testers.

Installation

Nmap can be installed on various operating systems. Here’s how to install it on popular platforms:

  • Linux: Use your package manager. For example, on Ubuntu:
sudo apt-get install nmap
  • macOS: Use Homebrew:
brew install nmap

Basic Syntax

The basic syntax for running Nmap is:

nmap [options] [targets]

Host Discovery

Fast Host Discovery

nmap -sn 192.168.1.0/24

Use the -sn flag (skip port scan) for host discovery without pinging each port.

Ping Scan

nmap -PE 192.168.1.1

This performs a simple ping scan on the target to verify it’s up.

Scanning

Port Scanning

nmap -p 1-65535 192.168.1.1

Scan all ports from 1 to 65535 on the target host.

Service Version Detection

nmap -sV 192.168.1.1

Detect service versions running on open ports.

Operating System Detection

nmap -O 192.168.1.1

Attempt to determine the operating system of the target machine.

Exploitation

Script Scanning

nmap --script=default 192.168.1.1

Run default scripts against the target to gather more information about vulnerabilities.

Analysis

Output Options

Use different output options for logging results:

Flag Description
-oN Output in normal format
-oX Output in XML format
-oG Output in grepable format

Evasion

Decoy Scan

nmap -D RND:5 -p 80 192.168.1.1

Using -D with random decoy IPs can obfuscate your actual scanning IP.

Reporting

Generate Reports

nmap -oA myscan 192.168.1.1

This command creates outputs in all available formats (normal, XML, and grepable) for easier analysis after scanning.

Quick Reference Table

Flag Description
-sn Host discovery only
-sV Service version detection
-O Operating system detection
–script Run specified scripts
-D Decoy scanning

Pro Tips

  • Use -A for aggressive scanning: it combines OS detection, version detection, script scanning, and traceroute.
  • Incorporate timing options like -T4 for faster scans without too much noise.

Real-World Examples

Finding Live Hosts

nmap -sn 192.168.1.0/24

Detailed Service Scan

nmap -sS -sV -O -p 1-1000 192.168.1.1

Stealthy Scan with Decoys

nmap -D 192.168.1.10,192.168.1.11,192.168.1.12 192.168.1.1