Nmap

A powerful network scanning tool used to discover hosts, open ports, running services, and operating systems on a target network.

Host Discovery

Command
nmap -sP 10.0.0.0/24
Description

Ping sweep to find live hosts on a subnet

Command
nmap -iL targets.txt
Description

Scan a list of targets from a text file

Port Scanning

Command
nmap [target] -sT
Description

Scan TCP ports only

Command
nmap [target] -sU -T5
Description

Scan UDP ports (slower, use -T5 to speed up)

Command
nmap [target] -sS
Description

Stealth SYN scan (default technique, less likely to be logged)

Command
nmap [target] -p 22-150
Description

Scan a specific port range

Command
nmap [target] -p- -T5
Description

Scan all 65535 ports

Command
nmap [target] --top-ports 100
Description

Scan only the most common ports for a quick overview

Service & OS Detection

Command
nmap [target] -sV
Description

Probe open ports for service/version info

Command
nmap [target] -O
Description

Enable OS detection

Command
nmap [target] -sT -O -sV -T4
Description

Combined OS + version detection

Command
nmap [target] -A -T4
Description

Aggressive scan: OS, version, scripts, traceroute

Scripting

Command
nmap [target] -sC -T5
Description

Run default NSE scripts on open ports

Command
nmap [target] --script http-enum.nse
Description

Run a specific NSE script against the target

Output

Command
nmap [target] --script http-enum.nse -oN test.txt
Description

Save scan output in normal format to a file

Command
nmap [target] -sV -T5 -oA scan-results
Description

Save output in all major formats at once

Vulnerability Investigation

Command
nmap [target] -p 3632 -sV
Description

Investigate an unknown/suspicious port's version

Command
nmap -p 3632 [target] --script distcc-cve2004-2687 --script-args="distcc-cve2004-2687.cmd='id'"
Description

Run a vulnerability-specific NSE script with command execution

Timing

Command
nmap [target] -T0
Description

Paranoid timing — extremely slow requests, lowest chance of detection, used to evade strict IDS

Command
nmap [target] -T1
Description

Sneaky timing — still very slow, slightly faster than paranoid

Command
nmap [target] -T2
Description

Polite timing — slows down to use less bandwidth and target resources

Command
nmap [target] -T3
Description

Normal timing — the default speed when no timing option is specified

Command
nmap [target] -T4
Description

Aggressive timing — faster scans; not recommended against real targets due to increased detection risk

Command
nmap [target] -T5
Description

Insane timing — fastest and most aggressive, sacrifices accuracy for speed; not recommended against real targets due to very high detection risk