1NMAP(1)                      Nmap Reference Guide                      NMAP(1)
2
3
4

NAME

6       nmap - Network exploration tool and security / port scanner
7

SYNOPSIS

9       nmap [Scan Type...] [Options] {target specification}
10

DESCRIPTION

12       Nmap (“Network Mapper”) is an open source tool for network exploration
13       and security auditing. It was designed to rapidly scan large networks,
14       although it works fine against single hosts. Nmap uses raw IP packets
15       in novel ways to determine what hosts are available on the network,
16       what services (application name and version) those hosts are offering,
17       what operating systems (and OS versions) they are running, what type of
18       packet filters/firewalls are in use, and dozens of other
19       characteristics. While Nmap is commonly used for security audits, many
20       systems and network administrators find it useful for routine tasks
21       such as network inventory, managing service upgrade schedules, and
22       monitoring host or service uptime.
23
24       The output from Nmap is a list of scanned targets, with supplemental
25       information on each depending on the options used. Key among that
26       information is the “interesting ports table”. That table lists the port
27       number and protocol, service name, and state. The state is either open,
28       filtered, closed, or unfiltered. Open means that an application on the
29       target machine is listening for connections/packets on that port.
30       Filtered means that a firewall, filter, or other network obstacle is
31       blocking the port so that Nmap cannot tell whether it is open or
32       closed.  Closed ports have no application listening on them, though
33       they could open up at any time. Ports are classified as unfiltered when
34       they are responsive to Nmap's probes, but Nmap cannot determine whether
35       they are open or closed. Nmap reports the state combinations
36       open|filtered and closed|filtered when it cannot determine which of the
37       two states describe a port. The port table may also include software
38       version details when version detection has been requested. When an IP
39       protocol scan is requested (-sO), Nmap provides information on
40       supported IP protocols rather than listening ports.
41
42       In addition to the interesting ports table, Nmap can provide further
43       information on targets, including reverse DNS names, operating system
44       guesses, device types, and MAC addresses.
45
46       A typical Nmap scan is shown in Example 14.1, “A representative Nmap
47       scan”. The only Nmap arguments used in this example are -A, to enable
48       OS and version detection, -T4 for faster execution, and then the two
49       target hostnames.  Example 14.1. A representative Nmap scan.sp
50       # nmap -A -T4 scanme.nmap.org playground
51
52       Starting nmap ( http://insecure.org/nmap/ )
53       Interesting ports on scanme.nmap.org (205.217.153.62):
54       (The 1663 ports scanned but not shown below are in state: filtered)
55       PORT    STATE  SERVICE VERSION
56       22/tcp  open   ssh     OpenSSH 3.9p1 (protocol 1.99)
57       53/tcp  open   domain
58       70/tcp  closed gopher
59       80/tcp  open   http    Apache httpd 2.0.52 ((Fedora))
60       113/tcp closed auth
61       Device type: general purpose
62       Running: Linux 2.4.X|2.5.X|2.6.X
63       OS details: Linux 2.4.7 - 2.6.11, Linux 2.6.0 - 2.6.11
64       Uptime 33.908 days (since Thu Jul 21 03:38:03 2005)
65
66       Interesting ports on playground.nmap.org (192.168.0.40):
67       (The 1659 ports scanned but not shown below are in state: closed)
68       PORT     STATE SERVICE       VERSION
69       135/tcp  open  msrpc         Microsoft Windows RPC
70       139/tcp  open  netbios-ssn
71       389/tcp  open  ldap?
72       445/tcp  open  microsoft-ds  Microsoft Windows XP microsoft-ds
73       1002/tcp open  windows-icfw?
74       1025/tcp open  msrpc         Microsoft Windows RPC
75       1720/tcp open  H.323/Q.931   CompTek AquaGateKeeper
76       5800/tcp open  vnc-http      RealVNC 4.0 (Resolution 400x250; VNC TCP port: 5900)
77       5900/tcp open  vnc           VNC (protocol 3.8)
78       MAC Address: 00:A0:CC:63:85:4B (Lite-on Communications)
79       Device type: general purpose
80       Running: Microsoft Windows NT/2K/XP
81       OS details: Microsoft Windows XP Pro RC1+ through final release
82       Service Info: OSs: Windows, Windows XP
83
84       Nmap finished: 2 IP addresses (2 hosts up) scanned in 88.392 seconds
85
86       The newest version of Nmap can be obtained from
87       http://insecure.org/nmap/. The newest version of the man page is
88       available from http://insecure.org/nmap/man/.
89

OPTIONS SUMMARY

91       This options summary is printed when Nmap is run with no arguments, and
92       the latest version is always available at
93       http://insecure.org/nmap/data/nmap.usage.txt. It helps people remember
94       the most common options, but is no substitute for the in-depth
95       documentation in the rest of this manual. Some obscure options aren't
96       even included here.
97
98       Nmap 4.20RC1 ( http://insecure.org )
99       Usage: nmap [Scan Type(s)] [Options] {target specification}
100       TARGET SPECIFICATION:
101         Can pass hostnames, IP addresses, networks, etc.
102         Ex: scanme.nmap.org, 192.168.0.1; 10.0.0-255.1-254
103         -iL <inputfilename>: Input from list of hosts/networks
104         -iR <num hosts>: Choose random targets
105         --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
106         --excludefile <exclude_file>: Exclude list from file
107       HOST DISCOVERY:
108         -sL: List Scan - simply list targets to scan
109         -sP: Ping Scan - go no further than determining if host is online
110         -P0: Treat all hosts as online -- skip host discovery
111         -PS/PA/PU [portlist]: TCP SYN/ACK or UDP discovery to given ports
112         -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
113         -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
114         --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
115         --system-dns: Use OS's DNS resolver
116       SCAN TECHNIQUES:
117         -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
118         -sU: UDP Scan
119         -sN/sF/sX: TCP Null, FIN, and Xmas scans
120         --scanflags <flags>: Customize TCP scan flags
121         -sI <zombie host[:probeport]>: Idlescan
122         -sO: IP protocol scan
123         -b <ftp relay host>: FTP bounce scan
124       PORT SPECIFICATION AND SCAN ORDER:
125         -p <port ranges>: Only scan specified ports
126           Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080
127         -F: Fast - Scan only the ports listed in the nmap-services file)
128         -r: Scan ports consecutively - don't randomize
129       SERVICE/VERSION DETECTION:
130         -sV: Probe open ports to determine service/version info
131         --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
132         --version-light: Limit to most likely probes (intensity 2)
133         --version-all: Try every single probe (intensity 9)
134         --version-trace: Show detailed version scan activity (for debugging)
135       OS DETECTION:
136         -O: Enable OS detection (try 2nd generation w/fallback to 1st)
137         -O2: Only use the new OS detection system (no fallback)
138         -O1: Only use the old (1st generation) OS detection system
139         --osscan-limit: Limit OS detection to promising targets
140         --osscan-guess: Guess OS more aggressively
141       TIMING AND PERFORMANCE:
142         Options which take <time> are in milliseconds, unless you append 's'
143         (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
144         -T[0-5]: Set timing template (higher is faster)
145         --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
146         --min-parallelism/max-parallelism <time>: Probe parallelization
147         --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
148             probe round trip time.
149         --max-retries <tries>: Caps number of port scan probe retransmissions.
150         --host-timeout <time>: Give up on target after this long
151         --scan-delay/--max-scan-delay <time>: Adjust delay between probes
152       FIREWALL/IDS EVASION AND SPOOFING:
153         -f; --mtu <val>: fragment packets (optionally w/given MTU)
154         -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
155         -S <IP_Address>: Spoof source address
156         -e <iface>: Use specified interface
157         -g/--source-port <portnum>: Use given port number
158         --data-length <num>: Append random data to sent packets
159         --ip-options <options>: Send packets with specified ip options
160         --ttl <val>: Set IP time-to-live field
161         --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
162         --badsum: Send packets with a bogus TCP/UDP checksum
163       OUTPUT:
164         -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
165            and Grepable format, respectively, to the given filename.
166         -oA <basename>: Output in the three major formats at once
167         -v: Increase verbosity level (use twice for more effect)
168         -d[level]: Set or increase debugging level (Up to 9 is meaningful)
169         --open: Only show open (or possibly open) ports
170         --packet-trace: Show all packets sent and received
171         --iflist: Print host interfaces and routes (for debugging)
172         --log-errors: Log errors/warnings to the normal-format output file
173         --append-output: Append to rather than clobber specified output files
174         --resume <filename>: Resume an aborted scan
175         --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
176         --webxml: Reference stylesheet from Insecure.Org for more portable XML
177         --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
178       MISC:
179         -6: Enable IPv6 scanning
180         -A: Enables OS detection and Version detection
181         --datadir <dirname>: Specify custom Nmap data file location
182         --send-eth/--send-ip: Send using raw ethernet frames or IP packets
183         --privileged: Assume that the user is fully privileged
184         --unprivileged: Assume the user lacks raw socket privileges
185         -V: Print version number
186         -h: Print this help summary page.
187       EXAMPLES:
188         nmap -v -A scanme.nmap.org
189         nmap -v -sP 192.168.0.0/16 10.0.0.0/8
190         nmap -v -iR 10000 -P0 -p 80
191
192

TARGET SPECIFICATION

194       Everything on the Nmap command-line that isn't an option (or option
195       argument) is treated as a target host specification. The simplest case
196       is to specify a target IP address or hostname for scanning.
197
198       Sometimes you wish to scan a whole network of adjacent hosts. For this,
199       Nmap supports CIDR-style addressing. You can append
200
201       /numbits to an IP address or hostname and Nmap will scan every IP
202       address for which the first numbits are the same as for the reference
203       IP or hostname given. For example, 192.168.10.0/24 would scan the 256
204       hosts between 192.168.10.0 (binary: 11000000 10101000 00001010
205       00000000) and 192.168.10.255 (binary: 11000000 10101000 00001010
206       11111111), inclusive. 192.168.10.40/24 would do exactly the same thing.
207       Given that the host scanme.nmap.org is at the IP address
208       205.217.153.62, the specification scanme.nmap.org/16 would scan the
209       65,536 IP addresses between 205.217.0.0 and 205.217.255.255. The
210       smallest allowed value is /1, which scans half the Internet. The
211       largest value is 32, which scans just the named host or IP address
212       because all address bits are fixed.
213
214       CIDR notation is short but not always flexible enough. For example, you
215       might want to scan 192.168.0.0/16 but skip any IPs ending with .0 or
216       .255 because they are commonly broadcast addresses. Nmap supports this
217       through octet range addressing. Rather than specify a normal IP
218       address, you can specify a comma separated list of numbers or ranges
219       for each octet. For example, 192.168.0-255.1-254 will skip all
220       addresses in the range that end in .0 and or .255. Ranges need not be
221       limited to the final octets: the specifier 0-255.0-255.13.37 will
222       perform an Internet-wide scan for all IP addresses ending in 13.37.
223       This sort of broad sampling can be useful for Internet surveys and
224       research.
225
226       IPv6 addresses can only be specified by their fully qualified IPv6
227       address or hostname. CIDR and octet ranges aren't supported for IPv6
228       because they are rarely useful.
229
230       Nmap accepts multiple host specifications on the command line, and they
231       don't need to be the same type. The command nmap scanme.nmap.org
232       192.168.0.0/16 10.0.0,1,3-7.0-255 does what you would expect.
233
234       While targets are usually specified on the command lines, the following
235       options are also available to control target selection:
236
237       -iL <inputfilename> (Input from list)
238              Reads target specifications from inputfilename. Passing a huge
239              list of hosts is often awkward on the command line, yet it is a
240              common desire. For example, your DHCP server might export a list
241              of 10,000 current leases that you wish to scan. Or maybe you
242              want to scan all IP addresses except for those to locate hosts
243              using unauthorized static IP addresses. Simply generate the list
244              of hosts to scan and pass that filename to Nmap as an argument
245              to the -iL option. Entries can be in any of the formats accepted
246              by Nmap on the command line (IP address, hostname, CIDR, IPv6,
247              or octet ranges). Each entry must be separated by one or more
248              spaces, tabs, or newlines. You can specify a hyphen (-) as the
249              filename if you want Nmap to read hosts from standard input
250              rather than an actual file.
251
252       -iR <num hosts> (Choose random targets)
253              For Internet-wide surveys and other research, you may want to
254              choose targets at random. The num hosts argument tells Nmap how
255              many IPs to generate. Undesirable IPs such as those in certain
256              private, multicast, or unallocated address ranges are
257              automatically skipped. The argument 0 can be specified for a
258              never-ending scan. Keep in mind that some network administrators
259              bristle at unauthorized scans of their networks and may
260              complain. Use this option at your own risk! If you find yourself
261              really bored one rainy afternoon, try the command nmap -sS -PS80
262              -iR 0 -p 80 to locate random web servers for browsing.
263
264       --exclude <host1[,host2][,host3],...> (Exclude hosts/networks)
265              Specifies a comma-separated list of targets to be excluded from
266              the scan even if they are part of the overall network range you
267              specify. The list you pass in uses normal Nmap syntax, so it can
268              include hostnames, CIDR netblocks, octet ranges, etc. This can
269              be useful when the network you wish to scan includes untouchable
270              mission-critical servers, systems that are known to react
271              adversely to port scans, or subnetworks administered by other
272              people.
273
274       --excludefile <exclude_file> (Exclude list from file)
275              This offers the same functionality as the --exclude option,
276              except that the excluded targets are provided in a newline,
277              space, or tab delimited exclude_file rather than on the command
278              line.
279

HOST DISCOVERY

281       One of the very first steps in any network reconnaissance mission is to
282       reduce a (sometimes huge) set of IP ranges into a list of active or
283       interesting hosts. Scanning every port of every single IP address is
284       slow and usually unnecessary. Of course what makes a host interesting
285       depends greatly on the scan purposes. Network administrators may only
286       be interested in hosts running a certain service, while security
287       auditors may care about every single device with an IP address. An
288       administrator may be comfortable using just an ICMP ping to locate
289       hosts on his internal network, while an external penetration tester may
290       use a diverse set of dozens of probes in an attempt to evade firewall
291       restrictions.
292
293       Because host discovery needs are so diverse, Nmap offers a wide variety
294       of options for customizing the techniques used. Host discovery is
295       sometimes called ping scan, but it goes well beyond the simple ICMP
296       echo request packets associated with the ubiquitous ping tool. Users
297       can skip the ping step entirely with a list scan (-sL) or by disabling
298       ping (-P0), or engage the network with arbitrary combinations of
299       multi-port TCP SYN/ACK, UDP, and ICMP probes. The goal of these probes
300       is to solicit responses which demonstrate that an IP address is
301       actually active (is being used by a host or network device). On many
302       networks, only a small percentage of IP addresses are active at any
303       given time. This is particularly common with RFC1918-blessed private
304       address space such as 10.0.0.0/8. That network has 16 million IPs, but
305       I have seen it used by companies with less than a thousand machines.
306       Host discovery can find those machines in a sparsely allocated sea of
307       IP addresses.
308
309       If no host discovery options are given, Nmap sends a TCP ACK packet
310       destined for port 80 and an ICMP Echo Request query to each target
311       machine. An exception to this is that an ARP scan is used for any
312       targets which are on a local ethernet network. For unprivileged UNIX
313       shell users, a SYN packet is sent instead of the ack using the
314       connect() system call. These defaults are equivalent to the -PA -PE
315       options. This host discovery is often sufficient when scanning local
316       networks, but a more comprehensive set of discovery probes is
317       recommended for security auditing.
318
319       The -P* options (which select ping types) can be combined. You can
320       increase your odds of penetrating strict firewalls by sending many
321       probe types using different TCP ports/flags and ICMP codes. Also note
322       that ARP discovery (-PR) is done by default against targets on a local
323       ethernet network even if you specify other -P* options, because it is
324       almost always faster and more effective.
325
326       By default, Nmap does host discovery and then performs a port scan
327       against each host it determines is online. This is true even if you
328       specify non-default host discovery types such as UDP probes (-PU). Read
329       about the -sP option to learn how to perform only host discovery, or
330       use -P0 to skip host discovery and port scan all target hosts. The
331       following options control host discovery:
332
333       -sL (List Scan)
334              The list scan is a degenerate form of host discovery that simply
335              lists each host of the network(s) specified, without sending any
336              packets to the target hosts. By default, Nmap still does
337              reverse-DNS resolution on the hosts to learn their names. It is
338              often surprising how much useful information simple hostnames
339              give out. For example, fw.chi is the name of one company's
340              Chicago firewall. Nmap also reports the total number of IP
341              addresses at the end. The list scan is a good sanity check to
342              ensure that you have proper IP addresses for your targets. If
343              the hosts sport domain names you do not recognize, it is worth
344              investigating further to prevent scanning the wrong company's
345              network.
346
347              Since the idea is to simply print a list of target hosts,
348              options for higher level functionality such as port scanning, OS
349              detection, or ping scanning cannot be combined with this. If you
350              wish to disable ping scanning while still performing such higher
351              level functionality, read up on the -P0 option.
352
353       -sP (Ping Scan)
354              This option tells Nmap to only perform a ping scan (host
355              discovery), then print out the available hosts that responded to
356              the scan. No further testing (such as port scanning or OS
357              detection) is performed. This is one step more intrusive than
358              the list scan, and can often be used for the same purposes. It
359              allows light reconnaissance of a target network without
360              attracting much attention. Knowing how many hosts are up is more
361              valuable to attackers than the list provided by list scan of
362              every single IP and host name.
363
364              Systems administrators often find this option valuable as well.
365              It can easily be used to count available machines on a network
366              or monitor server availability. This is often called a ping
367              sweep, and is more reliable than pinging the broadcast address
368              because many hosts do not reply to broadcast queries.
369
370              The -sP option sends an ICMP echo request and a TCP packet to
371              port 80 by default. When executed by an unprivileged user, a SYN
372              packet is sent (using a connect() call) to port 80 on the
373              target. When a privileged user tries to scan targets on a local
374              ethernet network, ARP requests (-PR) are used unless --send-ip
375              was specified. The -sP option can be combined with any of the
376              discovery probe types (the -P* options, excluding -P0) for
377              greater flexibility. If any of those probe type and port number
378              options are used, the default probes (ACK and echo request) are
379              overridden. When strict firewalls are in place between the
380              source host running Nmap and the target network, using those
381              advanced techniques is recommended. Otherwise hosts could be
382              missed when the firewall drops probes or their responses.
383
384       -P0 (No ping)
385              This option skips the Nmap discovery stage altogether. Normally,
386              Nmap uses this stage to determine active machines for heavier
387              scanning. By default, Nmap only performs heavy probing such as
388              port scans, version detection, or OS detection against hosts
389              that are found to be up. Disabling host discovery with -P0
390              causes Nmap to attempt the requested scanning functions against
391              every target IP address specified. So if a class B sized target
392              address space (/16) is specified on the command line, all 65,536
393              IP addresses are scanned. That second option character in -P0 is
394              a zero and not the letter O. Proper host discovery is skipped as
395              with the list scan, but instead of stopping and printing the
396              target list, Nmap continues to perform requested functions as if
397              each target IP is active.
398
399       -PS [portlist] (TCP SYN Ping)
400              This option sends an empty TCP packet with the SYN flag set. The
401              default destination port is 80 (configurable at compile time by
402              changing DEFAULT_TCP_PROBE_PORT in nmap.h), but an alternate
403              port can be specified as a parameter. A comma separated list of
404              ports can even be specified (e.g.
405              -PS22,23,25,80,113,1050,35000), in which case probes will be
406              attempted against each port in parallel.
407
408              The SYN flag suggests to the remote system that you are
409              attempting to establish a connection. Normally the destination
410              port will be closed, and a RST (reset) packet sent back. If the
411              port happens to be open, the target will take the second step of
412              a TCP 3-way-handshake by responding with a SYN/ACK TCP packet.
413              The machine running Nmap then tears down the nascent connection
414              by responding with a RST rather than sending an ACK packet which
415              would complete the 3-way-handshake and establish a full
416              connection. The RST packet is sent by the kernel of the machine
417              running Nmap in response to the unexpected SYN/ACK, not by Nmap
418              itself.
419
420              Nmap does not care whether the port is open or closed. Either
421              the RST or SYN/ACK response discussed previously tell Nmap that
422              the host is available and responsive.
423
424              On UNIX boxes, only the privileged user root is generally able
425              to send and receive raw TCP packets. For unprivileged users, a
426              workaround is automatically employed whereby the connect()
427              system call is initiated against each target port. This has the
428              effect of sending a SYN packet to the target host, in an attempt
429              to establish a connection. If connect() returns with a quick
430              success or an ECONNREFUSED failure, the underlying TCP stack
431              must have received a SYN/ACK or RST and the host is marked
432              available. If the connection attempt is left hanging until a
433              timeout is reached, the host is marked as down. This workaround
434              is also used for IPv6 connections, as raw IPv6 packet building
435              support is not yet available in Nmap.
436
437       -PA [portlist] (TCP ACK Ping)
438              The TCP ACK ping is quite similar to the just-discussed SYN
439              ping. The difference, as you could likely guess, is that the TCP
440              ACK flag is set instead of the SYN flag. Such an ACK packet
441              purports to be acknowledging data over an established TCP
442              connection, but no such connection exists. So remote hosts
443              should always respond with a RST packet, disclosing their
444              existence in the process.
445
446              The -PA option uses the same default port as the SYN probe (80)
447              and can also take a list of destination ports in the same
448              format. If an unprivileged user tries this, or an IPv6 target is
449              specified, the connect() workaround discussed previously is
450              used. This workaround is imperfect because connect() is actually
451              sending a SYN packet rather than an ACK.
452
453              The reason for offering both SYN and ACK ping probes is to
454              maximize the chances of bypassing firewalls. Many administrators
455              configure routers and other simple firewalls to block incoming
456              SYN packets except for those destined for public services like
457              the company web site or mail server. This prevents other
458              incoming connections to the organization, while allowing users
459              to make unobstructed outgoing connections to the Internet. This
460              non-stateful approach takes up few resources on the
461              firewall/router and is widely supported by hardware and software
462              filters. The Linux Netfilter/iptables firewall software offers
463              the --syn convenience option to implement this stateless
464              approach. When stateless firewall rules such as this are in
465              place, SYN ping probes (-PS) are likely to be blocked when sent
466              to closed target ports. In such cases, the ACK probe shines as
467              it cuts right through these rules.
468
469              Another common type of firewall uses stateful rules that drop
470              unexpected packets. This feature was initially found mostly on
471              high-end firewalls, though it has become much more common over
472              the years. The Linux Netfilter/iptables system supports this
473              through the --state option, which categorizes packets based on
474              connection state. A SYN probe is more likely to work against
475              such a system, as unexpected ACK packets are generally
476              recognized as bogus and dropped. A solution to this quandary is
477              to send both SYN and ACK probes by specifying -PS and -PA.
478
479       -PU [portlist] (UDP Ping)
480              Another host discovery option is the UDP ping, which sends an
481              empty (unless --data-length is specified) UDP packet to the
482              given ports. The portlist takes the same format as with the
483              previously discussed -PS and -PA options. If no ports are
484              specified, the default is 31338. This default can be configured
485              at compile-time by changing DEFAULT_UDP_PROBE_PORT in nmap.h. A
486              highly uncommon port is used by default because sending to open
487              ports is often undesirable for this particular scan type.
488
489              Upon hitting a closed port on the target machine, the UDP probe
490              should elicit an ICMP port unreachable packet in return. This
491              signifies to Nmap that the machine is up and available. Many
492              other types of ICMP errors, such as host/network unreachables or
493              TTL exceeded are indicative of a down or unreachable host. A
494              lack of response is also interpreted this way. If an open port
495              is reached, most services simply ignore the empty packet and
496              fail to return any response. This is why the default probe port
497              is 31338, which is highly unlikely to be in use. A few services,
498              such as chargen, will respond to an empty UDP packet, and thus
499              disclose to Nmap that the machine is available.
500
501              The primary advantage of this scan type is that it bypasses
502              firewalls and filters that only screen TCP. For example, I once
503              owned a Linksys BEFW11S4 wireless broadband router. The external
504              interface of this device filtered all TCP ports by default, but
505              UDP probes would still elicit port unreachable messages and thus
506              give away the device.
507
508       -PE; -PP; -PM (ICMP Ping Types)
509              In addition to the unusual TCP and UDP host discovery types
510              discussed previously, Nmap can send the standard packets sent by
511              the ubiquitous ping program. Nmap sends an ICMP type 8 (echo
512              request) packet to the target IP addresses, expecting a type 0
513              (Echo Reply) in return from available hosts. Unfortunately for
514              network explorers, many hosts and firewalls now block these
515              packets, rather than responding as required by [1]RFC 1122. For
516              this reason, ICMP-only scans are rarely reliable enough against
517              unknown targets over the Internet. But for system administrators
518              monitoring an internal network, they can be a practical and
519              efficient approach. Use the -PE option to enable this echo
520              request behavior.
521
522              While echo request is the standard ICMP ping query, Nmap does
523              not stop there. The ICMP standard ([2]RFC 792) also specifies
524              timestamp request, information request, and address mask request
525              packets as codes 13, 15, and 17, respectively. While the
526              ostensible purpose for these queries is to learn information
527              such as address masks and current times, they can easily be used
528              for host discovery. A system that replies is up and available.
529              Nmap does not currently implement information request packets,
530              as they are not widely supported. RFC 1122 insists that “a host
531              SHOULD NOT implement these messages”. Timestamp and address mask
532              queries can be sent with the -PP and -PM options, respectively.
533              A timestamp reply (ICMP code 14) or address mask reply (code 18)
534              discloses that the host is available. These two queries can be
535              valuable when admins specifically block echo request packets
536              while forgetting that other ICMP queries can be used for the
537              same purpose.
538
539       -PR (ARP Ping)
540              One of the most common Nmap usage scenarios is to scan an
541              ethernet LAN. On most LANs, especially those using
542              RFC1918-blessed private address ranges, the vast majority of IP
543              addresses are unused at any given time. When Nmap tries to send
544              a raw IP packet such as an ICMP echo request, the operating
545              system must determine the destination hardware (ARP) address
546              corresponding to the target IP so that it can properly address
547              the ethernet frame. This is often slow and problematic, since
548              operating systems weren't written with the expectation that they
549              would need to do millions of ARP requests against unavailable
550              hosts in a short time period.
551
552              ARP scan puts Nmap and its optimized algorithms in charge of ARP
553              requests. And if it gets a response back, Nmap doesn't even need
554              to worry about the IP-based ping packets since it already knows
555              the host is up. This makes ARP scan much faster and more
556              reliable than IP-based scans. So it is done by default when
557              scanning ethernet hosts that Nmap detects are on a local
558              ethernet network. Even if different ping types (such as -PE or
559              -PS) are specified, Nmap uses ARP instead for any of the targets
560              which are on the same LAN. If you absolutely don't want to do an
561              ARP scan, specify --send-ip.
562
563       -n (No DNS resolution)
564              Tells Nmap to never do reverse DNS resolution on the active IP
565              addresses it finds. Since DNS can be slow even with Nmap's
566              built-in parallel stub resolver, this option can slash scanning
567              times.
568
569       -R (DNS resolution for all targets)
570              Tells Nmap to always do reverse DNS resolution on the target IP
571              addresses. Normally reverse DNS is only performed against
572              responsive (online) hosts.
573
574       --system-dns (Use system DNS resolver)
575              By default, Nmap resolves IP addresses by sending queries
576              directly to the name servers configured on your host and then
577              listening for responses. Many requests (often dozens) are
578              performed in parallel to improve performance. Specify this
579              option to use your system resolver instead (one IP at a time via
580              the getnameinfo() call). This is slower and rarely useful unless
581              you find a bug in the Nmap parallel resolver (please let us know
582              if you do). The system resolver is always used for IPv6 scans.
583
584       --dns-servers <server1[,server2],...>  (Servers to use for reverse DNS
585       queries)
586              By default Nmap will try to determine your DNS servers (for rDNS
587              resolution) from your resolv.conf file (UNIX) or the registry
588              (Win32). Alternatively, you may use this option to specify
589              alternate servers. This option is not honored if you are using
590              --system-dns or an IPv6 scan. Using multiple DNS servers is
591              often faster, especially if you choose authoritative servers for
592              your target IP space. This option can also improve stealth, as
593              your requests can be bounced off just about any recursive DNS
594              server on the internet.
595
596              This option also comes in handy when scanning private networks.
597              Sometimes only a few name servers provide proper rDNS
598              information, and you may not even know where they are. You can
599              scan the network for port 53 (perhaps with version detection),
600              then try Nmap list scans (-sL) specifying each name server one
601              at a time with --dns-servers until you find one which works.
602

PORT SCANNING BASICS

604       While Nmap has grown in functionality over the years, it began as an
605       efficient port scanner, and that remains its core function. The simple
606       command nmap target scans more than 1660 TCP ports on the host target.
607       While many port scanners have traditionally lumped all ports into the
608       open or closed states, Nmap is much more granular. It divides ports
609       into six states: open, closed, filtered, unfiltered, open|filtered, or
610       closed|filtered.
611
612       These states are not intrinsic properties of the port itself, but
613       describe how Nmap sees them. For example, an Nmap scan from the same
614       network as the target may show port 135/tcp as open, while a scan at
615       the same time with the same options from across the Internet might show
616       that port as filtered.
617
618       The six port states recognized by Nmap
619
620       open   An application is actively accepting TCP connections or UDP
621              packets on this port. Finding these is often the primary goal of
622              port scanning. Security-minded people know that each open port
623              is an avenue for attack. Attackers and pen-testers want to
624              exploit the open ports, while administrators try to close or
625              protect them with firewalls without thwarting legitimate users.
626              Open ports are also interesting for non-security scans because
627              they show services available for use on the network.
628
629       closed A closed port is accessible (it receives and responds to Nmap
630              probe packets), but there is no application listening on it.
631              They can be helpful in showing that a host is up on an IP
632              address (host discovery, or ping scanning), and as part of OS
633              detection. Because closed ports are reachable, it may be worth
634              scanning later in case some open up. Administrators may want to
635              consider blocking such ports with a firewall. Then they would
636              appear in the filtered state, discussed next.
637
638       filtered
639              Nmap cannot determine whether the port is open because packet
640              filtering prevents its probes from reaching the port. The
641              filtering could be from a dedicated firewall device, router
642              rules, or host-based firewall software. These ports frustrate
643              attackers because they provide so little information. Sometimes
644              they respond with ICMP error messages such as type 3 code 13
645              (destination unreachable: communication administratively
646              prohibited), but filters that simply drop probes without
647              responding are far more common. This forces Nmap to retry
648              several times just in case the probe was dropped due to network
649              congestion rather than filtering. This slows down the scan
650              dramatically.
651
652       unfiltered
653              The unfiltered state means that a port is accessible, but Nmap
654              is unable to determine whether it is open or closed. Only the
655              ACK scan, which is used to map firewall rulesets, classifies
656              ports into this state. Scanning unfiltered ports with other scan
657              types such as Window scan, SYN scan, or FIN scan, may help
658              resolve whether the port is open.
659
660       open|filtered
661              Nmap places ports in this state when it is unable to determine
662              whether a port is open or filtered. This occurs for scan types
663              in which open ports give no response. The lack of response could
664              also mean that a packet filter dropped the probe or any response
665              it elicited. So Nmap does not know for sure whether the port is
666              open or being filtered. The UDP, IP Protocol, FIN, Null, and
667              Xmas scans classify ports this way.
668
669       closed|filtered
670              This state is used when Nmap is unable to determine whether a
671              port is closed or filtered. It is only used for the IPID Idle
672              scan.
673

PORT SCANNING TECHNIQUES

675       As a novice performing automotive repair, I can struggle for hours
676       trying to fit my rudimentary tools (hammer, duct tape, wrench, etc.) to
677       the task at hand. When I fail miserably and tow my jalopy to a real
678       mechanic, he invariably fishes around in a huge tool chest until
679       pulling out the perfect gizmo which makes the job seem effortless. The
680       art of port scanning is similar. Experts understand the dozens of scan
681       techniques and choose the appropriate one (or combination) for a given
682       task. Inexperienced users and script kiddies, on the other hand, try to
683       solve every problem with the default SYN scan. Since Nmap is free, the
684       only barrier to port scanning mastery is knowledge. That certainly
685       beats the automotive world, where it may take great skill to determine
686       that you need a strut spring compressor, then you still have to pay
687       thousands of dollars for it.
688
689       Most of the scan types are only available to privileged users. This is
690       because they send and receive raw packets, which requires root access
691       on UNIX systems. Using an administrator account on Windows is
692       recommended, though Nmap sometimes works for unprivileged users on that
693       platform when WinPcap has already been loaded into the OS. Requiring
694       root privileges was a serious limitation when Nmap was released in
695       1997, as many users only had access to shared shell accounts. Now, the
696       world is different. Computers are cheaper, far more people have
697       always-on direct Internet access, and desktop UNIX systems (including
698       Linux and MAC OS X) are prevalent. A Windows version of Nmap is now
699       available, allowing it to run on even more desktops. For all these
700       reasons, users have less need to run Nmap from limited shared shell
701       accounts. This is fortunate, as the privileged options make Nmap far
702       more powerful and flexible.
703
704       While Nmap attempts to produce accurate results, keep in mind that all
705       of its insights are based on packets returned by the target machines
706       (or firewalls in front of them). Such hosts may be untrustworthy and
707       send responses intended to confuse or mislead Nmap. Much more common
708       are non-RFC-compliant hosts that do not respond as they should to Nmap
709       probes. FIN, Null, and Xmas scans are particularly susceptible to this
710       problem. Such issues are specific to certain scan types and so are
711       discussed in the individual scan type entries.
712
713       This section documents the dozen or so port scan techniques supported
714       by Nmap. Only one method may be used at a time, except that UDP scan
715       (-sU) may be combined with any one of the TCP scan types. As a memory
716       aid, port scan type options are of the form -sC, where C is a prominent
717       character in the scan name, usually the first. The one exception to
718       this is the deprecated FTP bounce scan (-b). By default, Nmap performs
719       a SYN Scan, though it substitutes a connect scan if the user does not
720       have proper privileges to send raw packets (requires root access on
721       UNIX) or if IPv6 targets were specified. Of the scans listed in this
722       section, unprivileged users can only execute connect and ftp bounce
723       scans.
724
725       -sS (TCP SYN scan)
726              SYN scan is the default and most popular scan option for good
727              reasons. It can be performed quickly, scanning thousands of
728              ports per second on a fast network not hampered by intrusive
729              firewalls. SYN scan is relatively unobtrusive and stealthy,
730              since it never completes TCP connections. It also works against
731              any compliant TCP stack rather than depending on idiosyncrasies
732              of specific platforms as Nmap's Fin/Null/Xmas, Maimon and Idle
733              scans do. It also allows clear, reliable differentiation between
734              the open, closed, and filtered states.
735
736              This technique is often referred to as half-open scanning,
737              because you don't open a full TCP connection. You send a SYN
738              packet, as if you are going to open a real connection and then
739              wait for a response. A SYN/ACK indicates the port is listening
740              (open), while a RST (reset) is indicative of a non-listener. If
741              no response is received after several retransmissions, the port
742              is marked as filtered. The port is also marked filtered if an
743              ICMP unreachable error (type 3, code 1,2, 3, 9, 10, or 13) is
744              received.
745
746       -sT (TCP connect scan)
747              TCP connect scan is the default TCP scan type when SYN scan is
748              not an option. This is the case when a user does not have raw
749              packet privileges or is scanning IPv6 networks. Instead of
750              writing raw packets as most other scan types do, Nmap asks the
751              underlying operating system to establish a connection with the
752              target machine and port by issuing the connect() system call.
753              This is the same high-level system call that web browsers, P2P
754              clients, and most other network-enabled applications use to
755              establish a connection. It is part of a programming interface
756              known as the Berkeley Sockets API. Rather than read raw packet
757              responses off the wire, Nmap uses this API to obtain status
758              information on each connection attempt.
759
760              When SYN scan is available, it is usually a better choice. Nmap
761              has less control over the high level connect() call than with
762              raw packets, making it less efficient. The system call completes
763              connections to open target ports rather than performing the
764              half-open reset that SYN scan does. Not only does this take
765              longer and require more packets to obtain the same information,
766              but target machines are more likely to log the connection. A
767              decent IDS will catch either, but most machines have no such
768              alarm system. Many services on your average UNIX system will add
769              a note to syslog, and sometimes a cryptic error message, when
770              Nmap connects and then closes the connection without sending
771              data. Truly pathetic services crash when this happens, though
772              that is uncommon. An administrator who sees a bunch of
773              connection attempts in her logs from a single system should know
774              that she has been connect scanned.
775
776       -sU (UDP scans)
777              While most popular services on the Internet run over the TCP
778              protocol, [3]UDP services are widely deployed. DNS, SNMP, and
779              DHCP (registered ports 53, 161/162, and 67/68) are three of the
780              most common. Because UDP scanning is generally slower and more
781              difficult than TCP, some security auditors ignore these ports.
782              This is a mistake, as exploitable UDP services are quite common
783              and attackers certainly don't ignore the whole protocol.
784              Fortunately, Nmap can help inventory UDP ports.
785
786              UDP scan is activated with the -sU option. It can be combined
787              with a TCP scan type such as SYN scan (-sS) to check both
788              protocols during the same run.
789
790              UDP scan works by sending an empty (no data) UDP header to every
791              targeted port. If an ICMP port unreachable error (type 3, code
792              3) is returned, the port is closed. Other ICMP unreachable
793              errors (type 3, codes 1, 2, 9, 10, or 13) mark the port as
794              filtered. Occasionally, a service will respond with a UDP
795              packet, proving that it is open. If no response is received
796              after retransmissions, the port is classified as open|filtered.
797              This means that the port could be open, or perhaps packet
798              filters are blocking the communication. Versions scan (-sV) can
799              be used to help differentiate the truly open ports from the
800              filtered ones.
801
802              A big challenge with UDP scanning is doing it quickly. Open and
803              filtered ports rarely send any response, leaving Nmap to time
804              out and then conduct retransmissions just in case the probe or
805              response were lost. Closed ports are often an even bigger
806              problem. They usually send back an ICMP port unreachable error.
807              But unlike the RST packets sent by closed TCP ports in response
808              to a SYN or connect scan, many hosts rate limit ICMP port
809              unreachable messages by default. Linux and Solaris are
810              particularly strict about this. For example, the Linux 2.4.20
811              kernel limits destination unreachable messages to one per second
812              (in net/ipv4/icmp.c).
813
814              Nmap detects rate limiting and slows down accordingly to avoid
815              flooding the network with useless packets that the target
816              machine will drop. Unfortunately, a Linux-style limit of one
817              packet per second makes a 65,536-port scan take more than 18
818              hours. Ideas for speeding your UDP scans up include scanning
819              more hosts in parallel, doing a quick scan of just the popular
820              ports first, scanning from behind the firewall, and using
821              --host-timeout to skip slow hosts.
822
823       -sN; -sF; -sX (TCP Null, FIN, and Xmas scans)
824              These three scan types (even more are possible with the
825              --scanflags option described in the next section) exploit a
826              subtle loophole in the [4]TCP RFC to differentiate between open
827              and closed ports. Page 65 says that “if the [destination] port
828              state is CLOSED .... an incoming segment not containing a RST
829              causes a RST to be sent in response.”  Then the next page
830              discusses packets sent to open ports without the SYN, RST, or
831              ACK bits set, stating that: “you are unlikely to get here, but
832              if you do, drop the segment, and return.”
833
834              When scanning systems compliant with this RFC text, any packet
835              not containing SYN, RST, or ACK bits will result in a returned
836              RST if the port is closed and no response at all if the port is
837              open. As long as none of those three bits are included, any
838              combination of the other three (FIN, PSH, and URG) are OK. Nmap
839              exploits this with three scan types:
840
841              Null scan (-sN)
842                     Does not set any bits (tcp flag header is 0)
843
844              FIN scan (-sF)
845                     Sets just the TCP FIN bit.
846
847              Xmas scan (-sX)
848                     Sets the FIN, PSH, and URG flags, lighting the packet up
849                     like a Christmas tree.
850
851              These three scan types are exactly the same in behavior except
852              for the TCP flags set in probe packets. If a RST packet is
853              received, the port is considered closed, while no response means
854              it is open|filtered. The port is marked filtered if an ICMP
855              unreachable error (type 3, code 1, 2, 3, 9, 10, or 13) is
856              received.
857
858              The key advantage to these scan types is that they can sneak
859              through certain non-stateful firewalls and packet filtering
860              routers. Another advantage is that these scan types are a little
861              more stealthy than even a SYN scan. Don't count on this though
862              -- most modern IDS products can be configured to detect them.
863              The big downside is that not all systems follow RFC 793 to the
864              letter. A number of systems send RST responses to the probes
865              regardless of whether the port is open or not. This causes all
866              of the ports to be labeled closed. Major operating systems that
867              do this are Microsoft Windows, many Cisco devices, BSDI, and IBM
868              OS/400. This scan does work against most UNIX-based systems
869              though. Another downside of these scans is that they can't
870              distinguish open ports from certain filtered ones, leaving you
871              with the response open|filtered.
872
873       -sA (TCP ACK scan)
874              This scan is different than the others discussed so far in that
875              it never determines open (or even open|filtered) ports. It is
876              used to map out firewall rulesets, determining whether they are
877              stateful or not and which ports are filtered.
878
879              The ACK scan probe packet has only the ACK flag set (unless you
880              use --scanflags). When scanning unfiltered systems, open and
881              closed ports will both return a RST packet. Nmap then labels
882              them as unfiltered, meaning that they are reachable by the ACK
883              packet, but whether they are open or closed is undetermined.
884              Ports that don't respond, or send certain ICMP error messages
885              back (type 3, code 1, 2, 3, 9, 10, or 13), are labeled filtered.
886
887       -sW (TCP Window scan)
888              Window scan is exactly the same as ACK scan except that it
889              exploits an implementation detail of certain systems to
890              differentiate open ports from closed ones, rather than always
891              printing unfiltered when a RST is returned. It does this by
892              examining the TCP Window field of the RST packets returned. On
893              some systems, open ports use a positive window size (even for
894              RST packets) while closed ones have a zero window. So instead of
895              always listing a port as unfiltered when it receives a RST back,
896              Window scan lists the port as open or closed if the TCP Window
897              value in that reset is positive or zero, respectively.
898
899              This scan relies on an implementation detail of a minority of
900              systems out on the Internet, so you can't always trust it.
901              Systems that don't support it will usually return all ports
902              closed. Of course, it is possible that the machine really has no
903              open ports. If most scanned ports are closed but a few common
904              port numbers (such as 22, 25, 53) are filtered, the system is
905              most likely susceptible. Occasionally, systems will even show
906              the exact opposite behavior. If your scan shows 1000 open ports
907              and 3 closed or filtered ports, then those three may very well
908              be the truly open ones.
909
910       -sM (TCP Maimon scan)
911              The Maimon scan is named after its discoverer, Uriel Maimon. He
912              described the technique in Phrack Magazine issue #49 (November
913              1996). Nmap, which included this technique, was released two
914              issues later. This technique is exactly the same as Null, FIN,
915              and Xmas scans, except that the probe is FIN/ACK. According to
916              RFC 793 (TCP), a RST packet should be generated in response to
917              such a probe whether the port is open or closed. However, Uriel
918              noticed that many BSD-derived systems simply drop the packet if
919              the port is open.
920
921       --scanflags (Custom TCP scan)
922              Truly advanced Nmap users need not limit themselves to the
923              canned scan types offered. The --scanflags option allows you to
924              design your own scan by specifying arbitrary TCP flags. Let your
925              creative juices flow, while evading intrusion detection systems
926              whose vendors simply paged through the Nmap man page adding
927              specific rules!
928
929              The --scanflags argument can be a numerical flag value such as 9
930              (PSH and FIN), but using symbolic names is easier. Just mash
931              together any combination of URG, ACK, PSH, RST, SYN, and FIN.
932              For example, --scanflags URGACKPSHRSTSYNFIN sets everything,
933              though it's not very useful for scanning. The order these are
934              specified in is irrelevant.
935
936              In addition to specifying the desired flags, you can specify a
937              TCP scan type (such as -sA or -sF). That base type tells Nmap
938              how to interpret responses. For example, a SYN scan considers
939              no-response to indicate a filtered port, while a FIN scan treats
940              the same as open|filtered. Nmap will behave the same way it does
941              for the base scan type, except that it will use the TCP flags
942              you specify instead. If you don't specify a base type, SYN scan
943              is used.
944
945       -sI <zombie host[:probeport]> (Idlescan)
946              This advanced scan method allows for a truly blind TCP port scan
947              of the target (meaning no packets are sent to the target from
948              your real IP address). Instead, a unique side-channel attack
949              exploits predictable IP fragmentation ID sequence generation on
950              the zombie host to glean information about the open ports on the
951              target. IDS systems will display the scan as coming from the
952              zombie machine you specify (which must be up and meet certain
953              criteria). This fascinating scan type is too complex to fully
954              describe in this reference guide, so I wrote and posted an
955              informal paper with full details at
956              http://insecure.org/nmap/idlescan.html.
957
958              Besides being extraordinarily stealthy (due to its blind
959              nature), this scan type permits mapping out IP-based trust
960              relationships between machines. The port listing shows open
961              ports from the perspective of the zombie host.  So you can try
962              scanning a target using various zombies that you think might be
963              trusted (via router/packet filter rules).
964
965              You can add a colon followed by a port number to the zombie host
966              if you wish to probe a particular port on the zombie for IPID
967              changes. Otherwise Nmap will use the port it uses by default for
968              tcp pings (80).
969
970       -sO (IP protocol scan)
971              IP Protocol scan allows you to determine which IP protocols
972              (TCP, ICMP, IGMP, etc.) are supported by target machines. This
973              isn't technically a port scan, since it cycles through IP
974              protocol numbers rather than TCP or UDP port numbers. Yet it
975              still uses the -p option to select scanned protocol numbers,
976              reports its results within the normal port table format, and
977              even uses the same underlying scan engine as the true port
978              scanning methods. So it is close enough to a port scan that it
979              belongs here.
980
981              Besides being useful in its own right, protocol scan
982              demonstrates the power of open source software. While the
983              fundamental idea is pretty simple, I had not thought to add it
984              nor received any requests for such functionality. Then in the
985              summer of 2000, Gerhard Rieger conceived the idea, wrote an
986              excellent patch implementing it, and sent it to the nmap-hackers
987              mailing list. I incorporated that patch into the Nmap tree and
988              released a new version the next day. Few pieces of commercial
989              software have users enthusiastic enough to design and contribute
990              their own improvements!
991
992              Protocol scan works in a similar fashion to UDP scan. Instead of
993              iterating through the port number field of a UDP packet, it
994              sends IP packet headers and iterates through the 8-bit IP
995              protocol field. The headers are usually empty, containing no
996              data and not even the proper header for the claimed protocol.
997              The three exceptions are TCP, UDP, and ICMP. A proper protocol
998              header for those is included since some systems won't send them
999              otherwise and because Nmap already has functions to create them.
1000              Instead of watching for ICMP port unreachable messages, protocol
1001              scan is on the lookout for ICMP protocol unreachable messages.
1002              If Nmap receives any response in any protocol from the target
1003              host, Nmap marks that protocol as open. An ICMP protocol
1004              unreachable error (type 3, code 2) causes the protocol to be
1005              marked as closed Other ICMP unreachable errors (type 3, code 1,
1006              3, 9, 10, or 13) cause the protocol to be marked filtered
1007              (though they prove that ICMP is open at the same time). If no
1008              response is received after retransmissions, the protocol is
1009              marked open|filtered
1010
1011       -b <ftp relay host> (FTP bounce scan)
1012              An interesting feature of the FTP protocol ([5]RFC 959) is
1013              support for so-called proxy ftp connections. This allows a user
1014              to connect to one FTP server, then ask that files be sent to a
1015              third-party server. Such a feature is ripe for abuse on many
1016              levels, so most servers have ceased supporting it. One of the
1017              abuses this feature allows is causing the FTP server to port
1018              scan other hosts. Simply ask the FTP server to send a file to
1019              each interesting port of a target host in turn. The error
1020              message will describe whether the port is open or not. This is a
1021              good way to bypass firewalls because organizational FTP servers
1022              are often placed where they have more access to other internal
1023              hosts than any old Internet host would. Nmap supports ftp bounce
1024              scan with the -b option. It takes an argument of the form
1025              username:password@server:port.  Server is the name or IP address
1026              of a vulnerable FTP server. As with a normal URL, you may omit
1027              username:password, in which case anonymous login credentials
1028              (user: anonymous password:-wwwuser@) are used. The port number
1029              (and preceding colon) may be omitted as well, in which case the
1030              default FTP port (21) on server is used.
1031
1032              This vulnerability was widespread in 1997 when Nmap was
1033              released, but has largely been fixed. Vulnerable servers are
1034              still around, so it is worth trying when all else fails. If
1035              bypassing a firewall is your goal, scan the target network for
1036              open port 21 (or even for any ftp services if you scan all ports
1037              with version detection), then try a bounce scan using each. Nmap
1038              will tell you whether the host is vulnerable or not. If you are
1039              just trying to cover your tracks, you don't need to (and, in
1040              fact, shouldn't) limit yourself to hosts on the target network.
1041              Before you go scanning random Internet addresses for vulnerable
1042              FTP servers, consider that sysadmins may not appreciate you
1043              abusing their servers in this way.
1044

PORT SPECIFICATION AND SCAN ORDER

1046       In addition to all of the scan methods discussed previously, Nmap
1047       offers options for specifying which ports are scanned and whether the
1048       scan order is randomized or sequential. By default, Nmap scans all
1049       ports up to and including 1024 as well as higher numbered ports listed
1050       in the nmap-services file for the protocol(s) being scanned.
1051
1052       -p <port ranges> (Only scan specified ports)
1053              This option specifies which ports you want to scan and overrides
1054              the default. Individual port numbers are OK, as are ranges
1055              separated by a hyphen (e.g. 1-1023). The beginning and/or end
1056              values of a range may be omitted, causing Nmap to use 1 and
1057              65535, respectively. So you can specify -p- to scan ports from 1
1058              through 65535. Scanning port zero is allowed if you specify it
1059              explicitly. For IP protocol scanning (-sO), this option
1060              specifies the protocol numbers you wish to scan for (0-255).
1061
1062              When scanning both TCP and UDP ports, you can specify a
1063              particular protocol by preceding the port numbers by T: or U:.
1064              The qualifier lasts until you specify another qualifier. For
1065              example, the argument -p U:53,111,137,T:21-25,80,139,8080 would
1066              scan UDP ports 53,111,and 137, as well as the listed TCP ports.
1067              Note that to scan both UDP & TCP, you have to specify -sU and at
1068              least one TCP scan type (such as -sS, -sF, or -sT). If no
1069              protocol qualifier is given, the port numbers are added to all
1070              protocol lists.
1071
1072       -F (Fast (limited port) scan)
1073              Specifies that you only wish to scan for ports listed in the
1074              nmap-services file which comes with nmap (or the protocols file
1075              for -sO). This is much faster than scanning all 65535 ports on a
1076              host. Because this list contains so many TCP ports (more than
1077              1200), the speed difference from a default TCP scan (about 1650
1078              ports) isn't dramatic. The difference can be enormous if you
1079              specify your own tiny nmap-services file using the --datadir
1080              option.
1081
1082       -r (Don't randomize ports)
1083              By default, Nmap randomizes the scanned port order (except that
1084              certain commonly accessible ports are moved near the beginning
1085              for efficiency reasons). This randomization is normally
1086              desirable, but you can specify -r for sequential port scanning
1087              instead.
1088

SERVICE AND VERSION DETECTION

1090       Point Nmap at a remote machine and it might tell you that ports 25/tcp,
1091       80/tcp, and 53/udp are open. Using its nmap-services database of about
1092       2,200 well-known services, Nmap would report that those ports probably
1093       correspond to a mail server (SMTP), web server (HTTP), and name server
1094       (DNS) respectively. This lookup is usually accurate -- the vast
1095       majority of daemons listening on TCP port 25 are, in fact, mail
1096       servers. However, you should not bet your security on this! People can
1097       and do run services on strange ports.
1098
1099       Even if Nmap is right, and the hypothetical server above is running
1100       SMTP, HTTP, and DNS servers, that is not a lot of information. When
1101       doing vulnerability assessments (or even simple network inventories) of
1102       your companies or clients, you really want to know which mail and DNS
1103       servers and versions are running. Having an accurate version number
1104       helps dramatically in determining which exploits a server is vulnerable
1105       to. Version detection helps you obtain this information.
1106
1107       After TCP and/or UDP ports are discovered using one of the other scan
1108       methods, version detection interrogates those ports to determine more
1109       about what is actually running. The nmap-service-probes database
1110       contains probes for querying various services and match expressions to
1111       recognize and parse responses. Nmap tries to determine the service
1112       protocol (e.g. ftp, ssh, telnet, http), the application name (e.g. ISC
1113       Bind, Apache httpd, Solaris telnetd), the version number, hostname,
1114       device type (e.g. printer, router), the OS family (e.g. Windows, Linux)
1115       and sometimes miscellaneous details like whether an X server is open to
1116       connections, the SSH protocol version, or the KaZaA user name). Of
1117       course, most services don't provide all of this information. If Nmap
1118       was compiled with OpenSSL support, it will connect to SSL servers to
1119       deduce the service listening behind that encryption layer. When RPC
1120       services are discovered, the Nmap RPC grinder (-sR) is automatically
1121       used to determine the RPC program and version numbers. Some UDP ports
1122       are left in the open|filtered state after a UDP port scan is unable to
1123       determine whether the port is open or filtered. Version detection will
1124       try to elicit a response from these ports (just as it does with open
1125       ports), and change the state to open if it succeeds.  open|filtered TCP
1126       ports are treated the same way. Note that the Nmap -A option enables
1127       version detection among other things. A paper documenting the workings,
1128       usage, and customization of version detection is available at
1129       http://insecure.org/nmap/vscan/.
1130
1131       When Nmap receives responses from a service but cannot match them to
1132       its database, it prints out a special fingerprint and a URL for you to
1133       submit if to if you know for sure what is running on the port. Please
1134       take a couple minutes to make the submission so that your find can
1135       benefit everyone. Thanks to these submissions, Nmap has about 3,000
1136       pattern matches for more than 350 protocols such as smtp, ftp, http,
1137       etc.
1138
1139       Version detection is enabled and controlled with the following options:
1140
1141       -sV (Version detection)
1142              Enables version detection, as discussed above. Alternatively,
1143              you can use -A to enable both OS detection and version
1144              detection.
1145
1146       --allports (Don't exclude any ports from version detection)
1147              By default, Nmap version detection skips TCP port 9100 because
1148              some printers simply print anything sent to that port, leading
1149              to dozens of pages of HTTP get requests, binary SSL session
1150              requests, etc. This behavior can be changed by modifying or
1151              removing the Exclude directive in nmap-service-probes, or you
1152              can specify --allports to scan all ports regardless of any
1153              Exclude directive.
1154
1155       --version-intensity <intensity> (Set version scan intensity)
1156              When performing a version scan (-sV), nmap sends a series of
1157              probes, each of which is assigned a rarity value between 1 and
1158              9. The lower-numbered probes are effective against a wide
1159              variety of common services, while the higher numbered ones are
1160              rarely useful. The intensity level specifies which probes should
1161              be applied. The higher the number, the more likely it is the
1162              service will be correctly identified. However, high intensity
1163              scans take longer. The intensity must be between 0 and 9. The
1164              default is 7. When a probe is registered to the target port via
1165              the nmap-service-probesports directive, that probe is tried
1166              regardless of intensity level. This ensures that the DNS probes
1167              will always be attempted against any open port 53, the SSL probe
1168              will be done against 443, etc.
1169
1170       --version-light (Enable light mode)
1171              This is a convenience alias for --version-intensity 2. This
1172              light mode makes version scanning much faster, but it is
1173              slightly less likely to identify services.
1174
1175       --version-all (Try every single probe)
1176              An alias for --version-intensity 9, ensuring that every single
1177              probe is attempted against each port.
1178
1179       --version-trace (Trace version scan activity)
1180              This causes Nmap to print out extensive debugging info about
1181              what version scanning is doing. It is a subset of what you get
1182              with --packet-trace.
1183
1184       -sR (RPC scan)
1185              This method works in conjunction with the various port scan
1186              methods of Nmap. It takes all the TCP/UDP ports found open and
1187              floods them with SunRPC program NULL commands in an attempt to
1188              determine whether they are RPC ports, and if so, what program
1189              and version number they serve up. Thus you can effectively
1190              obtain the same info as rpcinfo -p even if the target's
1191              portmapper is behind a firewall (or protected by TCP wrappers).
1192              Decoys do not currently work with RPC scan. This is
1193              automatically enabled as part of version scan (-sV) if you
1194              request that. As version detection includes this and is much
1195              more comprehensive, -sR is rarely needed.
1196

OS DETECTION

1198       One of Nmap's best-known features is remote OS detection using TCP/IP
1199       stack fingerprinting. Nmap sends a series of TCP and UDP packets to the
1200       remote host and examines practically every bit in the responses. After
1201       performing dozens of tests such as TCP ISN sampling, TCP options
1202       support and ordering, IPID sampling, and the initial window size check,
1203       Nmap compares the results to its nmap-os-fingerprints database of more
1204       than 1500 known OS fingerprints and prints out the OS details if there
1205       is a match. Each fingerprint includes a freeform textual description of
1206       the OS, and a classification which provides the vendor name (e.g. Sun),
1207       underlying OS (e.g. Solaris), OS generation (e.g. 10), and device type
1208       (general purpose, router, switch, game console, etc).
1209
1210       If Nmap is unable to guess the OS of a machine, and conditions are good
1211       (e.g. at least one open port and one closed port were found), Nmap will
1212       provide a URL you can use to submit the fingerprint if you know (for
1213       sure) the OS running on the machine. By doing this you contribute to
1214       the pool of operating systems known to Nmap and thus it will be more
1215       accurate for everyone.
1216
1217       OS detection enables several other tests which make use of information
1218       that is gathered during the process anyway. One of these is uptime
1219       measurement, which uses the TCP timestamp option (RFC 1323) to guess
1220       when a machine was last rebooted. This is only reported for machines
1221       which provide this information. Another is TCP Sequence Predictability
1222       Classification. This measures approximately how hard it is to establish
1223       a forged TCP connection against the remote host. It is useful for
1224       exploiting source-IP based trust relationships (rlogin, firewall
1225       filters, etc) or for hiding the source of an attack. This sort of
1226       spoofing is rarely performed any more, but many machines are still
1227       vulnerable to it. The actual difficulty number is based on statistical
1228       sampling and may fluctuate. It is generally better to use the English
1229       classification such as “worthy challenge” or “trivial joke”. This is
1230       only reported in normal output in verbose (-v) mode. When verbose mode
1231       is enabled along with -O, IPID Sequence Generation is also reported.
1232       Most machines are in the “incremental” class, which means that they
1233       increment the ID field in the IP header for each packet they send. This
1234       makes them vulnerable to several advanced information gathering and
1235       spoofing attacks.
1236
1237       A paper documenting the workings, usage, and customization of OS
1238       detection is available at http://insecure.org/nmap/osdetect/.
1239
1240       OS detection is enabled and controlled with the following options:
1241
1242       -O (Enable OS detection)
1243              Enables OS detection, as discussed above. Alternatively, you can
1244              use -A to enable both OS detection and version detection. 2nd
1245              generation OS detection is tried first. If that fails, Nmap will
1246              either print out the host fingerprint and ask you to submit it
1247              (if you are certain about what the target host is running), or
1248              Nmap will fall back to the 1st generation OS detection system in
1249              case its larger database has a match.
1250
1251       -O2 (2nd Generation OS Detection Only)
1252              Enables 2nd generation OS detection, but never falls back to the
1253              old (1st generation) system, even if it fails to find any match.
1254              This saves time and can reduce the number of packets sent to
1255              each target.
1256
1257       -O1 (1nd Generation OS Detection Only)
1258              Tells Nmap to only use the old OS detection system. If -O2 just
1259              gives you a fingerprint to submit, but you don't know what OS
1260              the target is running, try -O1. But in that case, don't submit
1261              the fingerprint as you don't know for sure whether -O1 guess
1262              correctly. If it was perfect, we wouldn't have bothered to
1263              create -O2.
1264
1265              This option, and all other vestiges of the old OS detection
1266              system, will likely be removed in late 2006 or in 2007.
1267
1268       --osscan-limit (Limit OS detection to promising targets)
1269              OS detection is far more effective if at least one open and one
1270              closed TCP port are found. Set this option and Nmap will not
1271              even try OS detection against hosts that do not meet this
1272              criteria. This can save substantial time, particularly on -P0
1273              scans against many hosts. It only matters when OS detection is
1274              requested with -O or -A.
1275
1276       --osscan-guess; --fuzzy (Guess OS detection results)
1277              When Nmap is unable to detect a perfect OS match, it sometimes
1278              offers up near-matches as possibilities. The match has to be
1279              very close for Nmap to do this by default. Either of these
1280              (equivalent) options make Nmap guess more aggressively. Nmap
1281              will still tell you when an imperfect match is printed and
1282              display its confidence level (percentage) for each guess.
1283
1284       --max-os-tries (Set the maximum number of OS detection tries against a
1285       target)
1286              When Nmap performs OS detection against a target and fails to
1287              find a perfect match, it usually repeats the attempt. By
1288              default, Nmap tries five times if conditions are favorable for
1289              OS fingerprint submission, and twice when conditions aren't so
1290              good. Specifying a lower --max-os-tries value (such as 1) speeds
1291              Nmap up, though you miss out on retries which could potentially
1292              identify the OS. Alternatively, a high value may be set to allow
1293              even more retries when conditions are favorable. This is rarely
1294              done, except to generate better fingerprints for submission and
1295              integration into the Nmap OS database. This option only affects
1296              second generation OS detection (-O2, the default) and not the
1297              old system (-O1).
1298

TIMING AND PERFORMANCE

1300       One of my highest Nmap development priorities has always been
1301       performance. A default scan (nmap hostname) of a host on my local
1302       network takes a fifth of a second. That is barely enough time to blink,
1303       but adds up when you are scanning tens or hundreds of thousands of
1304       hosts. Moreover, certain scan options such as UDP scanning and version
1305       detection can increase scan times substantially. So can certain
1306       firewall configurations, particularly response rate limiting. While
1307       Nmap utilizes parallelism and many advanced algorithms to accelerate
1308       these scans, the user has ultimate control over how Nmap runs. Expert
1309       users carefully craft Nmap commands to obtain only the information they
1310       care about while meeting their time constraints.
1311
1312       Techniques for improving scan times include omitting non-critical
1313       tests, and upgrading to the latest version of Nmap (performance
1314       enhancements are made frequently). Optimizing timing parameters can
1315       also make a substantial difference. Those options are listed below.
1316
1317       Some options accept a time parameter. This is specified in milliseconds
1318       by default, though you can append ‘s’, ‘m’, or ‘h’ to the value to
1319       specify seconds, minutes, or hours. So the --host-timeout arguments
1320       900000, 900s, and 15m all do the same thing.
1321
1322       --min-hostgroup <numhosts>; --max-hostgroup <numhosts> (Adjust parallel
1323       scan group sizes)
1324              Nmap has the ability to port scan or version scan multiple hosts
1325              in parallel. Nmap does this by dividing the target IP space into
1326              groups and then scanning one group at a time. In general, larger
1327              groups are more efficient. The downside is that host results
1328              can't be provided until the whole group is finished. So if Nmap
1329              started out with a group size of 50, the user would not receive
1330              any reports (except for the updates offered in verbose mode)
1331              until the first 50 hosts are completed.
1332
1333              By default, Nmap takes a compromise approach to this conflict.
1334              It starts out with a group size as low as five so the first
1335              results come quickly and then increases the groupsize to as high
1336              as 1024. The exact default numbers depend on the options given.
1337              For efficiency reasons, Nmap uses larger group sizes for UDP or
1338              few-port TCP scans.
1339
1340              When a maximum group size is specified with --max-hostgroup,
1341              Nmap will never exceed that size. Specify a minimum size with
1342              --min-hostgroup and Nmap will try to keep group sizes above that
1343              level. Nmap may have to use smaller groups than you specify if
1344              there are not enough target hosts left on a given interface to
1345              fulfill the specified minimum. Both may be set to keep the group
1346              size within a specific range, though this is rarely desired.
1347
1348              The primary use of these options is to specify a large minimum
1349              group size so that the full scan runs more quickly. A common
1350              choice is 256 to scan a network in Class C sized chunks. For a
1351              scan with many ports, exceeding that number is unlikely to help
1352              much. For scans of just a few port numbers, host group sizes of
1353              2048 or more may be helpful.
1354
1355       --min-parallelism <numprobes>; --max-parallelism <numprobes> (Adjust
1356       probe parallelization)
1357              These options control the total number of probes that may be
1358              outstanding for a host group. They are used for port scanning
1359              and host discovery. By default, Nmap calculates an ever-changing
1360              ideal parallelism based on network performance. If packets are
1361              being dropped, Nmap slows down and allows fewer outstanding
1362              probes. The ideal probe number slowly rises as the network
1363              proves itself worthy. These options place minimum or maximum
1364              bounds on that variable. By default, the ideal parallelism can
1365              drop to 1 if the network proves unreliable and rise to several
1366              hundred in perfect conditions.
1367
1368              The most common usage is to set --min-parallelism to a number
1369              higher than one to speed up scans of poorly performing hosts or
1370              networks. This is a risky option to play with, as setting it too
1371              high may affect accuracy. Setting this also reduces Nmap's
1372              ability to control parallelism dynamically based on network
1373              conditions. A value of ten might be reasonable, though I only
1374              adjust this value as a last resort.
1375
1376              The --max-parallelism option is sometimes set to one to prevent
1377              Nmap from sending more than one probe at a time to hosts. This
1378              can be useful in combination with --scan-delay (discussed
1379              later), although the latter usually serves the purpose well
1380              enough by itself.
1381
1382       --min-rtt-timeout <time>, --max-rtt-timeout <time>,
1383       --initial-rtt-timeout <time> (Adjust probe timeouts)
1384              Nmap maintains a running timeout value for determining how long
1385              it will wait for a probe response before giving up or
1386              retransmitting the probe. This is calculated based on the
1387              response times of previous probes. If the network latency shows
1388              itself to be significant and variable, this timeout can grow to
1389              several seconds. It also starts at a conservative (high) level
1390              and may stay that way for a while when Nmap scans unresponsive
1391              hosts.
1392
1393              Specifying a lower --max-rtt-timeout and --initial-rtt-timeout
1394              than the defaults can cut scan times significantly. This is
1395              particularly true for pingless (-P0) scans, and those against
1396              heavily filtered networks. Don't get too aggressive though. The
1397              scan can end up taking longer if you specify such a low value
1398              that many probes are timing out and retransmitting while the
1399              response is in transit.
1400
1401              If all the hosts are on a local network, 100 milliseconds is a
1402              reasonable aggressive --max-rtt-timeout value. If routing is
1403              involved, ping a host on the network first with the ICMP ping
1404              utility, or with a custom packet crafter such as hping2 that is
1405              more likely to get through a firewall. Look at the maximum round
1406              trip time out of ten packets or so. You might want to double
1407              that for the --initial-rtt-timeout and triple or quadruple it
1408              for the --max-rtt-timeout. I generally do not set the maximum
1409              rtt below 100ms, no matter what the ping times are. Nor do I
1410              exceed 1000ms.
1411
1412              --min-rtt-timeout is a rarely used option that could be useful
1413              when a network is so unreliable that even Nmap's default is too
1414              aggressive. Since Nmap only reduces the timeout down to the
1415              minimum when the network seems to be reliable, this need is
1416              unusual and should be reported as a bug to the nmap-dev mailing
1417              list.
1418
1419       --max-retries <numtries> (Specify the maximum number of port scan probe
1420       retransmissions)
1421              When Nmap receives no response to a port scan probe, it could
1422              mean the port is filtered. Or maybe the probe or response was
1423              simply lost on the network. It is also possible that the target
1424              host has rate limiting enabled that temporarily blocked the
1425              response. So Nmap tries again by retransmitting the initial
1426              probe. If Nmap detects poor network reliability, it may try many
1427              more times before giving up on a port. While this benefits
1428              accuracy, it also lengthen scan times. When performance is
1429              critical, scans may be sped up by limiting the number of
1430              retransmissions allowed. You can even specify --max-retries 0 to
1431              prevent any retransmissions, though that is rarely recommended.
1432
1433              The default (with no -T template) is to allow ten
1434              retransmissions. If a network seems reliable and the target
1435              hosts aren't rate limiting, Nmap usually only does one
1436              retransmission. So most target scans aren't even affected by
1437              dropping --max-retries to a low value such as three. Such values
1438              can substantially speed scans of slow (rate limited) hosts. You
1439              usually lose some information when Nmap gives up on ports early,
1440              though that may be preferable to letting the --host-timeout
1441              expire and losing all information about the target.
1442
1443       --host-timeout <time> (Give up on slow target hosts)
1444              Some hosts simply take a long time to scan. This may be due to
1445              poorly performing or unreliable networking hardware or software,
1446              packet rate limiting, or a restrictive firewall. The slowest few
1447              percent of the scanned hosts can eat up a majority of the scan
1448              time. Sometimes it is best to cut your losses and skip those
1449              hosts initially. Specify --host-timeout with the maximum amount
1450              of time you are willing to wait. I often specify 30m to ensure
1451              that Nmap doesn't waste more than half an hour on a single host.
1452              Note that Nmap may be scanning other hosts at the same time
1453              during that half an hour as well, so it isn't a complete loss. A
1454              host that times out is skipped. No port table, OS detection, or
1455              version detection results are printed for that host.
1456
1457       --scan-delay <time>; --max-scan-delay <time> (Adjust delay between
1458       probes)
1459              This option causes Nmap to wait at least the given amount of
1460              time between each probe it sends to a given host. This is
1461              particularly useful in the case of rate limiting. Solaris
1462              machines (among many others) will usually respond to UDP scan
1463              probe packets with only one ICMP message per second. Any more
1464              than that sent by Nmap will be wasteful. A --scan-delay of 1s
1465              will keep Nmap at that slow rate. Nmap tries to detect rate
1466              limiting and adjust the scan delay accordingly, but it doesn't
1467              hurt to specify it explicitly if you already know what rate
1468              works best.
1469
1470              When Nmap adjusts the scan delay upward to cope with rate
1471              limiting, the scan slows down dramatically. The --max-scan-delay
1472              option specifies the largest delay that Nmap will allow. Setting
1473              this value too low can lead to wasteful packet retransmissions
1474              and possible missed ports when the target implements strict rate
1475              limiting.
1476
1477              Another use of --scan-delay is to evade threshold based
1478              intrusion detection and prevention systems (IDS/IPS).
1479
1480       --defeat-rst-ratelimit
1481              Many hosts have long used rate limiting to reduce the number of
1482              ICMP error messages (such as port-unreachable errors) they send.
1483              Some systems now apply similar rate limits to the RST (reset)
1484              packets they generate. This can slow Nmap down dramatically as
1485              it adjusts its timing to reflect those rate limits. You can tell
1486              Nmap to ignore those rate limits (for port scans such as SYN
1487              scan which don't treat nonresponsive ports as open) by
1488              specifying --defeat-rst-ratelimit.
1489
1490              Using this option can reduce accuracy, as some ports will appear
1491              nonresponse because Nmap didn't wait long enough for a
1492              rate-limited RST response. With a SYN scan, the non-response
1493              results in the port being labeled filtered rather than the
1494              closed state we see when RST packets are received. This optional
1495              is useful when you only care about open ports, and
1496              distinguishing between closed and filtered ports isn't worth the
1497              extra time.
1498
1499       -T <Paranoid|Sneaky|Polite|Normal|Aggressive|Insane> (Set a timing
1500       template)
1501              While the fine grained timing controls discussed in the previous
1502              section are powerful and effective, some people find them
1503              confusing. Moreover, choosing the appropriate values can
1504              sometimes take more time than the scan you are trying to
1505              optimize. So Nmap offers a simpler approach, with six timing
1506              templates. You can specify them with the -T option and their
1507              number (0 - 5) or their name. The template names are paranoid
1508              (0), sneaky (1), polite (2), normal (3), aggressive (4), and
1509              insane (5). The first two are for IDS evasion. Polite mode slows
1510              down the scan to use less bandwidth and target machine
1511              resources. Normal mode is the default and so -T3 does nothing.
1512              Aggressive mode speeds scans up by making the assumption that
1513              you are on a reasonably fast and reliable network. Finally
1514              Insane mode assumes that you are on an extraordinarily fast
1515              network or are willing to sacrifice some accuracy for speed.
1516
1517              These templates allow the user to specify how aggressive they
1518              wish to be, while leaving Nmap to pick the exact timing values.
1519              The templates also make some minor speed adjustments for which
1520              fine grained control options do not currently exist. For
1521              example, -T4 prohibits the dynamic scan delay from exceeding
1522              10ms for TCP ports and -T5 caps that value at 5 milliseconds.
1523              Templates can be used in combination with fine grained controls,
1524              and the fine-grained controls will you specify will take
1525              precedence over the timing template default for that parameter.
1526              I recommend using -T4 when scanning reasonably modern and
1527              reliable networks. Keep that option even when you add fine
1528              grained controls so that you benefit from those extra minor
1529              optimizations that it enables.
1530
1531              If you are on a decent broadband or ethernet connection, I would
1532              recommend always using -T4. Some people love -T5 though it is
1533              too aggressive for my taste. People sometimes specify -T2
1534              because they think it is less likely to crash hosts or because
1535              they consider themselves to be polite in general. They often
1536              don't realize just how slow -T Polite really is. Their scan may
1537              take ten times longer than a default scan. Machine crashes and
1538              bandwidth problems are rare with the default timing options
1539              (-T3) and so I normally recommend that for cautious scanners.
1540              Omitting version detection is far more effective than playing
1541              with timing values at reducing these problems.
1542
1543              While -T0 and -T1 may be useful for avoiding IDS alerts, they
1544              will take an extraordinarily long time to scan thousands of
1545              machines or ports. For such a long scan, you may prefer to set
1546              the exact timing values you need rather than rely on the canned
1547              -T0 and -T1 values.
1548
1549              The main effects of T0 are serializing the scan so only one port
1550              is scanned at a time, and waiting five minutes between sending
1551              each probe.  T1 and T2 are similar but they only wait 15 seconds
1552              and 0.4 seconds, respectively, between probes.  T3 is Nmap's
1553              default behavior, which includes parallelization.  T4 does the
1554              equivalent of --max-rtt-timeout 1250 --initial-rtt-timeout 500
1555              --max-retries 6 and sets the maximum TCP scan delay to 10
1556              milliseconds.  T5 does the equivalent of --max-rtt-timeout 300
1557              --min-rtt-timeout 50 --initial-rtt-timeout 250 --max-retries 2
1558              --host-timeout 15m as well as setting the maximum TCP scan delay
1559              to 5ms.
1560

FIREWALL/IDS EVASION AND SPOOFING

1562       Many Internet pioneers envisioned a global open network with a
1563       universal IP address space allowing virtual connections between any two
1564       nodes. This allows hosts to act as true peers, serving and retrieving
1565       information from each other. People could access all of their home
1566       systems from work, changing the climate control settings or unlocking
1567       the doors for early guests. This vision of universal connectivity has
1568       been stifled by address space shortages and security concerns. In the
1569       early 1990s, organizations began deploying firewalls for the express
1570       purpose of reducing connectivity. Huge networks were cordoned off from
1571       the unfiltered Internet by application proxies, network address
1572       translation, and packet filters. The unrestricted flow of information
1573       gave way to tight regulation of approved communication channels and the
1574       content that passes over them.
1575
1576       Network obstructions such as firewalls can make mapping a network
1577       exceedingly difficult. It will not get any easier, as stifling casual
1578       reconnaissance is often a key goal of implementing the devices.
1579       Nevertheless, Nmap offers many features to help understand these
1580       complex networks, and to verify that filters are working as intended.
1581       It even supports mechanisms for bypassing poorly implemented defenses.
1582       One of the best methods of understanding your network security posture
1583       is to try to defeat it. Place yourself in the mindset of an attacker,
1584       and deploy techniques from this section against your networks. Launch
1585       an FTP bounce scan, Idle scan, fragmentation attack, or try to tunnel
1586       through one of your own proxies.
1587
1588       In addition to restricting network activity, companies are increasingly
1589       monitoring traffic with intrusion detection systems (IDS). All of the
1590       major IDSs ship with rules designed to detect Nmap scans because scans
1591       are sometimes a precursor to attacks. Many of these products have
1592       recently morphed into intrusion prevention systems (IPS) that actively
1593       block traffic deemed malicious. Unfortunately for network
1594       administrators and IDS vendors, reliably detecting bad intentions by
1595       analyzing packet data is a tough problem. Attackers with patience,
1596       skill, and the help of certain Nmap options can usually pass by IDSs
1597       undetected. Meanwhile, administrators must cope with large numbers of
1598       false positive results where innocent activity is misdiagnosed and
1599       alerted on or blocked.
1600
1601       Occasionally people suggest that Nmap should not offer features for
1602       evading firewall rules or sneaking past IDSs. They argue that these
1603       features are just as likely to be misused by attackers as used by
1604       administrators to enhance security. The problem with this logic is that
1605       these methods would still be used by attackers, who would just find
1606       other tools or patch the functionality into Nmap. Meanwhile,
1607       administrators would find it that much harder to do their jobs.
1608       Deploying only modern, patched FTP servers is a far more powerful
1609       defense than trying to prevent the distribution of tools implementing
1610       the FTP bounce attack.
1611
1612       There is no magic bullet (or Nmap option) for detecting and subverting
1613       firewalls and IDS systems. It takes skill and experience. A tutorial is
1614       beyond the scope of this reference guide, which only lists the relevant
1615       options and describes what they do.
1616
1617       -f (fragment packets); --mtu (using the specified MTU)
1618              The -f option causes the requested scan (including ping scans)
1619              to use tiny fragmented IP packets. The idea is to split up the
1620              TCP header over several packets to make it harder for packet
1621              filters, intrusion detection systems, and other annoyances to
1622              detect what you are doing. Be careful with this! Some programs
1623              have trouble handling these tiny packets. The old-school sniffer
1624              named Sniffit segmentation faulted immediately upon receiving
1625              the first fragment. Specify this option once, and Nmap splits
1626              the packets into 8 bytes or less after the IP header. So a
1627              20-byte TCP header would be split into 3 packets. Two with eight
1628              bytes of the TCP header, and one with the final four. Of course
1629              each fragment also has an IP header. Specify -f again to use 16
1630              bytes per fragment (reducing the number of fragments). Or you
1631              can specify your own offset size with the --mtu option. Don't
1632              also specify -f if you use --mtu. The offset must be a multiple
1633              of 8. While fragmented packets won't get by packet filters and
1634              firewalls that queue all IP fragments, such as the
1635              CONFIG_IP_ALWAYS_DEFRAG option in the Linux kernel, some
1636              networks can't afford the performance hit this causes and thus
1637              leave it disabled. Others can't enable this because fragments
1638              may take different routes into their networks. Some source
1639              systems defragment outgoing packets in the kernel. Linux with
1640              the iptables connection tracking module is one such example. Do
1641              a scan while a sniffer such as Ethereal is running to ensure
1642              that sent packets are fragmented. If your host OS is causing
1643              problems, try the --send-eth option to bypass the IP layer and
1644              send raw ethernet frames.
1645
1646       -D <decoy1 [,decoy2][,ME],...> (Cloak a scan with decoys)
1647              Causes a decoy scan to be performed, which makes it appear to
1648              the remote host that the host(s) you specify as decoys are
1649              scanning the target network too. Thus their IDS might report
1650              5-10 port scans from unique IP addresses, but they won't know
1651              which IP was scanning them and which were innocent decoys. While
1652              this can be defeated through router path tracing,
1653              response-dropping, and other active mechanisms, it is generally
1654              an effective technique for hiding your IP address.
1655
1656              Separate each decoy host with commas, and you can optionally use
1657              ME as one of the decoys to represent the position for your real
1658              IP address. If you put ME in the 6th position or later, some
1659              common port scan detectors (such as Solar Designer's excellent
1660              scanlogd) are unlikely to show your IP address at all. If you
1661              don't use ME, nmap will put you in a random position.
1662
1663              Note that the hosts you use as decoys should be up or you might
1664              accidentally SYN flood your targets. Also it will be pretty easy
1665              to determine which host is scanning if only one is actually up
1666              on the network. You might want to use IP addresses instead of
1667              names (so the decoy networks don't see you in their nameserver
1668              logs).
1669
1670              Decoys are used both in the initial ping scan (using ICMP, SYN,
1671              ACK, or whatever) and during the actual port scanning phase.
1672              Decoys are also used during remote OS detection (-O). Decoys do
1673              not work with version detection or TCP connect scan.
1674
1675              It is worth noting that using too many decoys may slow your scan
1676              and potentially even make it less accurate. Also, some ISPs will
1677              filter out your spoofed packets, but many do not restrict
1678              spoofed IP packets at all.
1679
1680       -S <IP_Address> (Spoof source address)
1681              In some circumstances, Nmap may not be able to determine your
1682              source address ( Nmap will tell you if this is the case). In
1683              this situation, use -S with the IP address of the interface you
1684              wish to send packets through.
1685
1686              Another possible use of this flag is to spoof the scan to make
1687              the targets think that someone else is scanning them. Imagine a
1688              company being repeatedly port scanned by a competitor! The -e
1689              option and -P0 are generally required for this sort of usage.
1690              Note that you usually won't receive reply packets back (they
1691              will be addressed to the IP you are spoofing), so Nmap won't
1692              produce useful reports.
1693
1694       -e <interface> (Use specified interface)
1695              Tells Nmap what interface to send and receive packets on. Nmap
1696              should be able to detect this automatically, but it will tell
1697              you if it cannot.
1698
1699       --source-port <portnumber>; -g <portnumber> (Spoof source port number)
1700              One surprisingly common misconfiguration is to trust traffic
1701              based only on the source port number. It is easy to understand
1702              how this comes about. An administrator will set up a shiny new
1703              firewall, only to be flooded with complains from ungrateful
1704              users whose applications stopped working. In particular, DNS may
1705              be broken because the UDP DNS replies from external servers can
1706              no longer enter the network. FTP is another common example. In
1707              active FTP transfers, the remote server tries to establish a
1708              connection back to the client to transfer the requested file.
1709
1710              Secure solutions to these problems exist, often in the form of
1711              application-level proxies or protocol-parsing firewall modules.
1712              Unfortunately there are also easier, insecure solutions. Noting
1713              that DNS replies come from port 53 and active ftp from port 20,
1714              many admins have fallen into the trap of simply allowing
1715              incoming traffic from those ports. They often assume that no
1716              attacker would notice and exploit such firewall holes. In other
1717              cases, admins consider this a short-term stop-gap measure until
1718              they can implement a more secure solution. Then they forget the
1719              security upgrade.
1720
1721              Overworked network administrators are not the only ones to fall
1722              into this trap. Numerous products have shipped with these
1723              insecure rules. Even Microsoft has been guilty. The IPsec
1724              filters that shipped with Windows 2000 and Windows XP contain an
1725              implicit rule that allows all TCP or UDP traffic from port 88
1726              (Kerberos). In another well-known case, versions of the Zone
1727              Alarm personal firewall up to 2.1.25 allowed any incoming UDP
1728              packets with the source port 53 (DNS) or 67 (DHCP).
1729
1730              Nmap offers the -g and --source-port options (they are
1731              equivalent) to exploit these weaknesses. Simply provide a port
1732              number and Nmap will send packets from that port where possible.
1733              Nmap must use different port numbers for certain OS detection
1734              tests to work properly, and DNS requests ignore the
1735              --source-port flag because Nmap relies on system libraries to
1736              handle those. Most TCP scans, including SYN scan, support the
1737              option completely, as does UDP scan.
1738
1739       --data-length <number> (Append random data to sent packets)
1740              Normally Nmap sends minimalist packets containing only a header.
1741              So its TCP packets are generally 40 bytes and ICMP echo requests
1742              are just 28. This option tells Nmap to append the given number
1743              of random bytes to most of the packets it sends. OS detection
1744              (-O) packets are not affected because accuracy there requires
1745              probe consistency, but most pinging and portscan packets support
1746              this. It slows things down a little, but can make a scan
1747              slightly less conspicuous.
1748
1749       --ip-options <S|R [route]|L [route]|T|U ... >; --ip-options <hex
1750       string> (Send packets with specified ip options)
1751              The [6]IP protocol offers several options which may be placed in
1752              packet headers. Unlike the ubiquitous TCP options, IP options
1753              are rarely seen due to practicality and security concerns. In
1754              fact, many Internet routers block the most dangerous options
1755              such as source routing. Yet options can still be useful in some
1756              cases for determining and manipulating the network route to
1757              target machines. For example, you may be able to use the record
1758              route option to determine a path to a target even when more
1759              traditional traceroute-style approaches fail. Or if your packets
1760              are being dropped by a certain firewall, you may be able to
1761              specify a different route with the strict or loose source
1762              routing options.
1763
1764              The most powerful way to specify IP options is to simply pass in
1765              values as the argument to --ip-options. Precede each hex number
1766              with \x then the two digits. You may repeat certain characters
1767              by following them with an asterisk and then the number of times
1768              you wish them to repeat. For example, \x01\x07\x04\x00*36\x01 is
1769              a hex string containing 36 NUL bytes.
1770
1771              Nmap also offers a shortcut mechanism for specifying options.
1772              Simply pass the letter R, T, or U to request record-route,
1773              record-timestamp, or both options together, respectively. Loose
1774              or strict source routing may be specified with an L or S
1775              followed by a space and then a space-separated list of IP
1776              addresses.
1777
1778              If you wish to see the options in packets sent and received,
1779              specify --packet-trace. For more information and examples of
1780              using IP options with Nmap, see
1781              http://seclists.org/nmap-dev/2006/q3/0052.html.
1782
1783       --ttl <value> (Set IP time-to-live field)
1784              Sets the IPv4 time-to-live field in sent packets to the given
1785              value.
1786
1787       --randomize-hosts (Randomize target host order)
1788              Tells Nmap to shuffle each group of up to 8096 hosts before it
1789              scans them. This can make the scans less obvious to various
1790              network monitoring systems, especially when you combine it with
1791              slow timing options. If you want to randomize over larger group
1792              sizes, increase PING_GROUP_SZ in nmap.h and recompile. An
1793              alternative solution is to generate the target IP list with a
1794              list scan (-sL -n -oN filename), randomize it with a Perl
1795              script, then provide the whole list to Nmap with -iL.
1796
1797       --spoof-mac <mac address, prefix, or vendor name> (Spoof MAC address)
1798              Asks Nmap to use the given MAC address for all of the raw
1799              ethernet frames it sends. This option implies --send-eth to
1800              ensure that Nmap actually sends ethernet-level packets. The MAC
1801              given can take several formats. If it is simply the string “0”,
1802              Nmap chooses a completely random MAC for the session. If the
1803              given string is an even number of hex digits (with the pairs
1804              optionally separated by a colon), Nmap will use those as the
1805              MAC. If less than 12 hex digits are provided, Nmap fills in the
1806              remainder of the 6 bytes with random values. If the argument
1807              isn't a 0 or hex string, Nmap looks through nmap-mac-prefixes to
1808              find a vendor name containing the given string (it is case
1809              insensitive). If a match is found, Nmap uses the vendor's OUI
1810              (3-byte prefix) and fills out the remaining 3 bytes randomly.
1811              Valid --spoof-mac argument examples are Apple, 0,
1812              01:02:03:04:05:06, deadbeefcafe, 0020F2, and Cisco.
1813
1814       --badsum (Send packets with bogus TCP/UDP checksums)
1815              Asks Nmap to use an invalid TCP or UDP checksum for packets sent
1816              to target hosts. Since virtually all host IP stacks properly
1817              drop these packets, any responses received are likely coming
1818              from a firewall or IDS that didn't bother to verify the
1819              checksum. For more details on this technique, see
1820              http://www.phrack.org/phrack/60/p60-0x0c.txt
1821

OUTPUT

1823       Any security tools is only as useful as the output it generates.
1824       Complex tests and algorithms are of little value if they aren't
1825       presented in an organized and comprehensible fashion. Given the number
1826       of ways Nmap is used by people and other software, no single format can
1827       please everyone. So Nmap offers several formats, including the
1828       interactive mode for humans to read directly and XML for easy parsing
1829       by software.
1830
1831       In addition to offering different output formats, Nmap provides options
1832       for controlling the verbosity of output as well as debugging messages.
1833       Output types may be sent to standard output or to named files, which
1834       Nmap can append to or clobber. Output files may also be used to resume
1835       aborted scans.
1836
1837       Nmap makes output available in five different formats. The default is
1838       called interactive output, and it is sent to standard output (stdout).
1839       There is also normal output, which is similar to interactive except
1840       that it displays less runtime information and warnings since it is
1841       expected to be analyzed after the scan completes rather than
1842       interactively.
1843
1844       XML output is one of the most important output types, as it can be
1845       converted to HTML, easily parsed by programs such as Nmap graphical
1846       user interfaces, or imported into databases.
1847
1848       The two remaining output types are the simple grepable output which
1849       includes most information for a target host on a single line, and
1850       sCRiPt KiDDi3 0utPUt for users who consider themselves |<-r4d.
1851
1852       While interactive output is the default and has no associated
1853       command-line options, the other four format options use the same
1854       syntax. They take one argument, which is the filename that results
1855       should be stored in. Multiple formats may be specified, but each format
1856       may only be specified once. For example, you may wish to save normal
1857       output for your own review while saving XML of the same scan for
1858       programmatic analysis. You might do this with the options -oX
1859       myscan.xml -oN myscan.nmap. While this chapter uses the simple names
1860       like myscan.xml for brevity, more descriptive names are generally
1861       recommended. The names chosen are a matter of personal preference,
1862       though I use long ones that incorporate the scan date and a word or two
1863       describing the scan, placed in a directory named after the company I'm
1864       scanning.
1865
1866       While these options save results to files, Nmap still prints
1867       interactive output to stdout as usual. For example, the command nmap
1868       -oX myscan.xml target prints XML to myscan.xml and fills standard
1869       output with the same interactive results it would have printed if -oX
1870       wasn't specified at all. You can change this by passing a hyphen
1871       character as the argument to one of the format types. This causes Nmap
1872       to deactivate interactive output, and instead print results in the
1873       format you specified to the standard output stream. So the command nmap
1874       -oX - target will send only XML output to stdout. Serious errors may
1875       still be printed to the normal error stream, stderr.
1876
1877       Unlike some Nmap arguments, the space between the logfile option flag
1878       (such as -oX) and the filename or hyphen is mandatory. If you omit the
1879       flags and give arguments such as -oG- or -oXscan.xml, a backwards
1880       compatibility feature of Nmap will cause the creation of normal format
1881       output files named G- and Xscan.xml respectively.
1882
1883       Nmap also offers options to control scan verbosity and to append to
1884       output files rather than clobbering them. All of these options are
1885       described below.
1886
1887       Nmap Output Formats
1888
1889       -oN <filespec> (Normal output)
1890              Requests that normal output be directed to the given filename.
1891              As discussed above, this differs slightly from interactive
1892              output.
1893
1894       -oX <filespec> (XML output)
1895              Requests that XML output be directed to the given filename. Nmap
1896              includes a document type definition (DTD) which allows XML
1897              parsers to validate Nmap XML output. While it is primarily
1898              intended for programmatic use, it can also help humans interpret
1899              Nmap XML output. The DTD defines the legal elements of the
1900              format, and often enumerates the attributes and values they can
1901              take on. The latest version is always available from
1902              http://insecure.org/nmap/data/nmap.dtd.
1903
1904              XML offers a stable format that is easily parsed by software.
1905              Free XML parsers are available for all major computer languages,
1906              including C/C++, Perl, Python, and Java. People have even
1907              written bindings for most of these languages to handle Nmap
1908              output and execution specifically. Examples are [7]Nmap::Scanner
1909              and [8]Nmap::Parser in Perl CPAN. In almost all cases that a
1910              non-trivial application interfaces with Nmap, XML is the
1911              preferred format.
1912
1913              The XML output references an XSL stylesheet which can be used to
1914              format the results as HTML. The easiest way to use this is
1915              simply to load the XML output in a web browser such as Firefox
1916              or IE. By default, this will only work on the machine you ran
1917              Nmap on (or a similarly configured one) due to the hard-coded
1918              nmap.xsl filesystem path. Use the --webxml or --stylesheet
1919              options to create portable XML files that render as HTML on any
1920              web-connected machine.
1921
1922       -oS <filespec> (ScRipT KIdd|3 oUTpuT)
1923              Script kiddie output is like interactive output, except that it
1924              is post-processed to better suit the l33t HaXXorZ who previously
1925              looked down on Nmap due to its consistent capitalization and
1926              spelling. Humor impaired people should note that this option is
1927              making fun of the script kiddies before flaming me for
1928              supposedly “helping them”.
1929
1930       -oG <filespec> (Grepable output)
1931              This output format is covered last because it is deprecated. The
1932              XML output format is far more powerful, and is nearly as
1933              convenient for experienced users. XML is a standard for which
1934              dozens of excellent parsers are available, while grepable output
1935              is my own simple hack. XML is extensible to support new Nmap
1936              features as they are released, while I often must omit those
1937              features from grepable output for lack of a place to put them.
1938
1939              Nevertheless, grepable output is still quite popular. It is a
1940              simple format that lists each host on one line and can be
1941              trivially searched and parsed with standard UNIX tools such as
1942              grep, awk, cut, sed, diff, and Perl. Even I usually use it for
1943              one-off tests done at the command line. Finding all the hosts
1944              with the ssh port open or that are running Solaris takes only a
1945              simple grep to identify the hosts, piped to an awk or cut
1946              command to print the desired fields.
1947
1948              Grepable output consists of comments (lines starting with a
1949              pound (#)) and target lines. A target line includes a
1950              combination of 6 labeled fields, separated by tabs and followed
1951              with a colon. The fields are Host, Ports, Protocols, Ignored
1952              State, OS, Seq Index, IPID, and Status.
1953
1954              The most important of these fields is generally Ports, which
1955              gives details on each interesting port. It is a comma separated
1956              list of port entries. Each port entry represents one interesting
1957              port, and takes the form of seven slash (/) separated subfields.
1958              Those subfields are: Port number, State, Protocol, Owner,
1959              Service, SunRPC info, and Version info.
1960
1961              As with XML output, this man page does not allow for documenting
1962              the entire format. A more detailed look at the Nmap grepable
1963              output format is available from
1964              http://www.unspecific.com/nmap-oG-output.
1965
1966       -oA <basename> (Output to all formats)
1967
1968              As a convenience, you may specify -oA basename to store scan
1969              results in normal, XML, and grepable formats at once. They are
1970              stored in basename.nmap, basename.xml, and basename.gnmap,
1971              respectively. As with most programs, you can prefix the
1972              filenames with a directory path, such as ~/nmaplogs/foocorp/ on
1973              UNIX or c:\hacking\sco on Windows.
1974
1975       Verbosity and debugging options
1976
1977       -v (Increase verbosity level)
1978              Increases the verbosity level, causing Nmap to print more
1979              information about the scan in progress. Open ports are shown as
1980              they are found and completion time estimates are provided when
1981              Nmap thinks a scan will take more than a few minutes. Use it
1982              twice for even greater verbosity. Using it more than twice has
1983              no effect.
1984
1985              Most changes only affect interactive output, and some also
1986              affect normal and script kiddie output. The other output types
1987              are meant to be processed by machines, so Nmap can give
1988              substantial detail by default in those formats without fatiguing
1989              a human user. However, there are a few changes in other modes
1990              where output size can be reduced substantially by omitting some
1991              detail. For example, a comment line in the grepable output that
1992              provides a list of all ports scanned is only printed in verbose
1993              mode because it can be quite long.
1994
1995       -d [level] (Increase or set debugging level)
1996              When even verbose mode doesn't provide sufficient data for you,
1997              debugging is available to flood you with much more! As with the
1998              verbosity option (-v), debugging is enabled with a command-line
1999              flag (-d) and the debug level can be increased by specifying it
2000              multiple times. Alternatively, you can set a debug level by
2001              giving an argument to -d. For example, -d9 sets level nine. That
2002              is the highest effective level and will produce thousands of
2003              lines unless you run a very simple scan with very few ports and
2004              targets.
2005
2006              Debugging output is useful when a bug is suspected in Nmap, or
2007              if you are simply confused as to what Nmap is doing and why. As
2008              this feature is mostly intended for developers, debug lines
2009              aren't always self-explanatory. You may get something like:
2010              Timeout vals: srtt: -1 rttvar: -1 to: 1000000 delta 14987 ==>
2011              srtt: 14987 rttvar: 14987 to: 100000. If you don't understand a
2012              line, your only recourses are to ignore it, look it up in the
2013              source code, or request help from the development list
2014              (nmap-dev). Some lines are self explanatory, but the messages
2015              become more obscure as the debug level is increased.
2016
2017       --packet-trace (Trace packets and data sent and received)
2018              Causes Nmap to print a summary of every packet sent or received.
2019              This is often used for debugging, but is also a valuable way for
2020              new users to understand exactly what Nmap is doing under the
2021              covers. To avoid printing thousands of lines, you may want to
2022              specify a limited number of ports to scan, such as -p20-30. If
2023              you only care about the goings on of the version detection
2024              subsystem, use --version-trace instead.
2025
2026       --open (Show only open (or possibly open) ports)
2027              Sometimes you only care about ports you can actually connect to
2028              (open ones), and don't want results cluttered with closed,
2029              filtered, and closed|filtered ports. Output customization is
2030              normally done after the scan using tools such as grep, awk, and
2031              Perl, but this feature was added due to overwhelming requests.
2032              Specify --open to only see open, open|filtered, and unfiltered
2033              ports. These three ports are treated just as they normally are,
2034              which means that open|filtered and unfiltered may be condensed
2035              into counts if there are an overwhelming number of them.
2036
2037       --iflist (List interfaces and routes)
2038              Prints the interface list and system routes as detected by Nmap.
2039              This is useful for debugging routing problems or device
2040              mischaracterization (such as Nmap treating a PPP connection as
2041              Ethernet).
2042
2043       --log-errors (Log errors/warnings to normal mode output file)
2044              Warnings and errors printed by Nmap usually go only to the
2045              screen (interactive output), leaving any specified normal-fomat
2046              output files uncluttered. But when you do want to see those
2047              messages in the normal output file you specified, add this
2048              option. It is useful when you aren't watching the interactive
2049              output or are trying to debug a problem. The messages will also
2050              still appear in interactive mode. This will not work for most
2051              errors related to bad command-line arguments, as Nmap may not
2052              have initialized its output files yet. In addition, some Nmap
2053              error/warning messages use a different system that does not yet
2054              support this option. An alternative to using this option is
2055              redirecting interactive output (including the standard error
2056              stream) to a file. While most UNIX shells make that approach
2057              easy, it can be difficult on Windows.
2058
2059       Miscellaneous output options
2060
2061       --append-output (Append to rather than clobber output files)
2062              When you specify a filename to an output format flag such as -oX
2063              or -oN, that file is overwritten by default. If you prefer to
2064              keep the existing content of the file and append the new
2065              results, specify the --append-output option. All output
2066              filenames specified in that Nmap execution will then be appended
2067              to rather than clobbered. This doesn't work well for XML (-oX)
2068              scan data as the resultant file generally won't parse properly
2069              until you fix it up by hand.
2070
2071       --resume <filename> (Resume aborted scan)
2072              Some extensive Nmap runs take a very long time -- on the order
2073              of days. Such scans don't always run to completion. Restrictions
2074              may prevent Nmap from being run during working hours, the
2075              network could go down, the machine Nmap is running on might
2076              suffer a planned or unplanned reboot, or Nmap itself could
2077              crash. The admin running Nmap could cancel it for any other
2078              reason as well, by pressing ctrl-C. Restarting the whole scan
2079              from the beginning may be undesirable. Fortunately, if normal
2080              (-oN) or grepable (-oG) logs were kept, the user can ask Nmap to
2081              resume scanning with the target it was working on when execution
2082              ceased. Simply specify the --resume option and pass the
2083              normal/grepable output file as its argument. No other arguments
2084              are permitted, as Nmap parses the output file to use the same
2085              ones specified previously. Simply call Nmap as nmap --resume
2086              logfilename. Nmap will append new results to the data files
2087              specified in the previous execution. Resumption does not support
2088              the XML output format because combining the two runs into one
2089              valid XML file would be difficult.
2090
2091       --stylesheet <path or URL> (Set XSL stylesheet to transform XML output)
2092              Nmap ships with an XSL stylesheet named nmap.xsl for viewing or
2093              translating XML output to HTML. The XML output includes an
2094              xml-stylesheet directive which points to nmap.xml where it was
2095              initially installed by Nmap (or in the current working directory
2096              on Windows). Simply load Nmap's XML output in a modern web
2097              browser and it should retrieve nmap.xsl from the filesystem and
2098              use it to render results. If you wish to use a different
2099              stylesheet, specify it as the argument to --stylesheet. You must
2100              pass the full pathname or URL. One common invocation is
2101              --stylesheet http://insecure.org/nmap/data/nmap.xsl. This tells
2102              a browser to load the latest version of the stylesheet from
2103              Insecure.Org. The --webxml option does the same thing with less
2104              typing and memorization. Loading the XSL from Insecure.Org makes
2105              it easier to view results on a machine that doesn't have Nmap
2106              (and thus nmap.xsl) installed. So the URL is often more useful,
2107              but the local filesystem location of nmap.xsl is used by default
2108              for privacy reasons.
2109
2110       --webxml (Load stylesheet from Insecure.Org)
2111              This convenience option is simply an alias for --stylesheet
2112              http://insecure.org/nmap/data/nmap.xsl.
2113
2114       --no_stylesheet (Omit XSL stylesheet declaration from XML)
2115              Specify this option to prevent Nmap from associating any XSL
2116              stylesheet with its XML output. The xml-stylesheet directive is
2117              omitted.
2118

MISCELLANEOUS OPTIONS

2120       This section describes some important (and not-so-important) options
2121       that don't really fit anywhere else.
2122
2123       -6 (Enable IPv6 scanning)
2124              Since 2002, Nmap has offered IPv6 support for its most popular
2125              features. In particular, ping scanning (TCP-only), connect
2126              scanning, and version detection all support IPv6. The command
2127              syntax is the same as usual except that you also add the -6
2128              option. Of course, you must use IPv6 syntax if you specify an
2129              address rather than a hostname. An address might look like
2130              3ffe:7501:4819:2000:210:f3ff:fe03:14d0, so hostnames are
2131              recommended. The output looks the same as usual, with the IPv6
2132              address on the “interesting ports” line being the only IPv6 give
2133              away.
2134
2135              While IPv6 hasn't exactly taken the world by storm, it gets
2136              significant use in some (usually Asian) countries and most
2137              modern operating systems support it. To use Nmap with IPv6, both
2138              the source and target of your scan must be configured for IPv6.
2139              If your ISP (like most of them) does not allocate IPv6 addresses
2140              to you, free tunnel brokers are widely available and work fine
2141              with Nmap. One of the better ones is run by BT Exact at
2142              https://tb.ipv6.btexact.com/. I have also used one that
2143              Hurricane Electric provides at http://ipv6tb.he.net/. 6to4
2144              tunnels are another popular, free approach.
2145
2146       -A (Aggressive scan options)
2147              This option enables additional advanced and aggressive options.
2148              I haven't decided exactly which it stands for yet. Presently
2149              this enables OS Detection (-O) and version scanning (-sV). More
2150              features may be added in the future. The point is to enable a
2151              comprehensive set of scan options without people having to
2152              remember a large set of flags. This option only enables
2153              features, and not timing options (such as -T4) or verbosity
2154              options (-v) that you might want as well.
2155
2156       --datadir <directoryname> (Specify custom Nmap data file location)
2157              Nmap obtains some special data at runtime in files named
2158              nmap-service-probes, nmap-services, nmap-protocols, nmap-rpc,
2159              nmap-mac-prefixes, and nmap-os-fingerprints. Nmap first searches
2160              these files in the directory specified with the --datadir option
2161              (if any). Any files not found there, are searched for in the
2162              directory specified by the NMAPDIR environmental variable. Next
2163              comes ~/.nmap for real and effective UIDs (POSIX systems only)
2164              or location of the Nmap executable (Win32 only), and then a
2165              compiled-in location such as /usr/local/share/nmap or
2166              /usr/share/nmap
2167
2168       --send-eth (Use raw ethernet sending)
2169              Asks Nmap to send packets at the raw ethernet (data link) layer
2170              rather than the higher IP (network) layer. By default, Nmap
2171              chooses the one which is generally best for the platform it is
2172              running on. Raw sockets (IP layer) are generally most efficient
2173              for UNIX machines, while ethernet frames are required for
2174              Windows operation since Microsoft disabled raw socket support.
2175              Nmap still uses raw IP packets on UNIX despite this option when
2176              there is no other choice (such as non-ethernet connections).
2177
2178       --send-ip (Send at raw IP level)
2179              Asks Nmap to send packets via raw IP sockets rather than sending
2180              lower level ethernet frames. It is the complement to the
2181              --send-eth option discussed previously.
2182
2183       --privileged (Assume that the user is fully privileged)
2184              Tells Nmap to simply assume that it is privileged enough to
2185              perform raw socket sends, packet sniffing, and similar
2186              operations that usually require root privileges on UNIX systems.
2187              By default Nmap quits if such operations are requested but
2188              geteuid() is not zero.  --privileged is useful with Linux kernel
2189              capabilities and similar systems that may be configured to allow
2190              unprivileged users to perform raw-packet scans. Be sure to
2191              provide this option flag before any flags for options that
2192              require privileges (SYN scan, OS detection, etc.). The
2193              NMAP_PRIVILEGED variable may be set as an equivalent alternative
2194              to --privileged.
2195
2196       --unprivileged (Assume that the user lacks raw socket privileges)
2197              This option is the opposite of --privileged. It tells Nmap to
2198              treat the user as lacking network raw socket and sniffing
2199              privileges. This is useful for testing, debugging, or when the
2200              raw network functionality of your operating system is somehow
2201              broken.
2202
2203       --release-memory (Release memory before quitting)
2204              This option is only useful for memory-leak debugging. It causes
2205              Nmap to release allocated memory just before it quits so that
2206              actual memory leaks are easier to spot. Normally Nmap skips this
2207              as the OS does this anyway upon process termination.
2208
2209       --interactive (Start in interactive mode)
2210              Starts Nmap in interactive mode, which offers an interactive
2211              Nmap prompt allowing easy launching of multiple scans (either
2212              synchronously or in the background). This is useful for people
2213              who scan from multi-user systems as they often want to test
2214              their security without letting everyone else on the system know
2215              exactly which systems they are scanning. Use --interactive to
2216              activate this mode and then type h for help. This option is
2217              rarely used because proper shells are usually more familiar and
2218              feature-complete. This option includes a bang (!) operator for
2219              executing shell commands, which is one of many reasons not to
2220              install Nmap setuid root.
2221
2222       -V; --version (Print version number)
2223              Prints the Nmap version number and exits.
2224
2225       -h; --help (Print help summary page)
2226              Prints a short help screen with the most common command flags.
2227              Running Nmap without any arguments does the same thing.
2228

RUNTIME INTERACTION

2230       During the execution of nmap, all key presses are captured. This allows
2231       you to interact with the program without aborting and restarting it.
2232       Certain special keys will change options, while any other keys will
2233       print out a status message telling you about the scan. The convention
2234       is that lowercase letters increase the amount of printing, and
2235       uppercase letters decrease the printing. You may also press ‘?’ for
2236       help.
2237
2238       v / V  Increase / Decrease the Verbosity
2239
2240       d / D  Increase / Decrease the Debugging Level
2241
2242       p / P  Turn on / off Packet Tracing
2243
2244       ?      Print a runtime interaction help screen
2245
2246       Anything else
2247              Print out a status message like this:
2248
2249              Stats: 0:00:08 elapsed; 111 hosts completed (5 up), 5 undergoing
2250              Service Scan
2251
2252              Service scan Timing: About 28.00% done; ETC: 16:18 (0:00:15
2253              remaining)
2254

EXAMPLES

2256       Here are some Nmap usage examples, from the simple and routine to a
2257       little more complex and esoteric. Some actual IP addresses and domain
2258       names are used to make things more concrete. In their place you should
2259       substitute addresses/names from your own network.. While I don't think
2260       port scanning other networks is or should be illegal, some network
2261       administrators don't appreciate unsolicited scanning of their networks
2262       and may complain. Getting permission first is the best approach.
2263
2264       For testing purposes, you have permission to scan the host
2265       scanme.nmap.org. This permission only includes scanning via Nmap and
2266       not testing exploits or denial of service attacks. To conserve
2267       bandwidth, please do not initiate more than a dozen scans against that
2268       host per day. If this free scanning target service is abused, it will
2269       be taken down and Nmap will report Failed to resolve given hostname/IP:
2270       scanme.nmap.org. These permissions also apply to the hosts
2271       scanme2.nmap.org, scanme3.nmap.org, and so on, though those hosts do
2272       not currently exist.
2273
2274       nmap -v scanme.nmap.org
2275
2276       This option scans all reserved TCP ports on the machine scanme.nmap.org
2277       -v option enables verbose mode.
2278
2279       nmap -sS -O scanme.nmap.org/24
2280
2281       Launches a stealth SYN scan against each machine that is up out of the
2282       255 machines on “class C” network where Scanme resides. It also tries
2283       to determine what operating system is running on each host that is up
2284       and running. This requires root privileges because of the SYN scan and
2285       OS detection.
2286
2287       nmap -sV -p 22,53,110,143,4564 198.116.0-255.1-127
2288
2289       Launches host enumeration and a TCP scan at the first half of each of
2290       the 255 possible 8 bit subnets in the 198.116 class B address space.
2291       This tests whether the systems run sshd, DNS, pop3d, imapd, or port
2292       4564. For any of these ports found open, version detection is used to
2293       determine what application is running.
2294
2295       nmap -v -iR 100000 -P0 -p 80
2296
2297       Asks Nmap to choose 100,000 hosts at random and scan them for web
2298       servers (port 80). Host enumeration is disabled with -P0 since first
2299       sending a couple probes to determine whether a host is up is wasteful
2300       when you are only probing one port on each target host anyway.
2301
2302       nmap -P0 -p80 -oX logs/pb-port80scan.xml -oG logs/pb-port80scan.gnmap
2303       216.163.128.20/20
2304
2305       This scans 4096 IPs for any webservers (without pinging them) and saves
2306       the output in grepable and XML formats.
2307

BUGS

2309       Like its author, Nmap isn't perfect. But you can help make it better by
2310       sending bug reports or even writing patches. If Nmap doesn't behave the
2311       way you expect, first upgrade to the latest version available from
2312       http://insecure.org/nmap/. If the problem persists, do some research to
2313       determine whether it has already been discovered and addressed. Try
2314       Googling the error message or browsing the Nmap-dev archives at
2315       http://seclists.org/. Read this full munual page as well. If nothing
2316       comes of this, mail a bug report to <nmap-dev@insecure.org>. Please
2317       include everything you have learned about the problem, as well as what
2318       version of Nmap you are running and what operating system version it is
2319       running on. Problem reports and Nmap usage questions sent to
2320       nmap-dev@insecure.org are far more likely to be answered than those
2321       sent to Fyodor directly.
2322
2323       Code patches to fix bugs are even better than bug reports. Basic
2324       instructions for creating patch files with your changes are available
2325       at http://insecure.org/nmap/data/HACKING. Patches may be sent to
2326       nmap-dev (recommended) or to Fyodor directly.
2327

AUTHOR

2329       Fyodor <fyodor@insecure.org> (http://insecure.org)
2330
2331       Hundreds of people have made valuable contributions to Nmap over the
2332       years. These are detailed in the CHANGELOG file which is distributed
2333       with Nmap and also available from
2334       http://insecure.org/nmap/changelog.html.
2335
2337   Nmap Copyright and Licensing
2338       The Nmap Security Scanner is (C) 1996-2005 Insecure.Com LLC. Nmap is
2339       also a registered trademark of Insecure.Com LLC. This program is free
2340       software; you may redistribute and/or modify it under the terms of the
2341       GNU General Public License as published by the Free Software
2342       Foundation; Version 2. This guarantees your right to use, modify, and
2343       redistribute this software under certain conditions. If you wish to
2344       embed Nmap technology into proprietary software, we may be willing to
2345       sell alternative licenses (contact <sales@insecure.com>). Many security
2346       scanner vendors already license Nmap technology such as host discovery,
2347       port scanning, OS detection, and service/version detection.
2348
2349       Note that the GPL places important restrictions on “derived works”, yet
2350       it does not provide a detailed definition of that term. To avoid
2351       misunderstandings, we consider an application to constitute a
2352       “derivative work” for the purpose of this license if it does any of the
2353       following:
2354
2355       ·  Integrates source code from Nmap
2356
2357       ·  Reads or includes Nmap copyrighted data files, such as
2358          nmap-os-fingerprints or nmap-service-probes.
2359
2360       ·  Executes Nmap and parses the results (as opposed to typical shell or
2361          execution-menu apps, which simply display raw Nmap output and so are
2362          not derivative works.)
2363
2364       ·  Integrates/includes/aggregates Nmap into a proprietary executable
2365          installer, such as those produced by InstallShield.
2366
2367       ·  Links to a library or executes a program that does any of the above.
2368
2369       The term “Nmap” should be taken to also include any portions or derived
2370       works of Nmap. This list is not exclusive, but is just meant to clarify
2371       our interpretation of derived works with some common examples. These
2372       restrictions only apply when you actually redistribute Nmap. For
2373       example, nothing stops you from writing and selling a proprietary
2374       front-end to Nmap. Just distribute it by itself, and point people to
2375       http://insecure.org/nmap/ to download Nmap.
2376
2377       We don't consider these to be added restrictions on top of the GPL, but
2378       just a clarification of how we interpret “derived works” as it applies
2379       to our GPL-licensed Nmap product. This is similar to the way Linus
2380       Torvalds has announced his interpretation of how “derived works”
2381       applies to Linux kernel modules. Our interpretation refers only to Nmap
2382       - we don't speak for any other GPL products.
2383
2384       If you have any questions about the GPL licensing restrictions on using
2385       Nmap in non-GPL works, we would be happy to help. As mentioned above,
2386       we also offer alternative license to integrate Nmap into proprietary
2387       applications and appliances. These contracts have been sold to many
2388       security vendors, and generally include a perpetual license as well as
2389       providing for priority support and updates as well as helping to fund
2390       the continued development of Nmap technology. Please email
2391       <sales@insecure.com> for further information.
2392
2393       As a special exception to the GPL terms, Insecure.Com LLC grants
2394       permission to link the code of this program with any version of the
2395       OpenSSL library which is distributed under a license identical to that
2396       listed in the included Copying.OpenSSL file, and distribute linked
2397       combinations including the two. You must obey the GNU GPL in all
2398       respects for all of the code used other than OpenSSL. If you modify
2399       this file, you may extend this exception to your version of the file,
2400       but you are not obligated to do so.
2401
2402       If you received these files with a written license agreement or
2403       contract stating terms other than the terms above, then that
2404       alternative license agreement takes precedence over these comments.
2405
2406   Creative Commons license for this Nmap guide
2407       This Nmap Reference Guide is (C) 2005 Insecure.Com LLC. It is hereby
2408       placed under version 2.5 of the [9]Creative Commons Attribution
2409       License. This allows you redistribute and modify the work as you
2410       desire, as long as you credit the original source. Alternatively, you
2411       may choose to treat this document as falling under the same license as
2412       Nmap itself (discussed previously).
2413
2414   Source code availability and community contributions
2415       Source is provided to this software because we believe users have a
2416       right to know exactly what a program is going to do before they run it.
2417       This also allows you to audit the software for security holes (none
2418       have been found so far).
2419
2420       Source code also allows you to port Nmap to new platforms, fix bugs,
2421       and add new features. You are highly encouraged to send your changes to
2422       <fyodor@insecure.org> for possible incorporation into the main
2423       distribution. By sending these changes to Fyodor or one of the
2424       Insecure.Org development mailing lists, it is assumed that you are
2425       offering Fyodor and Insecure.Com LLC the unlimited, non-exclusive right
2426       to reuse, modify, and relicense the code. Nmap will always be available
2427       Open Source, but this is important because the inability to relicense
2428       code has caused devastating problems for other Free Software projects
2429       (such as KDE and NASM). We also occasionally relicense the code to
2430       third parties as discussed above. If you wish to specify special
2431       license conditions of your contributions, just say so when you send
2432       them.
2433
2434   No Warranty
2435       This program is distributed in the hope that it will be useful, but
2436       WITHOUT ANY WARRANTY; without even the implied warranty of
2437       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2438       General Public License for more details at
2439       http://www.gnu.org/copyleft/gpl.html, or in the COPYING file included
2440       with Nmap.
2441
2442       It should also be noted that Nmap has occasionally been known to crash
2443       poorly written applications, TCP/IP stacks, and even operating systems.
2444       While this is extremely rare, it is important to keep in mind.  Nmap
2445       should never be run against mission critical systems unless you are
2446       prepared to suffer downtime. We acknowledge here that Nmap may crash
2447       your systems or networks and we disclaim all liability for any damage
2448       or problems Nmap could cause.
2449
2450   Inappropriate Usage
2451       Because of the slight risk of crashes and because a few black hats like
2452       to use Nmap for reconnaissance prior to attacking systems, there are
2453       administrators who become upset and may complain when their system is
2454       scanned. Thus, it is often advisable to request permission before doing
2455       even a light scan of a network.
2456
2457       Nmap should never be installed with special privileges (e.g. suid root)
2458       for security reasons.
2459
2460   Third-Party Software
2461       This product includes software developed by the [10]Apache Software
2462       Foundation. A modified version of the [11]Libpcap portable packet
2463       capture library is distributed along with nmap. The Windows version of
2464       Nmap utilized the libpcap-derived [12]WinPcap library instead. Regular
2465       expression support is provided by the [13]PCRE library, which is open
2466       source software, written by Philip Hazel. Certain raw networking
2467       functions use the [14]Libdnet networking library, which was written by
2468       Dug Song. A modified version is distributed with Nmap. Nmap can
2469       optionally link with the [15]OpenSSL cryptography toolkit for SSL
2470       version detection support. All of the third-party software described in
2471       this paragraph is freely redistributable under BSD-style software
2472       licenses.
2473
2474   US Export Control Classification
2475       US Export Control: Insecure.Com LLC believes that Nmap falls under US
2476       ECCN (export control classification number) 5D992. This category is
2477       called “Information Security software not controlled by 5D002”. The
2478       only restriction of this classification is AT (anti-terrorism), which
2479       applies to almost all goods and denies export to a handful of rogue
2480       nations such as Iran and North Korea. Thus exporting Nmap does not
2481       require any special license, permit, or other governmental
2482       authorization.
2483

REFERENCES

2485        1. RFC 1122
2486           http://www.rfc-editor.org/rfc/rfc1122.txt
2487
2488        2. RFC 792
2489           http://www.rfc-editor.org/rfc/rfc792.txt
2490
2491        3. UDP
2492           http://www.rfc-editor.org/rfc/rfc768.txt
2493
2494        4. TCP RFC
2495           http://www.rfc-editor.org/rfc/rfc793.txt
2496
2497        5. RFC 959
2498           http://www.rfc-editor.org/rfc/rfc959.txt
2499
2500        6. IP protocol
2501           http://www.ietf.org/rfc/rfc0791.txt
2502
2503        7. Nmap::Scanner
2504           http://sourceforge.net/projects/nmap-scanner/
2505
2506        8. Nmap::Parser
2507           http://www.nmapparser.com
2508
2509        9. Creative Commons Attribution License
2510           http://creativecommons.org/licenses/by/2.5/
2511
2512       10. Apache Software Foundation
2513           http://www.apache.org
2514
2515       11. Libpcap portable packet capture library
2516           http://www.tcpdump.org
2517
2518       12. WinPcap library
2519           http://www.winpcap.org
2520
2521       13. PCRE library
2522           http://www.pcre.org
2523
2524       14. Libdnet
2525           http://libdnet.sourceforge.net
2526
2527       15. OpenSSL cryptography toolkit
2528           http://www.openssl.org
2529
2530
2531
2532                                  12/07/2006                           NMAP(1)
Impressum