Nmap Security Tool Cheatsheet

📱 Mobile Security Tips

Sarah Chen — iOS Security Specialist

What is Nmap?

Nmap (Network Mapper) is an open-source tool for network exploration and security auditing. It is widely used by network administrators and penetration testers to discover hosts and services on a computer network by sending packets and analyzing the responses.

Installation

Nmap can be installed on various operating systems. Below are the instructions for some common platforms:

  • Ubuntu/Debian: Run sudo apt install nmap
  • CentoS/RHEL: Run sudo yum install nmap
  • Windows: Download the installer from the official Nmap website.
  • macOS: Use Homebrew with brew install nmap.

Basic Syntax

The basic syntax of Nmap is:

nmap [options] [target]

Where [options] are the flags you’ll use, and [target] can be an IP address, hostname, or a subnet.

Discovery

To identify live hosts within a network:

nmap -sn 192.168.1.0/24

This command performs a **ping scan** to identify live hosts on the subnet.

Scanning

For service version detection:

nmap -sV 192.168.1.1

This detects the version of services running on open ports.

Exploitation

To script Nmap for more complex interactions:

nmap --script  -p  

Replace with the desired Nmap script from the script directory.

Analysis

To output scan results in a machine-readable format like XML:

nmap -oX result.xml 192.168.1.1

This allows for further analysis and integration with other tools.

Evasion

To evade firewalls, use:

nmap -Pn -p 80,443 192.168.1.1

This command skips host discovery and tries to connect to specific ports directly.

Reporting

Generate a comprehensive HTML report:

nmap -oX result.xml -oN result.txt -oG result.gnmap 192.168.1.0/24

Quick Reference Table

Flag Description
-sP Ping scan
-sV Service version detection
-oX Output results in XML format
-Pn Skip host discovery

Pro Tips

  • Use -T4 for faster scans while balancing accuracy: nmap -T4 192.168.1.0/24
  • Combine scans with -oA to store in all formats: nmap -oA result 192.168.1.1
  • Utilize Nmap’s scripting engine for specialized probes: nmap --script vuln 192.168.1.1

Real-World Examples

Scanning a range of IPs for common vulnerabilities:

nmap -p 22,80 --script http-vuln* 192.168.1.0/24

This command targets HTTP vulnerabilities on port 80 across the specified network.

Final note: Always ensure you have permission before scanning a network!