Nmap Security Tool Cheatsheet

📱 Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Nmap?

Nmap, short for Network Mapper, is a powerful open-source tool used for network discovery and security auditing. It is widely used by security analysts and penetration testers to discover hosts and services on a network, thus creating a “map” of the network.

Installation

Nmap can be downloaded from the official website or installed via package managers on various operating systems:

  • Windows: Download from nmap.org and follow the installer instructions.
  • Linux: Install via package manager, e.g., sudo apt-get install nmap for Debian-based systems.
  • macOS: Use Homebrew: brew install nmap.

Basic Syntax

nmap [options] {target}

Discovery

Ping Scan

Identify live hosts on a network.

nmap -sn 192.168.1.0/24

Service Version Detection

Determine the services running on the open ports.

nmap -sV 192.168.1.1

Scanning

TCP Scan

Perform a basic TCP connect scan.

nmap -sT 192.168.1.1

UDP Scan

Check for open UDP ports.

nmap -sU 192.168.1.1

Exploitation

Vuln Scan

Scan for known vulnerabilities using the nse script engine.

nmap --script=vuln 192.168.1.1

Analysis

OS Detection

Identify the operating system running on a target.

nmap -O 192.168.1.1

Evasion

Zenmap GUI

Use the GUI version for a more visual approach to scans.

zenmap

Reporting

XML Output

Generate an XML report of the scan results.

nmap -oX scan_results.xml 192.168.1.1

Quick Reference Table

Flag Description
-sP Ping scan (no port scan)
-sV Service version detection
-O OS detection
-oX Output to XML

Pro Tips

  • Combine flags for powerful scans: nmap -sS -p 1-65535 -T4 192.168.1.1 for a stealthy TCP scan across all ports.
  • Use -T option for timing templates to speed up or slow down scans.

Real-World Examples

For a comprehensive network discovery on a subnet:

nmap -sS -sP -O -p 1-1024 192.168.1.0/24

This command combines TCP SYN scan, ping sweep, OS detection, and checks the first 1024 ports on all hosts in the subnet.