> For the complete documentation index, see [llms.txt](https://thamizhiniyancs.gitbook.io/cheatsheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://thamizhiniyancs.gitbook.io/cheatsheets/scanning-networks/nmap/nmap-commands.md).

# Nmap Commands

<table data-full-width="true"><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td><code>nmap -p- --min-rate=10000 &#x3C;Target IP></code></td><td>Perform all port scan fast ( Ideal for CTFs not for real world targets )</td></tr><tr><td><code>nmap -p 1-65535 -T4 -A -v &#x3C;Target IP></code></td><td>Perform intense scan on all TCP ports</td></tr><tr><td><code>nmap -p ports &#x3C;Target IP></code></td><td>Run Nmap to identify IoT devices using insecure HTTP ports for transmitting data</td></tr><tr><td><code>nmap -T4 -A -v -Pn &#x3C;Target IP></code></td><td>Perform Intense scan with no ping</td></tr><tr><td><code>nmap -T4 -A -v -PE -PS -PA Ports URL</code></td><td>Footprint Web Infrastructure: Service Discovery</td></tr><tr><td><code>nmap -sn &#x3C;Target IP></code></td><td>Perform ping scan</td></tr><tr><td><code>nmap -sn &#x3C;Target IP/Subnet></code></td><td>Disable port scanning, host discovery only</td></tr><tr><td><code>nmap -sn -PR &#x3C;Target IP></code></td><td>ARP Ping Scan</td></tr><tr><td><code>nmap -sn -PU &#x3C;Target IP></code></td><td>UDP Ping Scan</td></tr><tr><td><code>nmap -sn -PE &#x3C;Target IP></code></td><td>ICMP ECHO Ping Scan</td></tr><tr><td><code>nmap -sn -PE &#x3C;IP range></code></td><td>ICMP ECHO Ping Sweep</td></tr><tr><td><code>nnmap –sn –PP &#x3C;Target IP></code></td><td>ICMP Timestamp Ping Scan</td></tr><tr><td><code>nmap –sn –PM &#x3C;Target IP></code></td><td>ICMP Address Mask Ping Scan</td></tr><tr><td><code>nmap –sn –PS &#x3C;Target IP></code></td><td>TCP SYN Ping Scan</td></tr><tr><td><code>nmap –sn –PA &#x3C;Target IP></code></td><td>TCP ACK Ping Scan</td></tr><tr><td><code>nmap –sn –PO &#x3C;Target IP></code></td><td>IP Protocol Ping Scan</td></tr><tr><td><code>nmap -St -v &#x3C;Target IP></code></td><td>TCP Connect/ Full Open Scan</td></tr><tr><td><code>namp -sS -v &#x3C;Target IP></code></td><td>Stealth Scan (Half-open Scan)</td></tr><tr><td><code>nmap -sX -v &#x3C;Target IP></code></td><td>Xmas Scan</td></tr><tr><td><code>nmap -sM -v &#x3C;Target IP></code></td><td>TCP Maimon Scan</td></tr><tr><td><code>nmap -sA -v &#x3C;Target IP></code></td><td>TCP Connect/ Full Open Scan</td></tr><tr><td><code>nmap –badsum &#x3C;Target IP></code></td><td>Sending Bad Checksums</td></tr><tr><td><code>nmap --script smb-os-discovery.nse &#x3C;Target IP></code></td><td>OS Discovery using Nmap Script Engine</td></tr><tr><td><code>nmap -sV -T4 -O -F –version-light &#x3C;Target IP></code></td><td>Perform quick scan plus</td></tr><tr><td><code>nmap -sV -T4 -O -F –version-light scanme.nmap.org</code></td><td>Perform quick scan plus</td></tr><tr><td><code>nmap -sV –O –p &#x3C;Target IP> nmap -sV --script http-enum &#x3C;Target IP></code></td><td>NSE scripts to enumerate information about the target website/ web servers</td></tr><tr><td><code>nmap target IP address -p 80 --script http-frontpage-login</code></td><td>Checks whether target machines are vulnerable to anonymous Frontpage login</td></tr><tr><td><code>nmap --script http-passwd --script-args http-passwd.root</code></td><td>Checks if a web server is vulnerable to directory traversal by attempting to retrieve /etc/passwd or \boot.ini</td></tr><tr><td><code>nmap -sV --script http-enum &#x3C;Target domain></code></td><td>Analyze Web Applications: Identify exposed Files and Directories of the target webserver</td></tr><tr><td><code>nmap -iL list-of-ips.txt</code></td><td>Scan targets from a text file</td></tr><tr><td><code>nmap --script=sniffer-detect [Target IP Address/Range of IP addresses]</code></td><td>Command to detect NIC in promiscuous mode</td></tr><tr><td><code>nmap &#x3C;Target IP> --data Oxdeadbeef</code></td><td>Create Custom Packets by Appending Custom Binary Data</td></tr><tr><td><code>nmap &#x3C;Target IP> --data-string “ph34r my</code> |<code>33t skills”</code></td><td>Create Custom Packets by Appending Custom String</td></tr><tr><td><code>nmap &#x3C;Target IP> --data-string 5</code></td><td>Create Custom Packets by Appending Random Data</td></tr><tr><td><code>nmap –sU –p 500 &#x3C;Target IP></code></td><td>Perform a check on the status of ISAKMP over port 500</td></tr><tr><td><code>nmap -sR &#x3C;Target IP/network></code></td><td>Identify the RPC service running on the network</td></tr><tr><td><code>nmap --script hostmap &#x3C;host></code></td><td>Discover virtual domains with hostmap</td></tr><tr><td><code>nmap --script http-trace -p80 localhost</code></td><td>Detect a vulnerable server that uses the TRACE method</td></tr><tr><td><code>nmap --script http-google-email &#x3C;host></code></td><td>Harvest email accounts with http-google-email</td></tr><tr><td><code>nmap -p80 --script http-userdir -enum localhost</code></td><td>Enumerate users with http-userdir-enum</td></tr><tr><td><code>nmap -p80 --script http-trace &#x3C;host></code></td><td>Detect HTTP TRACE</td></tr><tr><td><code>nmap -p80 --script http-waf-detect --script-args=”http-wafdetect. uri=/testphp. vulnweb.com/artists.php,http-wafdetect.detectBodyChanges” www.modsecurity.org</code></td><td>Check if web server is protected by WAF/IPS</td></tr><tr><td><code>nmap --script http-enum -p80 &#x3C;host></code></td><td>Enumerate common web applications</td></tr><tr><td><code>nmap -p80 --script http-robots.txt &#x3C;host></code></td><td>Obtain robots.txt</td></tr><tr><td><code>nmap -p80 --script http-test.txt &#x3C;host></code></td><td>Obtain test.txt</td></tr><tr><td><code>nmap --script=asn-query,whois,ip-geolocation-maxmind &#x3C;Target IP></code></td><td>IP address Information</td></tr><tr><td><code>nmap --script=http-title &#x3C;Target IP/ Subnet></code></td><td>Gather page titles from HTTP services</td></tr><tr><td><code>nmap --script=http-headers &#x3C;Target IP/ Subnet></code></td><td>Get HTTP headers of web services</td></tr><tr><td><code>nmap --script=http-enum &#x3C;Target IP/ Subnet></code></td><td>Find web apps from known paths</td></tr><tr><td><code>nmap -n -Pn -sSU -pT:0-65535,U:0-65535 -v -A -oX &#x3C;Name>&#x3C;Target IP></code></td><td>Perform complete scan of the IoT device that checks for both TCP and UDP services and ports</td></tr><tr><td><code>nmap -sS -T4 -A -f -v &#x3C;Target IP></code></td><td>Packet Fragmentation/ SYN/FIN scan using Nmap</td></tr><tr><td><code>nmap -g 80 &#x3C;Target IP></code></td><td>Source Port Manipulation/ Use given source port number</td></tr><tr><td><code>nmap –sU –A –PN –n –pU:19,53,123,161 –script=ntp-monlist,dns-recursion,nmp-sysdescr &#x3C;Target IP/ network></code></td><td>Scan for UDP DDOS reflectors</td></tr><tr><td><code>nmap -6 -n -Pn -sSU -pT:0-65535,U:0-65535 -v -A -oX &#x3C;Name>&#x3C;Target IP></code></td><td>Identify the IPv6 capabilities of a device</td></tr><tr><td><code>nmap -T4 -A -v &#x3C;Target IP></code></td><td>Perform intense scan</td></tr><tr><td><code>nmap -T4 -A &#x3C;Target IP/Subnet></code></td><td>Identify vulnerable services on service port by attackers by using RPC Enumeration</td></tr><tr><td><code>nmap -p 23 &#x3C;Target Domain></code></td><td>Telnet Enumeration</td></tr><tr><td><code>nmap -p 23 --script telnet-ntlm-info &#x3C;Target IP></code></td><td>Enumerate information from remote Microsoft Telnet services with NTLM authentication enabled</td></tr><tr><td><code>nmap -p 23 –script telnet-brute.nse –script-args</code></td><td>Perform brute-force attack against telnet server</td></tr><tr><td><code>nmap -p 445 -A &#x3C;Target IP></code></td><td>Enumerate SMB service running on the target IP address/ SMB Enumeration</td></tr><tr><td><code>nmap -p 21 &#x3C;Target Domain></code></td><td>FTP Enumeration</td></tr><tr><td><code>nmap -p 69 &#x3C;Target Domain></code></td><td>Enumerate TFTP service running on the target domain</td></tr><tr><td><code>nmap -p 179 &#x3C;Target IP></code></td><td>BGP Enumeration</td></tr><tr><td><code>nmap -sS -sU -T4 -A -v &#x3C;Target IP></code></td><td>Perform intense scan and scanning for UDP</td></tr><tr><td><code>nmap -sV -v -p 139,445 &#x3C;Target IP/Subnet></code></td><td>Detect all exposed Netbios servers on the subnet</td></tr><tr><td><code>nmap -sV -v --script nbstat.nse &#x3C;Target IP></code></td><td>map’s nbstat NSE script allow attackers to retrieve target’s NetBIOS names and MAC addresses</td></tr><tr><td><code>nmap -sU --script nbstat.nse -p 137 &#x3C;Target IP address></code></td><td>Find target Netbios name</td></tr><tr><td><code>nmap --script-args=unsafe=1 --script smb-check-vulns.nse -p 445 &#x3C;Target IP address></code></td><td>Check if Netbios servers are vulnerable to MS08-067</td></tr><tr><td><code>nmap -sV --version-intensity 0 &#x3C;Target IP></code></td><td>Lighter banner grabbing detection</td></tr><tr><td><code>nmap -sV --version-intensity 5 &#x3C;Target IP></code></td><td>More aggressive Service Detection</td></tr><tr><td><code>nmap -sV &#x3C;Target IP></code></td><td>Attempts to determine the version of service running/ Standard service detection/ Service Version Discovery in Zenmap</td></tr><tr><td><code>nmap --script-help=ssl-heartbleed</code></td><td>Get help for a script</td></tr><tr><td><code>nmap --script dns-zonetransfer.nse --script-args dns-zonetransfer.domain=&#x3C;domain> -p53 &#x3C;hosts></code></td><td>Attempts to pull a zone file (AXFR) from a DNS server</td></tr><tr><td><code>nmap --script http-robots.txt &#x3C;hosts></code></td><td>Harvests robots.txt files from discovered web servers</td></tr><tr><td><code>nmap --script smb-brute.nse -p445 &#x3C;hosts></code></td><td>Attempts to determine valid username and password combinations via automated guessing</td></tr><tr><td><code>nmap --script smb-psexec.nse –script-args=smbuser=&#x3C;username>,smbpass=&#x3C;password>[,config=&#x3C;config>] -p445 &#x3C;hosts></code></td><td>Attempts to run a series of programs on the target machine, using credentials provided as scriptargs</td></tr><tr><td><code>nmap -sV -p 443 --script=ssl-heartbleed &#x3C;Target IP/Subnet></code></td><td>Detect Heartbleed SSL Vulnerability</td></tr><tr><td><code>nmap &#x3C;Target IP>-50 -sL --dns-server &#x3C;Target IP></code></td><td>Query the Internal DNS for hosts, list targets only</td></tr><tr><td><code>nmap -iR 10 -sn -traceroute</code></td><td>Traceroute to random targets, no port scan</td></tr><tr><td><code>nmap &#x3C;Target IP>-1/24 -PR -sn -vv</code></td><td>Arp discovery only on local network, no port scan</td></tr><tr><td><code>nmap -iR 10 -PS22-25,80,113,1050,35000 -v -sn</code></td><td>Discovery only on ports x, no port scan</td></tr><tr><td><code>nmap -sP &#x3C;Target IP/Subnet></code></td><td>Ping scans the network, listing machines that respond to ping</td></tr><tr><td><code>nmap -v -sS -A -T4 &#x3C;Target IP></code></td><td>Prints verbose output, runs stealth syn scan, T4 timing, OS and version detection, traceroute and scripts against target services</td></tr><tr><td><code>nmap -v -sV -O -sS -T5 &#x3C;Target IP></code></td><td>Prints verbose output, runs stealth syn scan, T5 timing, OS and version detection</td></tr><tr><td><code>nmap -iL ip-addresses.txt</code></td><td>Scans a list of IP addresses</td></tr><tr><td><code>nmap — script-args=unsafe=1 —script smb-check-vulns.nse -p 445 &#x3C;Target IP></code></td><td>Check if Netbios servers are vulnerable to MS08–067</td></tr><tr><td><code>nmap –Pn –p- -sI zombie target</code></td><td>Attack</td></tr><tr><td><code>nmap –b ftp rely host</code></td><td>FTP Bounce Scan :@:. is the name or IP address of a vulnerable FTP server</td></tr><tr><td><code>nmap -T0 &#x3C;Target IP></code></td><td>Paranoid (0) Intrusion Detection System evasion</td></tr><tr><td><code>nmap -T1 &#x3C;Target IP></code></td><td>Sneaky (1) Intrusion Detection System evasion</td></tr><tr><td><code>nmap -T2 &#x3C;Target IP></code></td><td>Polite (2) slows down the scan to use less bandwidth and use less target machine resources</td></tr><tr><td><code>nmap -T3 &#x3C;Target IP></code></td><td>Normal (3) default speed</td></tr><tr><td><code>nmap -T4 &#x3C;Target IP></code></td><td>Aggressive (4) speeds scan; assumes you are on a reasonably fast and reliable network</td></tr><tr><td><code>nmap -T5 &#x3C;Target IP></code></td><td>Insane (5) speeds scan; assumes you are on extraordinarily fast network</td></tr><tr><td><code>nmap --script=ftp &#x3C;Target IP></code></td><td>Scan with a single script</td></tr><tr><td><code>nmap --script=http* &#x3C;Target IP></code></td><td>Scan with a wildcard script</td></tr><tr><td><code>nmap --script=banner,http &#x3C;Target IP></code></td><td>Scan with two scripts</td></tr><tr><td><code>nmap --script "not intrusive" &#x3C;Target IP></code></td><td>Scan default, but remove intrusive scripts</td></tr><tr><td><code>nmap -Pn --script=http-sitemap-generator xyz.com</code></td><td>HTTP site map generator</td></tr><tr><td><code>nmap -n -Pn -p 80 --open -sV -vvv --script banner,http-title -iR 1000</code></td><td>Fast search for random web servers</td></tr><tr><td><code>nmap -Pn --script=dns-brute xyz.com</code></td><td>Brute forces DNS hostnames guessing subdomain</td></tr><tr><td><code>nmap -n -Pn -vv -O -sV --script smb-enum*,smb-ls,smb-mbenum,smb-os-discovery,smb-s*,smb-vuln*,smbv2* -vv &#x3C;Target IP></code></td><td>Safe SMB scripts to run</td></tr><tr><td><code>nmap --script whois*&#x3C;Target Domain></code></td><td>Whois query</td></tr><tr><td><code>nmap -p80 --script http-unsafe-output-escaping &#x3C;Target Website></code></td><td>Detect cross site scripting vulnerabilities</td></tr><tr><td><code>nmap -p80 --script http-sql-injection &#x3C;Target></code></td><td>Check for SQL injections</td></tr><tr><td><code>nmap --data-length x &#x3C;Target IP></code></td><td>Appends random data to sent packets</td></tr><tr><td><code>nmap -oN file.file --append-output &#x3C;Target IP></code></td><td>Append a scan to a previous scan file</td></tr><tr><td><code>nmap --iflist</code></td><td>Shows the host interface and routes</td></tr><tr><td><code>nmap -6 2607:f0d2:5664:51::5</code></td><td>Enable IPV6 scanning</td></tr><tr><td><code>nmap -T0 -b username:password@ftpserver.tld :21 victim.tld</code></td><td>Uses the username “username”, the password “password”, the FTP server “ftpserver.tld” and port 21 on said server to scan victim.tld.</td></tr><tr><td><code>nmap -sU -sT -p U:[ports],T:[ports] &#x3C;Target IP></code></td><td>Scan ports by protocol</td></tr><tr><td><code>nmap -sV –version-trace &#x3C;Target IP></code></td><td>Troubleshooting version scans</td></tr><tr><td><code>nmap –script [script.nse] &#x3C;Target IP></code></td><td>Execute individual scripts</td></tr><tr><td><code>nmap –script [expression] &#x3C;Target IP></code></td><td>Execute multiple scripts</td></tr><tr><td><code>nmap –script [category] &#x3C;Target IP></code></td><td>Execute scripts by category</td></tr><tr><td><code>nmap –script [category1,category2, etc]</code></td><td>Execute multiple scripts categories</td></tr><tr><td><code>nmap –script [script] –script-trace &#x3C;Target IP></code></td><td>Troubleshoot scripts</td></tr><tr><td><code>$ docker -H &#x3C;docker host> run --network=host --rm marsmensch/nmap -ox &#x3C;IP Range></code></td><td>Use Nmap to scan the host’s internal network to identify running services</td></tr><tr><td><code>ndiff [scan1.xml] [scan2.xml]</code></td><td>Comparison using Ndiff</td></tr><tr><td><code>ndiff -v [scan1.xml] [scan2.xml]</code></td><td>Ndiff verbose mode</td></tr><tr><td><code>ndiff –xml [scan1.xm]</code></td><td>XML output mode</td></tr></tbody></table>
