Practical Security Tool Cheatsheet for Nmap

πŸ“± Mobile Security Tips

Mike Torres — Android Security Engineer

What is Nmap?

Nmap (Network Mapper) is an open-source tool designed for network discovery and security auditing. It is widely used by security professionals for tasks such as identifying hosts and services on a network, discovering open ports, and detecting vulnerabilities.

Installation

Nmap can be installed on various platforms. Below are the steps for major operating systems:

Linux: Use the package manager, for example:

sudo apt-get install nmap

Windows: Download the installer from the Nmap website and follow the setup instructions.
macOS: Use Homebrew:

brew install nmap

Basic Syntax

The basic syntax of Nmap is as follows:

nmap [options]

Where can be an IP address, domain name, or range of addresses.

Discovery

Ping Scan

To quickly determine which hosts are up in a network:

nmap -sn 

Service Version Detection

Identify services running on open ports:

nmap -sV 

Scanning

TCP Connect Scan

Perform a full TCP connection:

nmap -sT 

Quick Scan

Quickly scan the most common 1,000 ports:

nmap -F 

Exploitation

OS Detection

Identify the operating system running on a host:

nmap -O 

Script Scan

Use Nmap scripts to check for vulnerabilities:

nmap -sC 

Analysis

Output in XML

Save scan results in XML format for later analysis:

nmap -oX output.xml 

Evasion

Fragment Packets

Evade firewalls using packet fragmentation:

nmap -f 

Reporting

Save as Plain Text

Output results to plain text file:

nmap -oN output.txt 

Quick Reference Table

Flag Description
-sT TCP Connect Scan
-O Enable OS Detection
-sV Service Version Detection
-sn Ping Scan
-f Fragment packets

Pro Tips

  • Use nmap -p- to scan all 65,535 ports.
  • Combine options for comprehensive scans, like nmap -sS -A for a stealth scan combined with OS and version detection.
  • Run background scans with nmap -Pn &.

Real-World Examples

Example 1: Scanning a single target to identify services and OS:

nmap -sV -O 

Example 2: Scanning an entire subnet with output saved:

nmap -oA subnet_scan -sS 192.168.1.0/24