nmap -sn $ipAddress | grep -oP '(?<=Nmap scan report for )[^ ]*'nmap -p- --open -sS --min-rate 5000 -vvv -n -Pn $ipAddressnmap -sCV --min-rate=5000 $ipAddress -Pn -vvv -oN targeted
nmap 192.168.1.1 # Scan single IPnmap 192.168.1.1 192.168.2.1 # Scan specific IPsnmap 192.168.1.1-254 # Scan a rangenmap scanme.nmap.org # Scan a domainnmap 192.168.1.0/24 # Scan using CIDRnmap -iL targets.txt # Scan targets from filenmap -iR 100 # Scan 100 random hostsnmap --exclude 192.168.1.1 # Exclude listed hosts
# Simple Scansnmap target # Basic scan of a targetnmap 192.168.1.1/24 # Scan entire subnetnmap 192.168.1.1-50 # IP range
# Scan Typesnmap -sS target # TCP SYN scan (Default)nmap -sT target # TCP connect scan (Default without root)nmap -sU target # UDP scannmap -sA target # TCP ACK scannmap -sW target # TCP Window scannmap -sM target # TCP Maimon scan # Port Selectionnmap -p 80 target # Scan specific portnmap -p 80-443 target # Port rangenmap -p- target # All ports (1-65535)nmap -F target # Fast scan (100 ports)nmap --top-ports 1000 # Top 1000 portsnmap -p http,https # Scan by service namenmap -p U:53,T:21-25,80 # Mixed TCP/UDP scannmap -p-65535 # Start from port 1nmap -p0- # Scan through port 65535
nmap -sL 192.168.1.1-3 # No Scan, list targets onlynmap -sn target # Ping scan (disable port scan)nmap -Pn target # Skip ping (assume host is up)nmap -PS22-25,80 target # TCP SYN discovery on portsnmap -PA22-25,80 target # TCP ACK discovery on portsnmap -PU53 target # UDP discovery on portnmap -PR 192.168.1.1/24 # ARP discovery on local networknmap -n target # Never do DNS resolution
# Version Detectionnmap -sV target # Detect service versionsnmap -sV --version-light target # Faster version detectionnmap -sV --version-all target # Try all probesnmap -sV --version-intensity 8 # Set intensity (0-9)nmap -A target # Aggressive scan # Script Scanningnmap -sC target # Default script scannmap --script=vuln target # Vulnerability scriptsnmap --script=safe target # Safe scripts onlynmap --script=auth target # Authentication scripts
nmap -O target # OS detectionnmap -O --osscan-guess target # Aggressive OS guessnmap -O --osscan-limit target # Limit OS detection to promising targetsnmap -O --max-os-tries 1 target # Set maximum OS detection triesnmap -A target # Enable OS detection, version detection, scripts, and traceroute
# Timing Templatesnmap -T0 target # Paranoid - IDS evasionnmap -T1 target # Sneaky - IDS evasionnmap -T2 target # Polite - slower, resource friendlynmap -T3 target # Normal - default speednmap -T4 target # Aggressive - fast, reliable networksnmap -T5 target # Insane - very aggressive # Performance Controls--host-timeout <time> # Give up after specified time--min-rate <number> # Send packets no slower than <number>/sec--max-rate <number> # Send packets no faster than <number>/sec--min-parallelism <numprobes> # Probe parallelization minimum--max-parallelism <numprobes> # Probe parallelization maximum--min-hostgroup/max-hostgroup # Parallel host scan group sizes
nmap -oN output.txt target # Normal outputnmap -oG output.txt target # Grepable outputnmap -oX output.xml target # XML outputnmap -oA output target # Output in all formatsnmap -v target # Verbose outputnmap -vv target # Very verbose outputnmap --reason target # Show port state reasonsnmap -d target # Debuggingnmap --packet-trace target # Show all packets
# Basic Script Usagenmap --script=default target # Default safe scriptsnmap --script=banner target # Single script scannmap --script=http* target # Wildcard script scannmap --script "not intrusive" target # Exclude intrusive scripts # Useful Script Examplesnmap --script=http-sitemap-generator scanme.nmap.org # Generate HTTP site mapnmap --script=dns-brute domain.com # DNS subdomain brute forcenmap --script=whois* domain.com # Whois queriesnmap --script=http-sql-injection target # SQL injection testnmap --script=smb-enum*,smb-ls,smb-vuln* target # SMB enumeration and checks
nmap -f target # Fragment packetsnmap --mtu 32 target # Set specific MTU sizenmap -D decoy1,decoy2,ME target # Cloak scan with decoysnmap -S spoofed-IP target # Spoof source addressnmap -g 53 target # Use specific source portnmap --proxies proxy-url target # Use HTTP/SOCKS4 proxynmap --data-length 200 target # Append random data # Combined Evasion Examplenmap -f -t 0 -n -Pn --data-length 200 -D 192.168.1.101,192.168.1.102 target
# Web Server Discoverynmap -p80 -sV -oG - --open 192.168.1.0/24 | grep open # Live Host Discoverynmap -iR 10 -n -oX out.xml | grep "Nmap" | cut -d " " -f5 > live-hosts.txt # Compare Scan Resultsndiff scan1.xml scan2.xml # Convert to HTMLxsltproc nmap.xml -o nmap.html # Local Network ARP Scannmap -PR -sn 192.168.1.0/24 -vv