Comprehensive Cheatsheet for Nmap

πŸ“± Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Nmap?

Nmap (Network Mapper) is a powerful and versatile open-source tool used for network discovery and security auditing. Its features include host discovery, port scanning, service enumeration, and vulnerability detection. Security professionals rely on Nmap to assess the security posture of networks and help identify potential vulnerabilities.

Installation

Nmap can be installed on various operating systems. Below are the installation methods for popular platforms:

  • Linux: Use the package manager for your distribution. For Debian-based systems, run sudo apt install nmap. For Red Hat-based systems, use sudo yum install nmap.
  • Windows: Download the installer from the official Nmap website.
  • macOS: Install via Homebrew with brew install nmap.

Basic Syntax

The basic syntax of the Nmap command is as follows:

nmap [options] [target]

Where [options] are the specific flags you want to use, and [target] is the IP address or hostname of the device you want to scan.

Discovery

Ping Scan

A simple way to check if a host is online.

nmap -sn 192.168.1.1

Subnet Discovery

Scan an entire subnet to find live hosts.

nmap -sn 192.168.1.0/24

Scanning

Port Scan

Scan for open ports on a target.

nmap -p 1-65535 192.168.1.1

Service Version Detection

Identify service versions running on open ports.

nmap -sV 192.168.1.1

Exploitation

Vulnerability Scanning

Integrate script scanning for vulnerabilities.

nmap --script vuln 192.168.1.1

Analysis

OS Detection

Detect the operating system of the target.

nmap -O 192.168.1.1

Evasion

Stealth Scan

Use a SYN scan for stealthy port scanning.

nmap -sS 192.168.1.1

Reporting

Output to File

Save scan results to a file for reporting.

nmap -oN scan_results.txt 192.168.1.1

Quick Reference Table

Flag Description
-sS Stealth SYN scan
-sV Service version detection
-O OS detection
-sn Ping scan (host discovery)

Pro Tips

  • Combine flags for complex scans, e.g., nmap -sS -sV -O -p 1-1000 192.168.1.0/24 for a comprehensive scan.
  • Use the –script option for specific vulnerability checks.
  • Always run Nmap with elevated privileges to ensure accurate scanning results.

Real-World Examples

Network Inventory Check

To perform a quick inventory check of devices on a network:

nmap -sn 192.168.1.0/24

External Audit on Specific Ports

Scanning external services for common ports:

nmap -p 22,80,443 example.com

Final Thoughts

Nmap is an essential tool in the arsenal of any cybersecurity professional. By mastering its usage, analysts can efficiently discover vulnerabilities and improve the overall security of their networks.