hyperreal.coffee

Target specification

ExampleDescription
nmap 192.168.1.1Scan a single IP
nmap 192.168.1.1 192.168.2.1Scan specific IPs
nmap 192.168.1.1-254Scan a range
nmap scanme.nmap.orgScan a domain
nmap 192.168.1.0/24Scan using CIDR notation
nmap -iL targets.txtScan targets from a file
nmap -iR 100Scan 100 random hosts
nmap -exclude 192.168.1.1Exclude listed hosts

Nmap scan techniques

ExampleDescription
nmap 192.168.1.1 -sSTCP SYN port scan (default)
nmap 192.168.1.1 -sTTCP connect port scan
nmap 192.168.1.1 -sUUDP port scan
nmap 192.168.1.1 -sATCP ACK port scan
nmap 192.168.1.1 -sWTCP Window port scan
nmap 192.168.1.1 -sMTCP Maimon port scan

Host discovery

ExampleDescription
nmap 192.168.1.1-3 -sLNo scan. List targets only
nmap 192.168.1.1/24 -snDisable port scanning. Host discovery only.
nmap 192.168.1.1-5 -PnDisable host discovery. Port scan only.
nmap 192.168.1.1-5 -PS22-25,80TCP SYN discovery on ports 22-25, 80 (Port 80 by default)
nmap 192.168.1.1-5 -PA22-25,80TCP ACK discovery on ports 22-25, 80 (Port 80 by default)
nmap 192.168.1.1-5 -PU53UDP discovery on port 53. (Port 40125 by default)
nmap 192.168.1.1-1/24 -PRARP discovery on local network
nmap 192.168.1.1 -nNever do DNS resolution

Port specification

ExampleDescription
nmap 192.168.1.1 -p 21Port scan for port 21
nmap 192.168.1.1 -p 21-100Port scan for range 21-100
nmap 192.168.1.1 -p U:53,T:21-25,80Port scan multiple TCP and UDP ports
nmap 192.168.1.1 -p-Port scan all ports
nmap 192.168.1.1 -p http,httpsPort scan from service name
nmap 192.168.1.1 -FFast port scan (100 ports)
nmap 192.168.1.1 -top-ports 2000Port scan the top 2000 ports
nmap 192.168.1.1 -p-65535Leaving off the initial port in range makes the scan start at port 1
nmap 192.168.1.1 -p0-Leaving off the end port in range makes the scan go through to port 65535

Service and version detection

ExampleDescription
nmap 192.168.1.1 -sVAttempts to determine version of the service running on port.
nmap 192.168.1.1 -sV -version-intensity 8Intensity level 0-9. Higher number increases possibility of correctness.
nmap 192.168.1.1 -sV -version-lightEnable light mode. Lower possibility of correctness. Faster.
nmap 192.168.1.1 -sV -version-allEnable intensity level 9. Higher possibility of correctness. Slower.
nmap 192.168.1.1 -AEnable OS detection, version detection, script scanning, and traceroute.

OS detection

ExampleDescription
nmap 192.168.1.1 -ORemote OS detection using TCP/IP stack fingerprinting
nmap 192.168.1.1 -O -osscan-limitIf at least one open and one closed TCP port are not found it will not try OS detection against host.
nmap 192.168.1.1 -P -osscan-guessMakes nmap guess more aggressively.
nmap 192.168.1.1 -O -max-os-tries 1Set the maximum number of OS detection tries
nmap 192.168.1.1 -AEnables OS detection, version detection, script scanning, and traceroute.

Timing and performance

ExampleDescription
nmap 192.168.1.1 -T0Paranoid (0) IDS evasion
nmap 192.168.1.1 -T1Sneaky (1) IDS evasion
nmap 192.168.1.1 -T2Polite (2) slows down the scan to use less bandwidth and use less target machine resources.
nmap 192.168.1.1 -T3Normal (3) which is default speed.
nmap 192.168.1.1 -T4Aggressive (4) speed scans. Assumes you are on a reasonably fast and reliable network.
nmap 192.168.1.1 -T5Insane (5) speed scan. Assumes you are on an extraordinarily fast network.

Timing and performance switches

ExampleDescription
-host-timeout 1s; -host-timeout 4m;Give up on target after this long.
-min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout 4m;Specifies probe round trip time.
-min-hostgroup/max-hostgroup 50Parallel host scan group sizes
-min-parallelism/max-parallelism 10Probe parallelization
-max-retries 3Specify the max number of port scan probe retransmissions.
-min-rate 100Send packets to no slower than 100 per second
-max-rate 100Send packets no faster than 100 per second

NSE scripts

ExampleDescription
nmap 192.168.1.1 -sCScan with default NSE scripts. Useful and safe.
nmap 192.168.1.1 -script defaultScan with default NSE scripts.
nmap 192.168.1.1 -script=bannerScan with single script. Example banner.
nmap 192.168.1.1 -script=http*Scan with a wildcard. Example http.
nmap 192.168.1.1 -script=http,bannerScan with two scripts. http and banner.
nmap 192.168.1.1 -script "not intrusive"Scan default, but remove intrusive scripts.
nmap -script snmp-sysdescr -script-args snmpcommunity=admin 192.168.1.1NSE script with arguments

Useful NSE script examples

ExampleDescription
nmap -Pn -script=http-sitemap-generator scanme.nmap.orghttp site map generator
nmap -n -Pn -p 80 -open -sV -vvv -script banner,http-title -iR 1000Fast search for random web servers
nmap -Pn -script=dns-brute domain.comBrute forces DNS hostnames guessing subdomains
nmap -n -Pn -vv -O -sV -script smb-enum*,smb-ls,smb-mbenum,smb-os-discovery,smb-s*,smb-vuln*,smbv2* -vv 192.168.1.1Safe SMB scripts to run
nmap -script whois* domain.comWhois query
nmap -p80 -script http-unsafe-output-escaping scanme.nmap.orgDetect cross site scripting vulnerabilities
nmap -p80 -script http-sql-injection scanme.nmap.orgCheck for SQL injections

Firewall/IDS evasion and spoofing

ExampleDescription
nmap 192.168.1.1 -fRequested scan (including ping scans) use tiny fragmented IP packets. Harder for packet filters.
nmap 192.168.1.1 -mtu 32Set your own offset size
nmap -D 192.168.1.101,192.168.1.102,192.168.1.103Send scans from spoofed IPs
nmap -D decoy-ip1,decoy-ip2,your-own-ipSame as above
nmap -S www.microsoft.com www.facebook.comScan Facebook from Microsoft (-e eth0 -Pn may be required
nmap -g 53 192.168.1.1Use given source port number
nmap -proxies http://192.168.1.1:8080,http://192.168.1.2:8080 192.168.1.1Relay connections through HTTP/SOCKS4 proxies
nmap -data-length 200 192.168.1.1Appends random data to sent packets

Output

ExampleDescription
nmap 192.168.1.1 -oN normal.fileNormal output to the file normal.file
nmap 192.168.1.1 -oX xml.fileXML output to the file xml.file
nmap 192.168.1.1 -oG grep.fileGrepable output to the file grep.file
nmap 192.168.1.1 -oA resultsOutput in the three major formats at once
nmap 192.168.1.1 -oG -Grepable output to screen. -oN, -oX also usable.
nmap 192.168.1.1 -oN file.txt -append-outputAppend a scan to a previous scan file
nmap 192.168.1.1 -vIncrease verbosity level (use -vv or more)
nmap 192.168.1.1 -dIncrease debugging level (use -dd or more)
nmap 192.168.1.1 -reasonDisplay the reason a port is in a particular state, same output as -vv
nmap 192.168.1.1 -openOnly show open (or possibly open) ports
nmap 192.168.1.1 -T4 -packet-traceShow all packets sent and received
nmap -iflistShows the host interfaces and routes
nmap -resume results.fileResume a scan from results.file

Helpful nmap output examples

ExampleDescription
`nmap -p80 -sV -oG - -open 192.168.1.1/24grep open`
`nmap -iR 10 -n -oX out.xmlgrep “Nmap”
`nmap -iR 10 -n -oX out2.xmlgrep “Nmap”
ndiff scan.xml scan2.xmlCompare the output of two scan results
xsltproc nmap.xml -o nmap.htmlConvert nmap xml files to html files

Other useful nmap commands

ExampleDescription
nmap -iR 10 -PS22-25,80,113,1050,35000 -v -snDiscovery only on ports X, no port scan
nmap 192.168.1.1-1/24 -PR -sn -vvARP discovery only on local network, no port scan
nmap -iR 10 -sn -tracerouteTraceroute to random targets, no port scan
nmap 192.168.1.1-50 -sL -dns-server 192.168.1.1Query the internal DNS for hosts, list targets only
nmap 192.168.1.1 --packet-traceShow the details of the packets that are sent and received during a scan and capture the traffic

Reply to this post by email ↪