1NMAP(1) Nmap Reference Guide NMAP(1)
2
3
4
6 nmap - Network exploration tool and security / port scanner
7
9 nmap [Scan Type...] [Options] {target specification}
10
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
27 port number and protocol, service name, and state. The state is either
28 open, filtered, closed, or unfiltered. Open. means that an
29 application on the target machine is listening for connections/packets
30 on that port. Filtered. means that a firewall, filter, or other
31 network obstacle is blocking the port so that Nmap cannot tell whether
32 it is open or closed. Closed. ports have no application listening on
33 them, though they could open up at any time. Ports are classified as
34 unfiltered. when they are responsive to Nmap´s probes, but Nmap cannot
35 determine whether they are open or closed. Nmap reports the state
36 combinations open|filtered. and closed|filtered. when it cannot
37 determine which of the two states describe a port. The port table may
38 also include software version details when version detection has been
39 requested. When an IP protocol scan is requested (-sO), Nmap provides
40 information on 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 1. The only Nmap arguments used
47 in this example are -A, to enable OS and version detection, script
48 scanning, and traceroute; -T4 for faster execution; and then the two
49 target hostnames.
50
51 Example 1. A representative Nmap scan
52
53 # nmap -A -T4 scanme.nmap.org
54
55 Nmap scan report for scanme.nmap.org (64.13.134.52)
56 Host is up (0.045s latency).
57 Not shown: 993 filtered ports
58 PORT STATE SERVICE VERSION
59 22/tcp open ssh OpenSSH 4.3 (protocol 2.0)
60 | ssh-hostkey: 1024 60:ac:4d:51:b1:cd:85:09:12:16:92:76:1d:5d:27:6e (DSA)
61 |_2048 2c:22:75:60:4b:c3:3b:18:a2:97:2c:96:7e:28:dc:dd (RSA)
62 25/tcp closed smtp
63 53/tcp open domain
64 70/tcp closed gopher
65 80/tcp open http Apache httpd 2.2.3 ((CentOS))
66 |_html-title: Go ahead and ScanMe!
67 | http-methods: Potentially risky methods: TRACE
68 |_See http://nmap.org/nsedoc/scripts/http-methods.html
69 113/tcp closed auth
70 31337/tcp closed Elite
71 Device type: general purpose
72 Running: Linux 2.6.X
73 OS details: Linux 2.6.13 - 2.6.31, Linux 2.6.18
74 Network Distance: 13 hops
75
76 TRACEROUTE (using port 80/tcp)
77 HOP RTT ADDRESS
78 [Cut first 10 hops for brevity]
79 11 80.33 ms layer42.car2.sanjose2.level3.net (4.59.4.78)
80 12 137.52 ms xe6-2.core1.svk.layer42.net (69.36.239.221)
81 13 44.15 ms scanme.nmap.org (64.13.134.52)
82
83 Nmap done: 1 IP address (1 host up) scanned in 22.19 seconds
84
85 The newest version of Nmap can be obtained from http://nmap.org. The
86 newest version of this man page is available at
87 http://nmap.org/book/man.html. It is also included as a chapter of
88 Nmap Network Scanning: The Official Nmap Project Guide to Network
89 Discovery and Security Scanning (see http://nmap.org/book/).
90
92 This options summary is printed when Nmap is run with no arguments, and
93 the latest version is always available at
94 http://nmap.org/data/nmap.usage.txt. It helps people remember the most
95 common options, but is no substitute for the in-depth documentation in
96 the rest of this manual. Some obscure options aren´t even included
97 here.
98
99 Nmap 5.51 ( http://nmap.org )
100 Usage: nmap [Scan Type(s)] [Options] {target specification}
101 TARGET SPECIFICATION:
102 Can pass hostnames, IP addresses, networks, etc.
103 Ex: scanme.nmap.org, 192.168.0.1; 10.0.0-255.1-254
104 -iL <inputfilename>: Input from list of hosts/networks
105 -iR <num hosts>: Choose random targets
106 --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
107 --excludefile <exclude_file>: Exclude list from file
108 HOST DISCOVERY:
109 -sL: List Scan - simply list targets to scan
110 -sn: Ping Scan - disable port scan
111 -Pn: Treat all hosts as online -- skip host discovery
112 -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
113 -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
114 -PO[protocol list]: IP Protocol Ping
115 -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
116 --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
117 --system-dns: Use OS´s DNS resolver
118 --traceroute: Trace hop path to each host
119 SCAN TECHNIQUES:
120 -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
121 -sU: UDP Scan
122 -sN/sF/sX: TCP Null, FIN, and Xmas scans
123 --scanflags <flags>: Customize TCP scan flags
124 -sI <zombie host[:probeport]>: Idle scan
125 -sY/sZ: SCTP INIT/COOKIE-ECHO scans
126 -sO: IP protocol scan
127 -b <FTP relay host>: FTP bounce scan
128 PORT SPECIFICATION AND SCAN ORDER:
129 -p <port ranges>: Only scan specified ports
130 Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
131 -F: Fast mode - Scan fewer ports than the default scan
132 -r: Scan ports consecutively - don´t randomize
133 --top-ports <number>: Scan <number> most common ports
134 --port-ratio <ratio>: Scan ports more common than <ratio>
135 SERVICE/VERSION DETECTION:
136 -sV: Probe open ports to determine service/version info
137 --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
138 --version-light: Limit to most likely probes (intensity 2)
139 --version-all: Try every single probe (intensity 9)
140 --version-trace: Show detailed version scan activity (for debugging)
141 SCRIPT SCAN:
142 -sC: equivalent to --script=default
143 --script=<Lua scripts>: <Lua scripts> is a comma separated list of
144 directories, script-files or script-categories
145 --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
146 --script-trace: Show all data sent and received
147 --script-updatedb: Update the script database.
148 OS DETECTION:
149 -O: Enable OS detection
150 --osscan-limit: Limit OS detection to promising targets
151 --osscan-guess: Guess OS more aggressively
152 TIMING AND PERFORMANCE:
153 Options which take <time> are in seconds, or append ´ms´ (milliseconds),
154 ´s´ (seconds), ´m´ (minutes), or ´h´ (hours) to the value (e.g. 30m).
155 -T<0-5>: Set timing template (higher is faster)
156 --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
157 --min-parallelism/max-parallelism <numprobes>: Probe parallelization
158 --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
159 probe round trip time.
160 --max-retries <tries>: Caps number of port scan probe retransmissions.
161 --host-timeout <time>: Give up on target after this long
162 --scan-delay/--max-scan-delay <time>: Adjust delay between probes
163 --min-rate <number>: Send packets no slower than <number> per second
164 --max-rate <number>: Send packets no faster than <number> per second
165 FIREWALL/IDS EVASION AND SPOOFING:
166 -f; --mtu <val>: fragment packets (optionally w/given MTU)
167 -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
168 -S <IP_Address>: Spoof source address
169 -e <iface>: Use specified interface
170 -g/--source-port <portnum>: Use given port number
171 --data-length <num>: Append random data to sent packets
172 --ip-options <options>: Send packets with specified ip options
173 --ttl <val>: Set IP time-to-live field
174 --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
175 --badsum: Send packets with a bogus TCP/UDP/SCTP checksum
176 OUTPUT:
177 -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
178 and Grepable format, respectively, to the given filename.
179 -oA <basename>: Output in the three major formats at once
180 -v: Increase verbosity level (use -vv or more for greater effect)
181 -d: Increase debugging level (use -dd or more for greater effect)
182 --reason: Display the reason a port is in a particular state
183 --open: Only show open (or possibly open) ports
184 --packet-trace: Show all packets sent and received
185 --iflist: Print host interfaces and routes (for debugging)
186 --log-errors: Log errors/warnings to the normal-format output file
187 --append-output: Append to rather than clobber specified output files
188 --resume <filename>: Resume an aborted scan
189 --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
190 --webxml: Reference stylesheet from Nmap.Org for more portable XML
191 --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
192 MISC:
193 -6: Enable IPv6 scanning
194 -A: Enable OS detection, version detection, script scanning, and traceroute
195 --datadir <dirname>: Specify custom Nmap data file location
196 --send-eth/--send-ip: Send using raw ethernet frames or IP packets
197 --privileged: Assume that the user is fully privileged
198 --unprivileged: Assume the user lacks raw socket privileges
199 -V: Print version number
200 -h: Print this help summary page.
201 EXAMPLES:
202 nmap -v -A scanme.nmap.org
203 nmap -v -sn 192.168.0.0/16 10.0.0.0/8
204 nmap -v -iR 10000 -Pn -p 80
205 SEE THE MAN PAGE (http://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES
206
208 Everything on the Nmap command-line that isn´t an option (or option
209 argument) is treated as a target host specification. The simplest case
210 is to specify a target IP address or hostname for scanning.
211
212 Sometimes you wish to scan a whole network of adjacent hosts. For this,
213 Nmap supports CIDR-style. addressing. You can append /numbits to an
214 IPv4 address or hostname and Nmap will scan every IP address for which
215 the first numbits are the same as for the reference IP or hostname
216 given. For example, 192.168.10.0/24 would scan the 256 hosts between
217 192.168.10.0 (binary: 11000000 10101000 00001010 00000000) and
218 192.168.10.255 (binary: 11000000 10101000 00001010 11111111),
219 inclusive. 192.168.10.40/24 would scan exactly the same targets. Given
220 that the host scanme.nmap.org. is at the IP address 64.13.134.52, the
221 specification scanme.nmap.org/16 would scan the 65,536 IP addresses
222 between 64.13.0.0 and 64.13.255.255. The smallest allowed value is /0,
223 which targets the whole Internet. The largest value is /32, which scans
224 just the named host or IP address because all address bits are fixed.
225
226 CIDR notation is short but not always flexible enough. For example, you
227 might want to scan 192.168.0.0/16 but skip any IPs ending with .0 or
228 .255 because they may be used as subnet network and broadcast
229 addresses. Nmap supports this through octet range addressing. Rather
230 than specify a normal IP address, you can specify a comma-separated
231 list of numbers or ranges for each octet. For example,
232 192.168.0-255.1-254 will skip all addresses in the range that end in .0
233 or .255, and 192.168.3-5,7.1 will scan the four addresses 192.168.3.1,
234 192.168.4.1, 192.168.5.1, and 192.168.7.1. Either side of a range may
235 be omitted; the default values are 0 on the left and 255 on the right.
236 Using - by itself is the same as 0-255, but remember to use 0- in the
237 first octet so the target specification doesn´t look like a
238 command-line option. Ranges need not be limited to the final octets:
239 the specifier 0-255.0-255.13.37 will perform an Internet-wide scan for
240 all IP addresses ending in 13.37. This sort of broad sampling can be
241 useful for Internet surveys and research.
242
243 IPv6 addresses can only be specified by their fully qualified IPv6
244 address or hostname. CIDR and octet ranges aren´t supported for IPv6
245 because they are rarely useful.
246
247 Nmap accepts multiple host specifications on the command line, and they
248 don´t need to be the same type. The command nmap scanme.nmap.org
249 192.168.0.0/8 10.0.0,1,3-7.- does what you would expect.
250
251 While targets are usually specified on the command lines, the following
252 options are also available to control target selection:
253
254 -iL inputfilename (Input from list) .
255 Reads target specifications from inputfilename. Passing a huge list
256 of hosts is often awkward on the command line, yet it is a common
257 desire. For example, your DHCP server might export a list of 10,000
258 current leases that you wish to scan. Or maybe you want to scan all
259 IP addresses except for those to locate hosts using unauthorized
260 static IP addresses. Simply generate the list of hosts to scan and
261 pass that filename to Nmap as an argument to the -iL option.
262 Entries can be in any of the formats accepted by Nmap on the
263 command line (IP address, hostname, CIDR, IPv6, or octet ranges).
264 Each entry must be separated by one or more spaces, tabs, or
265 newlines. You can specify a hyphen (-) as the filename if you want
266 Nmap to read hosts from standard input rather than an actual file.
267
268 The input file may contain comments that start with # and extend to
269 the end of the line.
270
271 -iR num hosts (Choose random targets) .
272 For Internet-wide surveys and other research, you may want to
273 choose targets at random. The num hosts argument tells Nmap how
274 many IPs to generate. Undesirable IPs such as those in certain
275 private, multicast, or unallocated address ranges are automatically
276 skipped. The argument 0 can be specified for a never-ending scan.
277 Keep in mind that some network administrators bristle at
278 unauthorized scans of their networks and may complain. Use this
279 option at your own risk! If you find yourself really bored one
280 rainy afternoon, try the command nmap -Pn -sS -p 80 -iR 0 --open.
281 to locate random web servers for browsing.
282
283 --exclude host1[,host2[,...]] (Exclude hosts/networks) .
284 Specifies a comma-separated list of targets to be excluded from the
285 scan even if they are part of the overall network range you
286 specify. The list you pass in uses normal Nmap syntax, so it can
287 include hostnames, CIDR netblocks, octet ranges, etc. This can be
288 useful when the network you wish to scan includes untouchable
289 mission-critical servers, systems that are known to react adversely
290 to port scans, or subnets administered by other people.
291
292 --excludefile exclude_file (Exclude list from file) .
293 This offers the same functionality as the --exclude option, except
294 that the excluded targets are provided in a newline-, space-, or
295 tab-delimited exclude_file rather than on the command line.
296
297 The exclude file may contain comments that start with # and extend
298 to the end of the line.
299
301 One of the very first steps in any network reconnaissance mission is to
302 reduce a (sometimes huge) set of IP ranges into a list of active or
303 interesting hosts. Scanning every port of every single IP address is
304 slow and usually unnecessary. Of course what makes a host interesting
305 depends greatly on the scan purposes. Network administrators may only
306 be interested in hosts running a certain service, while security
307 auditors may care about every single device with an IP address. An
308 administrator may be comfortable using just an ICMP ping to locate
309 hosts on his internal network, while an external penetration tester may
310 use a diverse set of dozens of probes in an attempt to evade firewall
311 restrictions.
312
313 Because host discovery needs are so diverse, Nmap offers a wide variety
314 of options for customizing the techniques used. Host discovery is
315 sometimes called ping scan, but it goes well beyond the simple ICMP
316 echo request packets associated with the ubiquitous ping tool. Users
317 can skip the ping step entirely with a list scan (-sL) or by disabling
318 ping (-Pn), or engage the network with arbitrary combinations of
319 multi-port TCP SYN/ACK, UDP, SCTP INIT and ICMP probes. The goal of
320 these probes is to solicit responses which demonstrate that an IP
321 address is actually active (is being used by a host or network device).
322 On many networks, only a small percentage of IP addresses are active at
323 any given time. This is particularly common with private address space
324 such as 10.0.0.0/8. That network has 16 million IPs, but I have seen it
325 used by companies with less than a thousand machines. Host discovery
326 can find those machines in a sparsely allocated sea of IP addresses.
327
328 If no host discovery options are given, Nmap sends an ICMP echo
329 request, a TCP SYN packet to port 443, a TCP ACK packet to port 80, and
330 an ICMP timestamp request. These defaults are equivalent to the -PE
331 -PS443 -PA80 -PP options. An exception to this is that an ARP scan is
332 used for any targets which are on a local ethernet network. For
333 unprivileged Unix shell users, the default probes are a SYN packet to
334 ports 80 and 443 using the connect system call.. This host discovery
335 is often sufficient when scanning local networks, but a more
336 comprehensive set of discovery probes is recommended for security
337 auditing.
338
339 The -P* options (which select ping types) can be combined. You can
340 increase your odds of penetrating strict firewalls by sending many
341 probe types using different TCP ports/flags and ICMP codes. Also note
342 that ARP discovery (-PR). is done by default against targets on a
343 local ethernet network even if you specify other -P* options, because
344 it is almost always faster and more effective.
345
346 By default, Nmap does host discovery and then performs a port scan
347 against each host it determines is online. This is true even if you
348 specify non-default host discovery types such as UDP probes (-PU). Read
349 about the -sn option to learn how to perform only host discovery, or
350 use -Pn to skip host discovery and port scan all target hosts. The
351 following options control host discovery:
352
353 -sL (List Scan) .
354 The list scan is a degenerate form of host discovery that simply
355 lists each host of the network(s) specified, without sending any
356 packets to the target hosts. By default, Nmap still does
357 reverse-DNS resolution on the hosts to learn their names. It is
358 often surprising how much useful information simple hostnames give
359 out. For example, fw.chi is the name of one company´s Chicago
360 firewall. Nmap also reports the total number of IP addresses at
361 the end. The list scan is a good sanity check to ensure that you
362 have proper IP addresses for your targets. If the hosts sport
363 domain names you do not recognize, it is worth investigating
364 further to prevent scanning the wrong company´s network.
365
366 Since the idea is to simply print a list of target hosts, options
367 for higher level functionality such as port scanning, OS detection,
368 or ping scanning cannot be combined with this. If you wish to
369 disable ping scanning while still performing such higher level
370 functionality, read up on the -Pn (skip ping) option.
371
372 -sn (No port scan) .
373 This option tells Nmap not to do a port scan after host discovery,
374 and only print out the available hosts that responded to the scan.
375 This is often known as a “ping scan”, but you can also request that
376 traceroute and NSE host scripts be run. This is by default one step
377 more intrusive than the list scan, and can often be used for the
378 same purposes. It allows light reconnaissance of a target network
379 without attracting much attention. Knowing how many hosts are up is
380 more valuable to attackers than the list provided by list scan of
381 every single IP and host name.
382
383 Systems administrators often find this option valuable as well. It
384 can easily be used to count available machines on a network or
385 monitor server availability. This is often called a ping sweep, and
386 is more reliable than pinging the broadcast address because many
387 hosts do not reply to broadcast queries.
388
389 The default host discovery done with -sn consists of an ICMP echo
390 request, TCP SYN to port 443, TCP ACK to port 80, and an ICMP
391 timestamp request by default. When executed by an unprivileged
392 user, only SYN packets are sent (using a connect call) to ports 80
393 and 443 on the target. When a privileged user tries to scan targets
394 on a local ethernet network, ARP requests are used unless --send-ip
395 was specified. The -sn option can be combined with any of the
396 discovery probe types (the -P* options, excluding -Pn) for greater
397 flexibility. If any of those probe type and port number options are
398 used, the default probes are overridden. When strict firewalls are
399 in place between the source host running Nmap and the target
400 network, using those advanced techniques is recommended. Otherwise
401 hosts could be missed when the firewall drops probes or their
402 responses.
403
404 In previous releases of Nmap, -sn was known as -sP..
405
406 -Pn (No ping) .
407 This option skips the Nmap discovery stage altogether. Normally,
408 Nmap uses this stage to determine active machines for heavier
409 scanning. By default, Nmap only performs heavy probing such as port
410 scans, version detection, or OS detection against hosts that are
411 found to be up. Disabling host discovery with -Pn causes Nmap to
412 attempt the requested scanning functions against every target IP
413 address specified. So if a class B target address space (/16) is
414 specified on the command line, all 65,536 IP addresses are scanned.
415 Proper host discovery is skipped as with the list scan, but instead
416 of stopping and printing the target list, Nmap continues to perform
417 requested functions as if each target IP is active. To skip ping
418 scan and port scan, while still allowing NSE to run, use the two
419 options -Pn -sn together.
420
421 For machines on a local ethernet network, ARP scanning will still
422 be performed (unless --send-ip is specified) because Nmap needs MAC
423 addresses to further scan target hosts. In previous versions of
424 Nmap, -Pn was -P0. and -PN..
425
426 -PS port list (TCP SYN Ping) .
427 This option sends an empty TCP packet with the SYN flag set. The
428 default destination port is 80 (configurable at compile time by
429 changing DEFAULT_TCP_PROBE_PORT_SPEC. in nmap.h).. Alternate
430 ports can be specified as a parameter. The syntax is the same as
431 for the -p except that port type specifiers like T: are not
432 allowed. Examples are -PS22 and -PS22-25,80,113,1050,35000. Note
433 that there can be no space between -PS and the port list. If
434 multiple probes are specified they will be sent in parallel.
435
436 The SYN flag suggests to the remote system that you are attempting
437 to establish a connection. Normally the destination port will be
438 closed, and a RST (reset) packet sent back. If the port happens to
439 be open, the target will take the second step of a TCP
440 three-way-handshake. by responding with a SYN/ACK TCP packet. The
441 machine running Nmap then tears down the nascent connection by
442 responding with a RST rather than sending an ACK packet which would
443 complete the three-way-handshake and establish a full connection.
444 The RST packet is sent by the kernel of the machine running Nmap in
445 response to the unexpected SYN/ACK, not by Nmap itself.
446
447 Nmap does not care whether the port is open or closed. Either the
448 RST or SYN/ACK response discussed previously tell Nmap that the
449 host is available and responsive.
450
451 On Unix boxes, only the privileged user root. is generally able to
452 send and receive raw TCP packets.. For unprivileged users, a
453 workaround is automatically employed. whereby the connect system
454 call is initiated against each target port. This has the effect of
455 sending a SYN packet to the target host, in an attempt to establish
456 a connection. If connect returns with a quick success or an
457 ECONNREFUSED failure, the underlying TCP stack must have received a
458 SYN/ACK or RST and the host is marked available. If the connection
459 attempt is left hanging until a timeout is reached, the host is
460 marked as down. This workaround is also used for IPv6 connections,
461 as raw IPv6 packet building support is not yet available in Nmap..
462
463 -PA port list (TCP ACK Ping) .
464 The TCP ACK ping is quite similar to the just-discussed SYN ping.
465 The difference, as you could likely guess, is that the TCP ACK flag
466 is set instead of the SYN flag. Such an ACK packet purports to be
467 acknowledging data over an established TCP connection, but no such
468 connection exists. So remote hosts should always respond with a RST
469 packet, disclosing their existence in the process.
470
471 The -PA option uses the same default port as the SYN probe (80) and
472 can also take a list of destination ports in the same format. If an
473 unprivileged user tries this, or an IPv6 target is specified, the
474 connect workaround discussed previously is used. This workaround is
475 imperfect because connect is actually sending a SYN packet rather
476 than an ACK.
477
478 The reason for offering both SYN and ACK ping probes is to maximize
479 the chances of bypassing firewalls. Many administrators configure
480 routers and other simple firewalls to block incoming SYN packets
481 except for those destined for public services like the company web
482 site or mail server. This prevents other incoming connections to
483 the organization, while allowing users to make unobstructed
484 outgoing connections to the Internet. This non-stateful approach
485 takes up few resources on the firewall/router and is widely
486 supported by hardware and software filters. The Linux
487 Netfilter/iptables. firewall software offers the --syn convenience
488 option to implement this stateless approach. When stateless
489 firewall rules such as this are in place, SYN ping probes (-PS) are
490 likely to be blocked when sent to closed target ports. In such
491 cases, the ACK probe shines as it cuts right through these rules.
492
493 Another common type of firewall uses stateful rules that drop
494 unexpected packets. This feature was initially found mostly on
495 high-end firewalls, though it has become much more common over the
496 years. The Linux Netfilter/iptables system supports this through
497 the --state option, which categorizes packets based on connection
498 state. A SYN probe is more likely to work against such a system, as
499 unexpected ACK packets are generally recognized as bogus and
500 dropped. A solution to this quandary is to send both SYN and ACK
501 probes by specifying -PS and -PA.
502
503 -PU port list (UDP Ping) .
504 Another host discovery option is the UDP ping, which sends a UDP
505 packet to the given ports. For most ports, the packet will be
506 empty, though for a few a protocol-specific payload will be sent
507 that is more likely to get a response.. The payload database is
508 described at http://nmap.org/book/nmap-payloads.html.
509
510 The --data-length. option sends a fixed-length random payload for
511 all ports.
512
513 The port list takes the same format as with the previously
514 discussed -PS and -PA options. If no ports are specified, the
515 default is 40125.. This default can be configured at compile-time
516 by changing DEFAULT_UDP_PROBE_PORT_SPEC. in nmap.h.. A highly
517 uncommon port is used by default because sending to open ports is
518 often undesirable for this particular scan type.
519
520 Upon hitting a closed port on the target machine, the UDP probe
521 should elicit an ICMP port unreachable packet in return. This
522 signifies to Nmap that the machine is up and available. Many other
523 types of ICMP errors, such as host/network unreachables or TTL
524 exceeded are indicative of a down or unreachable host. A lack of
525 response is also interpreted this way. If an open port is reached,
526 most services simply ignore the empty packet and fail to return any
527 response. This is why the default probe port is 40125, which is
528 highly unlikely to be in use. A few services, such as the Character
529 Generator (chargen) protocol, will respond to an empty UDP packet,
530 and thus disclose to Nmap that the machine is available.
531
532 The primary advantage of this scan type is that it bypasses
533 firewalls and filters that only screen TCP. For example, I once
534 owned a Linksys BEFW11S4 wireless broadband router. The external
535 interface of this device filtered all TCP ports by default, but UDP
536 probes would still elicit port unreachable messages and thus give
537 away the device.
538
539 -PY port list (SCTP INIT Ping) .
540 This option sends an SCTP packet containing a minimal INIT chunk.
541 The default destination port is 80 (configurable at compile time by
542 changing DEFAULT_SCTP_PROBE_PORT_SPEC. in nmap.h). Alternate ports
543 can be specified as a parameter. The syntax is the same as for the
544 -p except that port type specifiers like S: are not allowed.
545 Examples are -PY22 and -PY22,80,179,5060. Note that there can be no
546 space between -PY and the port list. If multiple probes are
547 specified they will be sent in parallel.
548
549 The INIT chunk suggests to the remote system that you are
550 attempting to establish an association. Normally the destination
551 port will be closed, and an ABORT chunk will be sent back. If the
552 port happens to be open, the target will take the second step of an
553 SCTP four-way-handshake. by responding with an INIT-ACK chunk. If
554 the machine running Nmap has a functional SCTP stack, then it tears
555 down the nascent association by responding with an ABORT chunk
556 rather than sending a COOKIE-ECHO chunk which would be the next
557 step in the four-way-handshake. The ABORT packet is sent by the
558 kernel of the machine running Nmap in response to the unexpected
559 INIT-ACK, not by Nmap itself.
560
561 Nmap does not care whether the port is open or closed. Either the
562 ABORT or INIT-ACK response discussed previously tell Nmap that the
563 host is available and responsive.
564
565 On Unix boxes, only the privileged user root. is generally able to
566 send and receive raw SCTP packets.. Using SCTP INIT Pings is
567 currently not possible for unprivileged users.. The same
568 limitation applies to IPv6, which is currently not supported for
569 SCTP INIT Ping..
570
571 -PE; -PP; -PM (ICMP Ping Types) .
572 In addition to the unusual TCP, UDP and SCTP host discovery types
573 discussed previously, Nmap can send the standard packets sent by
574 the ubiquitous ping program. Nmap sends an ICMP type 8 (echo
575 request) packet to the target IP addresses, expecting a type 0
576 (echo reply) in return from available hosts.. Unfortunately for
577 network explorers, many hosts and firewalls now block these
578 packets, rather than responding as required by RFC 1122[2].. For
579 this reason, ICMP-only scans are rarely reliable enough against
580 unknown targets over the Internet. But for system administrators
581 monitoring an internal network, they can be a practical and
582 efficient approach. Use the -PE option to enable this echo request
583 behavior.
584
585 While echo request is the standard ICMP ping query, Nmap does not
586 stop there. The ICMP standards (RFC 792[3]. and RFC 950[4]. “a
587 host SHOULD NOT implement these messages”. Timestamp and address
588 mask queries can be sent with the -PP and -PM options,
589 respectively. A timestamp reply (ICMP code 14) or address mask
590 reply (code 18) discloses that the host is available. These two
591 queries can be valuable when administrators specifically block echo
592 request packets while forgetting that other ICMP queries can be
593 used for the same purpose.
594
595 -PO protocol list (IP Protocol Ping) .
596 One of the newer host discovery options is the IP protocol ping,
597 which sends IP packets with the specified protocol number set in
598 their IP header. The protocol list takes the same format as do port
599 lists in the previously discussed TCP, UDP and SCTP host discovery
600 options. If no protocols are specified, the default is to send
601 multiple IP packets for ICMP (protocol 1), IGMP (protocol 2), and
602 IP-in-IP (protocol 4). The default protocols can be configured at
603 compile-time by changing DEFAULT_PROTO_PROBE_PORT_SPEC. in nmap.h.
604 Note that for the ICMP, IGMP, TCP (protocol 6), UDP (protocol 17)
605 and SCTP (protocol 132), the packets are sent with the proper
606 protocol headers. while other protocols are sent with no
607 additional data beyond the IP header (unless the --data-length.
608 option is specified).
609
610 This host discovery method looks for either responses using the
611 same protocol as a probe, or ICMP protocol unreachable messages
612 which signify that the given protocol isn´t supported on the
613 destination host. Either type of response signifies that the target
614 host is alive.
615
616 -PR (ARP Ping) .
617 One of the most common Nmap usage scenarios is to scan an ethernet
618 LAN. On most LANs, especially those using private address ranges
619 specified by RFC 1918[5], the vast majority of IP addresses are
620 unused at any given time. When Nmap tries to send a raw IP packet
621 such as an ICMP echo request, the operating system must determine
622 the destination hardware (ARP) address corresponding to the target
623 IP so that it can properly address the ethernet frame. This is
624 often slow and problematic, since operating systems weren´t written
625 with the expectation that they would need to do millions of ARP
626 requests against unavailable hosts in a short time period.
627
628 ARP scan puts Nmap and its optimized algorithms in charge of ARP
629 requests. And if it gets a response back, Nmap doesn´t even need to
630 worry about the IP-based ping packets since it already knows the
631 host is up. This makes ARP scan much faster and more reliable than
632 IP-based scans. So it is done by default when scanning ethernet
633 hosts that Nmap detects are on a local ethernet network. Even if
634 different ping types (such as -PE or -PS) are specified, Nmap uses
635 ARP instead for any of the targets which are on the same LAN. If
636 you absolutely don´t want to do an ARP scan, specify --send-ip.
637
638 --traceroute (Trace path to host) .
639 Traceroutes are performed post-scan using information from the scan
640 results to determine the port and protocol most likely to reach the
641 target. It works with all scan types except connect scans (-sT) and
642 idle scans (-sI). All traces use Nmap´s dynamic timing model and
643 are performed in parallel.
644
645 Traceroute works by sending packets with a low TTL (time-to-live)
646 in an attempt to elicit ICMP Time Exceeded messages from
647 intermediate hops between the scanner and the target host. Standard
648 traceroute implementations start with a TTL of 1 and increment the
649 TTL until the destination host is reached. Nmap´s traceroute starts
650 with a high TTL and then decrements the TTL until it reaches zero.
651 Doing it backwards lets Nmap employ clever caching algorithms to
652 speed up traces over multiple hosts. On average Nmap sends 5–10
653 fewer packets per host, depending on network conditions. If a
654 single subnet is being scanned (i.e. 192.168.0.0/24) Nmap may only
655 have to send two packets to most hosts.
656
657 -n (No DNS resolution) .
658 Tells Nmap to never do reverse DNS resolution on the active IP
659 addresses it finds. Since DNS can be slow even with Nmap´s built-in
660 parallel stub resolver, this option can slash scanning times.
661
662 -R (DNS resolution for all targets) .
663 Tells Nmap to always do reverse DNS resolution on the target IP
664 addresses. Normally reverse DNS is only performed against
665 responsive (online) hosts.
666
667 --system-dns (Use system DNS resolver) .
668 By default, Nmap resolves IP addresses by sending queries directly
669 to the name servers configured on your host and then listening for
670 responses. Many requests (often dozens) are performed in parallel
671 to improve performance. Specify this option to use your system
672 resolver instead (one IP at a time via the getnameinfo call). This
673 is slower and rarely useful unless you find a bug in the Nmap
674 parallel resolver (please let us know if you do). The system
675 resolver is always used for IPv6 scans.
676
677 --dns-servers server1[,server2[,...]] (Servers to use for reverse DNS
678 queries) .
679 By default, Nmap determines your DNS servers (for rDNS resolution)
680 from your resolv.conf file (Unix) or the Registry (Win32).
681 Alternatively, you may use this option to specify alternate
682 servers. This option is not honored if you are using --system-dns
683 or an IPv6 scan. Using multiple DNS servers is often faster,
684 especially if you choose authoritative servers for your target IP
685 space. This option can also improve stealth, as your requests can
686 be bounced off just about any recursive DNS server on the Internet.
687
688 This option also comes in handy when scanning private networks.
689 Sometimes only a few name servers provide proper rDNS information,
690 and you may not even know where they are. You can scan the network
691 for port 53 (perhaps with version detection), then try Nmap list
692 scans (-sL) specifying each name server one at a time with
693 --dns-servers until you find one which works.
694
696 While Nmap has grown in functionality over the years, it began as an
697 efficient port scanner, and that remains its core function. The simple
698 command nmap target scans 1,000 TCP ports on the host target. While
699 many port scanners have traditionally lumped all ports into the open or
700 closed states, Nmap is much more granular. It divides ports into six
701 states: open, closed, filtered, unfiltered, open|filtered, or
702 closed|filtered.
703
704 These states are not intrinsic properties of the port itself, but
705 describe how Nmap sees them. For example, an Nmap scan from the same
706 network as the target may show port 135/tcp as open, while a scan at
707 the same time with the same options from across the Internet might show
708 that port as filtered.
709
710 The six port states recognized by Nmap
711
712 An application is actively accepting TCP connections, UDP datagrams
713 or SCTP associations on this port. Finding these is often the
714 primary goal of port scanning. Security-minded people know that
715 each open port is an avenue for attack. Attackers and pen-testers
716 want to exploit the open ports, while administrators try to close
717 or protect them with firewalls without thwarting legitimate users.
718 Open ports are also interesting for non-security scans because they
719 show services available for use on the network.
720
721 A closed port is accessible (it receives and responds to Nmap probe
722 packets), but there is no application listening on it. They can be
723 helpful in showing that a host is up on an IP address (host
724 discovery, or ping scanning), and as part of OS detection. Because
725 closed ports are reachable, it may be worth scanning later in case
726 some open up. Administrators may want to consider blocking such
727 ports with a firewall. Then they would appear in the filtered
728 state, discussed next.
729
730 Nmap cannot determine whether the port is open because packet
731 filtering prevents its probes from reaching the port. The filtering
732 could be from a dedicated firewall device, router rules, or
733 host-based firewall software. These ports frustrate attackers
734 because they provide so little information. Sometimes they respond
735 with ICMP error messages such as type 3 code 13 (destination
736 unreachable: communication administratively prohibited), but
737 filters that simply drop probes without responding are far more
738 common. This forces Nmap to retry several times just in case the
739 probe was dropped due to network congestion rather than filtering.
740 This slows down the scan dramatically.
741
742 The unfiltered state means that a port is accessible, but Nmap is
743 unable to determine whether it is open or closed. Only the ACK
744 scan, which is used to map firewall rulesets, classifies ports into
745 this state. Scanning unfiltered ports with other scan types such as
746 Window scan, SYN scan, or FIN scan, may help resolve whether the
747 port is open.
748
749 Nmap places ports in this state when it is unable to determine
750 whether a port is open or filtered. This occurs for scan types in
751 which open ports give no response. The lack of response could also
752 mean that a packet filter dropped the probe or any response it
753 elicited. So Nmap does not know for sure whether the port is open
754 or being filtered. The UDP, IP protocol, FIN, NULL, and Xmas scans
755 classify ports this way.
756
757 This state is used when Nmap is unable to determine whether a port
758 is closed or filtered. It is only used for the IP ID idle scan.
759
761 As a novice performing automotive repair, I can struggle for hours
762 trying to fit my rudimentary tools (hammer, duct tape, wrench, etc.) to
763 the task at hand. When I fail miserably and tow my jalopy to a real
764 mechanic, he invariably fishes around in a huge tool chest until
765 pulling out the perfect gizmo which makes the job seem effortless. The
766 art of port scanning is similar. Experts understand the dozens of scan
767 techniques and choose the appropriate one (or combination) for a given
768 task. Inexperienced users and script kiddies,. on the other hand, try
769 to solve every problem with the default SYN scan. Since Nmap is free,
770 the only barrier to port scanning mastery is knowledge. That certainly
771 beats the automotive world, where it may take great skill to determine
772 that you need a strut spring compressor, then you still have to pay
773 thousands of dollars for it.
774
775 Most of the scan types are only available to privileged users.. This
776 is because they send and receive raw packets,. which requires root
777 access on Unix systems. Using an administrator account on Windows is
778 recommended, though Nmap sometimes works for unprivileged users on that
779 platform when WinPcap has already been loaded into the OS. Requiring
780 root privileges was a serious limitation when Nmap was released in
781 1997, as many users only had access to shared shell accounts. Now, the
782 world is different. Computers are cheaper, far more people have
783 always-on direct Internet access, and desktop Unix systems (including
784 Linux and Mac OS X) are prevalent. A Windows version of Nmap is now
785 available, allowing it to run on even more desktops. For all these
786 reasons, users have less need to run Nmap from limited shared shell
787 accounts. This is fortunate, as the privileged options make Nmap far
788 more powerful and flexible.
789
790 While Nmap attempts to produce accurate results, keep in mind that all
791 of its insights are based on packets returned by the target machines
792 (or firewalls in front of them). Such hosts may be untrustworthy and
793 send responses intended to confuse or mislead Nmap. Much more common
794 are non-RFC-compliant hosts that do not respond as they should to Nmap
795 probes. FIN, NULL, and Xmas scans are particularly susceptible to this
796 problem. Such issues are specific to certain scan types and so are
797 discussed in the individual scan type entries.
798
799 This section documents the dozen or so port scan techniques supported
800 by Nmap. Only one method may be used at a time, except that UDP scan
801 (-sU) and any one of the SCTP scan types (-sY, -sZ) may be combined
802 with any one of the TCP scan types. As a memory aid, port scan type
803 options are of the form -sC, where C is a prominent character in the
804 scan name, usually the first. The one exception to this is the
805 deprecated FTP bounce scan (-b). By default, Nmap performs a SYN Scan,
806 though it substitutes a connect scan if the user does not have proper
807 privileges to send raw packets (requires root access on Unix) or if
808 IPv6 targets were specified. Of the scans listed in this section,
809 unprivileged users can only execute connect and FTP bounce scans.
810
811 -sS (TCP SYN scan) .
812 SYN scan is the default and most popular scan option for good
813 reasons. It can be performed quickly, scanning thousands of ports
814 per second on a fast network not hampered by restrictive firewalls.
815 It is also relatively unobtrusive and stealthy since it never
816 completes TCP connections. SYN scan works against any compliant TCP
817 stack rather than depending on idiosyncrasies of specific platforms
818 as Nmap´s FIN/NULL/Xmas, Maimon and idle scans do. It also allows
819 clear, reliable differentiation between the open, closed, and
820 filtered states.
821
822 This technique is often referred to as half-open scanning, because
823 you don´t open a full TCP connection. You send a SYN packet, as if
824 you are going to open a real connection and then wait for a
825 response. A SYN/ACK indicates the port is listening (open), while a
826 RST (reset) is indicative of a non-listener. If no response is
827 received after several retransmissions, the port is marked as
828 filtered. The port is also marked filtered if an ICMP unreachable
829 error (type 3, code 1, 2, 3, 9, 10, or 13) is received. The port is
830 also considered open if a SYN packet (without the ACK flag) is
831 received in response. This can be due to an extremely rare TCP
832 feature known as a simultaneous open or split handshake connection
833 (see http://nmap.org/misc/split-handshake.pdf).
834
835 -sT (TCP connect scan) .
836 TCP connect scan is the default TCP scan type when SYN scan is not
837 an option. This is the case when a user does not have raw packet
838 privileges or is scanning IPv6 networks. Instead of writing raw
839 packets as most other scan types do, Nmap asks the underlying
840 operating system to establish a connection with the target machine
841 and port by issuing the connect system call. This is the same
842 high-level system call that web browsers, P2P clients, and most
843 other network-enabled applications use to establish a connection.
844 It is part of a programming interface known as the Berkeley Sockets
845 API. Rather than read raw packet responses off the wire, Nmap uses
846 this API to obtain status information on each connection attempt.
847
848 When SYN scan is available, it is usually a better choice. Nmap has
849 less control over the high level connect call than with raw
850 packets, making it less efficient. The system call completes
851 connections to open target ports rather than performing the
852 half-open reset that SYN scan does. Not only does this take longer
853 and require more packets to obtain the same information, but target
854 machines are more likely to log the connection. A decent IDS will
855 catch either, but most machines have no such alarm system. Many
856 services on your average Unix system will add a note to syslog, and
857 sometimes a cryptic error message, when Nmap connects and then
858 closes the connection without sending data. Truly pathetic services
859 crash when this happens, though that is uncommon. An administrator
860 who sees a bunch of connection attempts in her logs from a single
861 system should know that she has been connect scanned.
862
863 -sU (UDP scans) .
864 While most popular services on the Internet run over the TCP
865 protocol, UDP[6] services are widely deployed. DNS, SNMP, and DHCP
866 (registered ports 53, 161/162, and 67/68) are three of the most
867 common. Because UDP scanning is generally slower and more difficult
868 than TCP, some security auditors ignore these ports. This is a
869 mistake, as exploitable UDP services are quite common and attackers
870 certainly don´t ignore the whole protocol. Fortunately, Nmap can
871 help inventory UDP ports.
872
873 UDP scan is activated with the -sU option. It can be combined with
874 a TCP scan type such as SYN scan (-sS) to check both protocols
875 during the same run.
876
877 UDP scan works by sending a UDP packet to every targeted port. For
878 some common ports such as 53 and 161, a protocol-specific payload
879 is sent, but for most ports the packet is empty.. The
880 --data-length option can be used to send a fixed-length random
881 payload to every port. If an ICMP port unreachable error (type 3,
882 code 3) is returned, the port is closed. Other ICMP unreachable
883 errors (type 3, codes 1, 2, 9, 10, or 13) mark the port as
884 filtered. Occasionally, a service will respond with a UDP packet,
885 proving that it is open. If no response is received after
886 retransmissions, the port is classified as open|filtered. This
887 means that the port could be open, or perhaps packet filters are
888 blocking the communication. Version detection (-sV) can be used to
889 help differentiate the truly open ports from the filtered ones.
890
891 A big challenge with UDP scanning is doing it quickly. Open and
892 filtered ports rarely send any response, leaving Nmap to time out
893 and then conduct retransmissions just in case the probe or response
894 were lost. Closed ports are often an even bigger problem. They
895 usually send back an ICMP port unreachable error. But unlike the
896 RST packets sent by closed TCP ports in response to a SYN or
897 connect scan, many hosts rate limit. ICMP port unreachable
898 messages by default. Linux and Solaris are particularly strict
899 about this. For example, the Linux 2.4.20 kernel limits destination
900 unreachable messages to one per second (in net/ipv4/icmp.c).
901
902 Nmap detects rate limiting and slows down accordingly to avoid
903 flooding the network with useless packets that the target machine
904 will drop. Unfortunately, a Linux-style limit of one packet per
905 second makes a 65,536-port scan take more than 18 hours. Ideas for
906 speeding your UDP scans up include scanning more hosts in parallel,
907 doing a quick scan of just the popular ports first, scanning from
908 behind the firewall, and using --host-timeout to skip slow hosts.
909
910 -sY (SCTP INIT scan) .
911
912 SCTP[7] is a relatively new alternative to the TCP and UDP
913 protocols, combining most characteristics of TCP and UDP, and also
914 adding new features like multi-homing and multi-streaming. It is
915 mostly being used for SS7/SIGTRAN related services but has the
916 potential to be used for other applications as well. SCTP INIT scan
917 is the SCTP equivalent of a TCP SYN scan. It can be performed
918 quickly, scanning thousands of ports per second on a fast network
919 not hampered by restrictive firewalls. Like SYN scan, INIT scan is
920 relatively unobtrusive and stealthy, since it never completes SCTP
921 associations. It also allows clear, reliable differentiation
922 between the open, closed, and filtered states.
923
924 This technique is often referred to as half-open scanning, because
925 you don´t open a full SCTP association. You send an INIT chunk, as
926 if you are going to open a real association and then wait for a
927 response. An INIT-ACK chunk indicates the port is listening (open),
928 while an ABORT chunk is indicative of a non-listener. If no
929 response is received after several retransmissions, the port is
930 marked as filtered. The port is also marked filtered if an ICMP
931 unreachable error (type 3, code 1, 2, 3, 9, 10, or 13) is received.
932
933 -sN; -sF; -sX (TCP NULL, FIN, and Xmas scans) .
934 These three scan types (even more are possible with the --scanflags
935 option described in the next section) exploit a subtle loophole in
936 the TCP RFC[8] to differentiate between open and closed ports. Page
937 65 of RFC 793 says that “if the [destination] port state is CLOSED
938 .... an incoming segment not containing a RST causes a RST to be
939 sent in response.” Then the next page discusses packets sent to
940 open ports without the SYN, RST, or ACK bits set, stating that:
941 “you are unlikely to get here, but if you do, drop the segment, and
942 return.”
943
944 When scanning systems compliant with this RFC text, any packet not
945 containing SYN, RST, or ACK bits will result in a returned RST if
946 the port is closed and no response at all if the port is open. As
947 long as none of those three bits are included, any combination of
948 the other three (FIN, PSH, and URG) are OK. Nmap exploits this with
949 three scan types:
950
951 Null scan (-sN)
952 Does not set any bits (TCP flag header is 0)
953
954 FIN scan (-sF)
955 Sets just the TCP FIN bit.
956
957 Xmas scan (-sX)
958 Sets the FIN, PSH, and URG flags, lighting the packet up like a
959 Christmas tree.
960
961 These three scan types are exactly the same in behavior except for
962 the TCP flags set in probe packets. If a RST packet is received,
963 the port is considered closed, while no response means it is
964 open|filtered. The port is marked filtered if an ICMP unreachable
965 error (type 3, code 1, 2, 3, 9, 10, or 13) is received.
966
967 The key advantage to these scan types is that they can sneak
968 through certain non-stateful firewalls and packet filtering
969 routers. Another advantage is that these scan types are a little
970 more stealthy than even a SYN scan. Don´t count on this though—most
971 modern IDS products can be configured to detect them. The big
972 downside is that not all systems follow RFC 793 to the letter. A
973 number of systems send RST responses to the probes regardless of
974 whether the port is open or not. This causes all of the ports to be
975 labeled closed. Major operating systems that do this are Microsoft
976 Windows, many Cisco devices, BSDI, and IBM OS/400. This scan does
977 work against most Unix-based systems though. Another downside of
978 these scans is that they can´t distinguish open ports from certain
979 filtered ones, leaving you with the response open|filtered.
980
981 -sA (TCP ACK scan) .
982 This scan is different than the others discussed so far in that it
983 never determines open (or even open|filtered) ports. It is used to
984 map out firewall rulesets, determining whether they are stateful or
985 not and which ports are filtered.
986
987 The ACK scan probe packet has only the ACK flag set (unless you use
988 --scanflags). When scanning unfiltered systems, open and closed
989 ports will both return a RST packet. Nmap then labels them as
990 unfiltered, meaning that they are reachable by the ACK packet, but
991 whether they are open or closed is undetermined. Ports that don´t
992 respond, or send certain ICMP error messages back (type 3, code 1,
993 2, 3, 9, 10, or 13), are labeled filtered.
994
995 -sW (TCP Window scan) .
996 Window scan is exactly the same as ACK scan except that it exploits
997 an implementation detail of certain systems to differentiate open
998 ports from closed ones, rather than always printing unfiltered when
999 a RST is returned. It does this by examining the TCP Window field
1000 of the RST packets returned. On some systems, open ports use a
1001 positive window size (even for RST packets) while closed ones have
1002 a zero window. So instead of always listing a port as unfiltered
1003 when it receives a RST back, Window scan lists the port as open or
1004 closed if the TCP Window value in that reset is positive or zero,
1005 respectively.
1006
1007 This scan relies on an implementation detail of a minority of
1008 systems out on the Internet, so you can´t always trust it. Systems
1009 that don´t support it will usually return all ports closed. Of
1010 course, it is possible that the machine really has no open ports.
1011 If most scanned ports are closed but a few common port numbers
1012 (such as 22, 25, 53) are filtered, the system is most likely
1013 susceptible. Occasionally, systems will even show the exact
1014 opposite behavior. If your scan shows 1,000 open ports and three
1015 closed or filtered ports, then those three may very well be the
1016 truly open ones.
1017
1018 -sM (TCP Maimon scan) .
1019 The Maimon scan is named after its discoverer, Uriel Maimon.. He
1020 described the technique in Phrack Magazine issue #49 (November
1021 1996).. Nmap, which included this technique, was released two
1022 issues later. This technique is exactly the same as NULL, FIN, and
1023 Xmas scans, except that the probe is FIN/ACK. According to RFC
1024 793[8] (TCP), a RST packet should be generated in response to such
1025 a probe whether the port is open or closed. However, Uriel noticed
1026 that many BSD-derived systems simply drop the packet if the port is
1027 open.
1028
1029 --scanflags (Custom TCP scan) .
1030 Truly advanced Nmap users need not limit themselves to the canned
1031 scan types offered. The --scanflags option allows you to design
1032 your own scan by specifying arbitrary TCP flags.. Let your
1033 creative juices flow, while evading intrusion detection systems.
1034 whose vendors simply paged through the Nmap man page adding
1035 specific rules!
1036
1037 The --scanflags argument can be a numerical flag value such as 9
1038 (PSH and FIN), but using symbolic names is easier. Just mash
1039 together any combination of URG, ACK, PSH, RST, SYN, and FIN. For
1040 example, --scanflags URGACKPSHRSTSYNFIN sets everything, though
1041 it´s not very useful for scanning. The order these are specified in
1042 is irrelevant.
1043
1044 In addition to specifying the desired flags, you can specify a TCP
1045 scan type (such as -sA or -sF). That base type tells Nmap how to
1046 interpret responses. For example, a SYN scan considers no-response
1047 to indicate a filtered port, while a FIN scan treats the same as
1048 open|filtered. Nmap will behave the same way it does for the base
1049 scan type, except that it will use the TCP flags you specify
1050 instead. If you don´t specify a base type, SYN scan is used.
1051
1052 -sZ (SCTP COOKIE ECHO scan) .
1053 SCTP COOKIE ECHO scan is a more advanced SCTP scan. It takes
1054 advantage of the fact that SCTP implementations should silently
1055 drop packets containing COOKIE ECHO chunks on open ports, but send
1056 an ABORT if the port is closed. The advantage of this scan type is
1057 that it is not as obvious a port scan than an INIT scan. Also,
1058 there may be non-stateful firewall rulesets blocking INIT chunks,
1059 but not COOKIE ECHO chunks. Don´t be fooled into thinking that this
1060 will make a port scan invisible; a good IDS will be able to detect
1061 SCTP COOKIE ECHO scans too. The downside is that SCTP COOKIE ECHO
1062 scans cannot differentiate between open and filtered ports, leaving
1063 you with the state open|filtered in both cases.
1064
1065 -sI zombie host[:probeport] (idle scan) .
1066 This advanced scan method allows for a truly blind TCP port scan of
1067 the target (meaning no packets are sent to the target from your
1068 real IP address). Instead, a unique side-channel attack exploits
1069 predictable IP fragmentation ID sequence generation on the zombie
1070 host to glean information about the open ports on the target. IDS
1071 systems will display the scan as coming from the zombie machine you
1072 specify (which must be up and meet certain criteria). This
1073 fascinating scan type is too complex to fully describe in this
1074 reference guide, so I wrote and posted an informal paper with full
1075 details at http://nmap.org/book/idlescan.html.
1076
1077 Besides being extraordinarily stealthy (due to its blind nature),
1078 this scan type permits mapping out IP-based trust relationships
1079 between machines. The port listing shows open ports from the
1080 perspective of the zombie host. So you can try scanning a target
1081 using various zombies that you think might be trusted. (via
1082 router/packet filter rules).
1083
1084 You can add a colon followed by a port number to the zombie host if
1085 you wish to probe a particular port on the zombie for IP ID
1086 changes. Otherwise Nmap will use the port it uses by default for
1087 TCP pings (80).
1088
1089 -sO (IP protocol scan) .
1090 IP protocol scan allows you to determine which IP protocols (TCP,
1091 ICMP, IGMP, etc.) are supported by target machines. This isn´t
1092 technically a port scan, since it cycles through IP protocol
1093 numbers rather than TCP or UDP port numbers. Yet it still uses the
1094 -p option to select scanned protocol numbers, reports its results
1095 within the normal port table format, and even uses the same
1096 underlying scan engine as the true port scanning methods. So it is
1097 close enough to a port scan that it belongs here.
1098
1099 Besides being useful in its own right, protocol scan demonstrates
1100 the power of open-source software. While the fundamental idea is
1101 pretty simple, I had not thought to add it nor received any
1102 requests for such functionality. Then in the summer of 2000,
1103 Gerhard Rieger. conceived the idea, wrote an excellent patch
1104 implementing it, and sent it to the nmap-hackers mailing list.. I
1105 incorporated that patch into the Nmap tree and released a new
1106 version the next day. Few pieces of commercial software have users
1107 enthusiastic enough to design and contribute their own
1108 improvements!
1109
1110 Protocol scan works in a similar fashion to UDP scan. Instead of
1111 iterating through the port number field of a UDP packet, it sends
1112 IP packet headers and iterates through the eight-bit IP protocol
1113 field. The headers are usually empty, containing no data and not
1114 even the proper header for the claimed protocol. The exceptions are
1115 TCP, UDP, ICMP, SCTP, and IGMP. A proper protocol header for those
1116 is included since some systems won´t send them otherwise and
1117 because Nmap already has functions to create them. Instead of
1118 watching for ICMP port unreachable messages, protocol scan is on
1119 the lookout for ICMP protocol unreachable messages. If Nmap
1120 receives any response in any protocol from the target host, Nmap
1121 marks that protocol as open. An ICMP protocol unreachable error
1122 (type 3, code 2) causes the protocol to be marked as closed Other
1123 ICMP unreachable errors (type 3, code 1, 3, 9, 10, or 13) cause the
1124 protocol to be marked filtered (though they prove that ICMP is open
1125 at the same time). If no response is received after
1126 retransmissions, the protocol is marked open|filtered
1127
1128 -b FTP relay host (FTP bounce scan) .
1129 An interesting feature of the FTP protocol (RFC 959[9]) is support
1130 for so-called proxy FTP connections. This allows a user to connect
1131 to one FTP server, then ask that files be sent to a third-party
1132 server. Such a feature is ripe for abuse on many levels, so most
1133 servers have ceased supporting it. One of the abuses this feature
1134 allows is causing the FTP server to port scan other hosts. Simply
1135 ask the FTP server to send a file to each interesting port of a
1136 target host in turn. The error message will describe whether the
1137 port is open or not. This is a good way to bypass firewalls because
1138 organizational FTP servers are often placed where they have more
1139 access to other internal hosts than any old Internet host would.
1140 Nmap supports FTP bounce scan with the -b option. It takes an
1141 argument of the form username:password@server:port. Server is the
1142 name or IP address of a vulnerable FTP server. As with a normal
1143 URL, you may omit username:password, in which case anonymous login
1144 credentials (user: anonymous password:-wwwuser@) are used. The port
1145 number (and preceding colon) may be omitted as well, in which case
1146 the default FTP port (21) on server is used.
1147
1148 This vulnerability was widespread in 1997 when Nmap was released,
1149 but has largely been fixed. Vulnerable servers are still around, so
1150 it is worth trying when all else fails. If bypassing a firewall is
1151 your goal, scan the target network for port 21 (or even for any FTP
1152 services if you scan all ports with version detection) and use the
1153 ftp-bounce. NSE script. Nmap will tell you whether the host is
1154 vulnerable or not. If you are just trying to cover your tracks, you
1155 don´t need to (and, in fact, shouldn´t) limit yourself to hosts on
1156 the target network. Before you go scanning random Internet
1157 addresses for vulnerable FTP servers, consider that sysadmins may
1158 not appreciate you abusing their servers in this way.
1159
1161 In addition to all of the scan methods discussed previously, Nmap
1162 offers options for specifying which ports are scanned and whether the
1163 scan order is randomized or sequential. By default, Nmap scans the most
1164 common 1,000 ports for each protocol.
1165
1166 -p port ranges (Only scan specified ports) .
1167 This option specifies which ports you want to scan and overrides
1168 the default. Individual port numbers are OK, as are ranges
1169 separated by a hyphen (e.g. 1-1023). The beginning and/or end
1170 values of a range may be omitted, causing Nmap to use 1 and 65535,
1171 respectively. So you can specify -p- to scan ports from 1 through
1172 65535. Scanning port zero. is allowed if you specify it
1173 explicitly. For IP protocol scanning (-sO), this option specifies
1174 the protocol numbers you wish to scan for (0–255).
1175
1176 When scanning both TCP and UDP ports, you can specify a particular
1177 protocol by preceding the port numbers by T: or U:. The qualifier
1178 lasts until you specify another qualifier. For example, the
1179 argument -p U:53,111,137,T:21-25,80,139,8080 would scan UDP ports
1180 53, 111,and 137, as well as the listed TCP ports. Note that to scan
1181 both UDP and TCP, you have to specify -sU and at least one TCP scan
1182 type (such as -sS, -sF, or -sT). If no protocol qualifier is given,
1183 the port numbers are added to all protocol lists. Ports can also
1184 be specified by name according to what the port is referred to in
1185 the nmap-services. You can even use the wildcards * and ? with the
1186 names. For example, to scan FTP and all ports whose names begin
1187 with “http”, use -p ftp,http*. Be careful about shell expansions
1188 and quote the argument to -p if unsure.
1189
1190 Ranges of ports can be surrounded by square brackets to indicate
1191 ports inside that range that appear in nmap-services. For example,
1192 the following will scan all ports in nmap-services equal to or
1193 below 1024: -p [-1024]. Be careful with shell expansions and quote
1194 the argument to -p if unsure.
1195
1196 -F (Fast (limited port) scan) .
1197 Specifies that you wish to scan fewer ports than the default.
1198 Normally Nmap scans the most common 1,000 ports for each scanned
1199 protocol. With -F, this is reduced to 100.
1200
1201 Nmap needs an nmap-services file with frequency information in
1202 order to know which ports are the most common. If port frequency
1203 information isn´t available, perhaps because of the use of a custom
1204 nmap-services file, -F means to scan only ports that are named in
1205 the services file (normally Nmap scans all named ports plus ports
1206 1–1024).
1207
1208 -r (Don´t randomize ports) .
1209 By default, Nmap randomizes the scanned port order (except that
1210 certain commonly accessible ports are moved near the beginning for
1211 efficiency reasons). This randomization is normally desirable, but
1212 you can specify -r for sequential (sorted from lowest to highest)
1213 port scanning instead.
1214
1215 --port-ratio ratio<decimal number between 0 and 1>
1216 Scans all ports in nmap-services file with a ratio greater than the
1217 one given. ratio must be between 0.0 and 1.1.
1218
1219 --top-ports n
1220 Scans the n highest-ratio ports found in nmap-services file. n
1221 must be 1 or greater.
1222
1224 Point Nmap at a remote machine and it might tell you that ports 25/tcp,
1225 80/tcp, and 53/udp are open. Using its nmap-services. database of
1226 about 2,200 well-known services,. Nmap would report that those ports
1227 probably correspond to a mail server (SMTP), web server (HTTP), and
1228 name server (DNS) respectively. This lookup is usually accurate—the
1229 vast majority of daemons listening on TCP port 25 are, in fact, mail
1230 servers. However, you should not bet your security on this! People can
1231 and do run services on strange ports..
1232
1233 Even if Nmap is right, and the hypothetical server above is running
1234 SMTP, HTTP, and DNS servers, that is not a lot of information. When
1235 doing vulnerability assessments (or even simple network inventories) of
1236 your companies or clients, you really want to know which mail and DNS
1237 servers and versions are running. Having an accurate version number
1238 helps dramatically in determining which exploits a server is vulnerable
1239 to. Version detection helps you obtain this information.
1240
1241 After TCP and/or UDP ports are discovered using one of the other scan
1242 methods, version detection interrogates those ports to determine more
1243 about what is actually running. The nmap-service-probes. database
1244 contains probes for querying various services and match expressions to
1245 recognize and parse responses. Nmap tries to determine the service
1246 protocol (e.g. FTP, SSH, Telnet, HTTP), the application name (e.g. ISC
1247 BIND, Apache httpd, Solaris telnetd), the version number, hostname,
1248 device type (e.g. printer, router), the OS family (e.g. Windows, Linux)
1249 and sometimes miscellaneous details like whether an X server is open to
1250 connections, the SSH protocol version, or the KaZaA user name). Of
1251 course, most services don´t provide all of this information. If Nmap
1252 was compiled with OpenSSL support, it will connect to SSL servers to
1253 deduce the service listening behind that encryption layer.. When RPC
1254 services are discovered, the Nmap RPC grinder. (-sR). is
1255 automatically used to determine the RPC program and version numbers.
1256 Some UDP ports are left in the open|filtered state after a UDP port
1257 scan is unable to determine whether the port is open or filtered.
1258 Version detection will try to elicit a response from these ports (just
1259 as it does with open ports), and change the state to open if it
1260 succeeds. open|filtered TCP ports are treated the same way. Note that
1261 the Nmap -A option enables version detection among other things. A
1262 paper documenting the workings, usage, and customization of version
1263 detection is available at http://nmap.org/book/vscan.html.
1264
1265 When Nmap receives responses from a service but cannot match them to
1266 its database, it prints out a special fingerprint and a URL for you to
1267 submit if to if you know for sure what is running on the port. Please
1268 take a couple minutes to make the submission so that your find can
1269 benefit everyone. Thanks to these submissions, Nmap has about 6,500
1270 pattern matches for more than 650 protocols such as SMTP, FTP, HTTP,
1271 etc..
1272
1273 Version detection is enabled and controlled with the following options:
1274
1275 -sV (Version detection) .
1276 Enables version detection, as discussed above. Alternatively, you
1277 can use -A, which enables version detection among other things.
1278
1279 --allports (Don´t exclude any ports from version detection) .
1280 By default, Nmap version detection skips TCP port 9100 because some
1281 printers simply print anything sent to that port, leading to dozens
1282 of pages of HTTP GET requests, binary SSL session requests, etc.
1283 This behavior can be changed by modifying or removing the Exclude
1284 directive in nmap-service-probes, or you can specify --allports to
1285 scan all ports regardless of any Exclude directive.
1286
1287 --version-intensity intensity (Set version scan intensity) .
1288 When performing a version scan (-sV), Nmap sends a series of
1289 probes, each of which is assigned a rarity value between one and
1290 nine. The lower-numbered probes are effective against a wide
1291 variety of common services, while the higher-numbered ones are
1292 rarely useful. The intensity level specifies which probes should be
1293 applied. The higher the number, the more likely it is the service
1294 will be correctly identified. However, high intensity scans take
1295 longer. The intensity must be between 0 and 9.. The default is 7..
1296 When a probe is registered to the target port via the
1297 nmap-service-probes ports directive, that probe is tried regardless
1298 of intensity level. This ensures that the DNS probes will always be
1299 attempted against any open port 53, the SSL probe will be done
1300 against 443, etc.
1301
1302 --version-light (Enable light mode) .
1303 This is a convenience alias for --version-intensity 2. This light
1304 mode makes version scanning much faster, but it is slightly less
1305 likely to identify services.
1306
1307 --version-all (Try every single probe) .
1308 An alias for --version-intensity 9, ensuring that every single
1309 probe is attempted against each port.
1310
1311 --version-trace (Trace version scan activity) .
1312 This causes Nmap to print out extensive debugging info about what
1313 version scanning is doing. It is a subset of what you get with
1314 --packet-trace.
1315
1316 -sR (RPC scan) .
1317 This method works in conjunction with the various port scan methods
1318 of Nmap. It takes all the TCP/UDP ports found open and floods them
1319 with SunRPC program NULL commands in an attempt to determine
1320 whether they are RPC ports, and if so, what program and version
1321 number they serve up. Thus you can effectively obtain the same info
1322 as rpcinfo -p even if the target´s portmapper is behind a firewall
1323 (or protected by TCP wrappers). Decoys do not currently work with
1324 RPC scan.. This is automatically enabled as part of version scan
1325 (-sV) if you request that. As version detection includes this and
1326 is much more comprehensive, -sR is rarely needed.
1327
1329 One of Nmap´s best-known features is remote OS detection using TCP/IP
1330 stack fingerprinting. Nmap sends a series of TCP and UDP packets to the
1331 remote host and examines practically every bit in the responses. After
1332 performing dozens of tests such as TCP ISN sampling, TCP options
1333 support and ordering, IP ID sampling, and the initial window size
1334 check, Nmap compares the results to its nmap-os-db. database of more
1335 than 2,600 known OS fingerprints and prints out the OS details if there
1336 is a match. Each fingerprint includes a freeform textual description of
1337 the OS, and a classification which provides the vendor name (e.g. Sun),
1338 underlying OS (e.g. Solaris), OS generation (e.g. 10), and device type
1339 (general purpose, router, switch, game console, etc).
1340
1341 If Nmap is unable to guess the OS of a machine, and conditions are good
1342 (e.g. at least one open port and one closed port were found), Nmap will
1343 provide a URL you can use to submit the fingerprint if you know (for
1344 sure) the OS running on the machine. By doing this you contribute to
1345 the pool of operating systems known to Nmap and thus it will be more
1346 accurate for everyone.
1347
1348 OS detection enables some other tests which make use of information
1349 that is gathered during the process anyway. One of these is TCP
1350 Sequence Predictability Classification. This measures approximately how
1351 hard it is to establish a forged TCP connection against the remote
1352 host. It is useful for exploiting source-IP based trust relationships
1353 (rlogin, firewall filters, etc) or for hiding the source of an attack.
1354 This sort of spoofing is rarely performed any more, but many machines
1355 are still vulnerable to it. The actual difficulty number is based on
1356 statistical sampling and may fluctuate. It is generally better to use
1357 the English classification such as “worthy challenge” or “trivial
1358 joke”. This is only reported in normal output in verbose (-v) mode.
1359 When verbose mode is enabled along with -O, IP ID sequence generation
1360 is also reported. Most machines are in the “incremental” class, which
1361 means that they increment the ID field in the IP header for each packet
1362 they send. This makes them vulnerable to several advanced information
1363 gathering and spoofing attacks.
1364
1365 Another bit of extra information enabled by OS detection is a guess at
1366 a target´s uptime. This uses the TCP timestamp option (RFC 1323[10]) to
1367 guess when a machine was last rebooted. The guess can be inaccurate due
1368 to the timestamp counter not being initialized to zero or the counter
1369 overflowing and wrapping around, so it is printed only in verbose mode.
1370
1371 A paper documenting the workings, usage, and customization of OS
1372 detection is available at http://nmap.org/book/osdetect.html.
1373
1374 OS detection is enabled and controlled with the following options:
1375
1376 -O (Enable OS detection) .
1377 Enables OS detection, as discussed above. Alternatively, you can
1378 use -A to enable OS detection along with other things.
1379
1380 --osscan-limit (Limit OS detection to promising targets) .
1381 OS detection is far more effective if at least one open and one
1382 closed TCP port are found. Set this option and Nmap will not even
1383 try OS detection against hosts that do not meet this criteria. This
1384 can save substantial time, particularly on -Pn scans against many
1385 hosts. It only matters when OS detection is requested with -O or
1386 -A.
1387
1388 --osscan-guess; --fuzzy (Guess OS detection results) .
1389 When Nmap is unable to detect a perfect OS match, it sometimes
1390 offers up near-matches as possibilities. The match has to be very
1391 close for Nmap to do this by default. Either of these (equivalent)
1392 options make Nmap guess more aggressively. Nmap will still tell you
1393 when an imperfect match is printed and display its confidence level
1394 (percentage) for each guess.
1395
1396 --max-os-tries (Set the maximum number of OS detection tries against a
1397 target) .
1398 When Nmap performs OS detection against a target and fails to find
1399 a perfect match, it usually repeats the attempt. By default, Nmap
1400 tries five times if conditions are favorable for OS fingerprint
1401 submission, and twice when conditions aren´t so good. Specifying a
1402 lower --max-os-tries value (such as 1) speeds Nmap up, though you
1403 miss out on retries which could potentially identify the OS.
1404 Alternatively, a high value may be set to allow even more retries
1405 when conditions are favorable. This is rarely done, except to
1406 generate better fingerprints for submission and integration into
1407 the Nmap OS database.
1408
1410 The Nmap Scripting Engine (NSE) is one of Nmap´s most powerful and
1411 flexible features. It allows users to write (and share) simple scripts
1412 (using the Lua programming language[11],
1413
1414 Tasks we had in mind when creating the system include network
1415 discovery, more sophisticated version detection, vulnerability
1416 detection. NSE can even be used for vulnerability exploitation.
1417
1418 To reflect those different uses and to simplify the choice of which
1419 scripts to run, each script contains a field associating it with one or
1420 more categories. Currently defined categories are auth, default.
1421 discovery, dos, exploit, external, fuzzer, intrusive, malware, safe,
1422 version, and vuln. These are all described at
1423 http://nmap.org/book/nse-usage.html#nse-categories.
1424
1425 Scripts are not run in a sandbox and thus could accidentally or
1426 maliciously damage your system or invade your privacy. Never run
1427 scripts from third parties unless you trust the authors or have
1428 carefully audited the scripts yourself.
1429
1430 The Nmap Scripting Engine is described in detail at
1431 http://nmap.org/book/nse.html
1432
1433 and is controlled by the following options:
1434
1435 -sC .
1436 Performs a script scan using the default set of scripts. It is
1437 equivalent to --script=default. Some of the scripts in this
1438 category are considered intrusive and should not be run against a
1439 target network without permission.
1440
1441 --script filename|category|directory|expression|all[,...] .
1442 Runs a script scan using the comma-separated list of filenames,
1443 script categories, and directories. Each element in the list may
1444 also be a Boolean expression describing a more complex set of
1445 scripts. Each element is interpreted first as an expression, then
1446 as a category, and finally as a file or directory name. The special
1447 argument all makes every script in Nmap´s script database eligible
1448 to run. The all argument should be used with caution as NSE may
1449 contain dangerous scripts including exploits, brute force
1450 authentication crackers, and denial of service attacks.
1451
1452 File and directory names may be relative or absolute. Absolute
1453 names are used directly. Relative paths are looked for in the
1454 following places until found:
1455 --datadir
1456 $NMAPDIR.
1457 ~/.nmap (not searched on Windows).
1458 NMAPDATADIR.
1459 the current directory
1460 A scripts subdirectory is also tried in each of these.
1461
1462 When a directory name is given, Nmap loads every file in the
1463 directory whose name ends with .nse. All other files are ignored
1464 and directories are not searched recursively. When a filename is
1465 given, it does not have to have the .nse extension; it will be
1466 added automatically if necessary. Nmap scripts are stored in a
1467 scripts subdirectory of the Nmap data directory by default (see
1468 http://nmap.org/book/data-files.html).
1469
1470 For efficiency, scripts are indexed in a database stored in
1471 scripts/script.db,. which lists the category or categories in
1472 which each script belongs. When referring to scripts from
1473 script.db by name, you can use a shell-style ‘*’ wildcard.
1474
1475 nmap --script "http-*"
1476 Loads all scripts whose name starts with http-, such as
1477 http-auth.nse and http-open-proxy.nse. The argument to --script
1478 had to be in quotes to protect the wildcard from the shell.
1479
1480 More complicated script selection can be done using the and, or,
1481 and not operators to build Boolean expressions. The operators have
1482 the same precedence[12] as in Lua: not is the highest, followed by
1483 and and then or. You can alter precedence by using parentheses.
1484 Because expressions contain space characters it is necessary to
1485 quote them.
1486
1487 nmap --script "not intrusive"
1488 Loads every script except for those in the intrusive category.
1489
1490 nmap --script "default or safe"
1491 This is functionally equivalent to nmap --script
1492 "default,safe". It loads all scripts that are in the default
1493 category or the safe category or both.
1494
1495 nmap --script "default and safe"
1496 Loads those scripts that are in both the default and safe
1497 categories.
1498
1499 nmap --script "(default or safe or intrusive) and not http-*"
1500 Loads scripts in the default, safe, or intrusive categories,
1501 except for those whose names start with http-.
1502
1503 --script-args n1=v1,n2={n3=v3},n4={v4,v5} .
1504 Lets you provide arguments to NSE scripts. Arguments are a
1505 comma-separated list of name=value pairs. Names and values may be
1506 strings not containing whitespace or the characters ‘{’, ‘}’, ‘=’,
1507 or ‘,’. To include one of these characters in a string, enclose the
1508 string in single or double quotes. Within a quoted string, ‘\’
1509 escapes a quote. A backslash is only used to escape quotation marks
1510 in this special case; in all other cases a backslash is interpreted
1511 literally. Values may also be tables enclosed in {}, just as in
1512 Lua. A table may contain simple string values or more name-value
1513 pairs, including nested tables. A complex example of script
1514 arguments is The online NSE Documentation Portal at
1515 http://nmap.org/nsedoc/ lists the arguments that each script
1516 accepts.
1517
1518 --script-trace .
1519 This option does what --packet-trace does, just one ISO layer
1520 higher. If this option is specified all incoming and outgoing
1521 communication performed by a script is printed. The displayed
1522 information includes the communication protocol, the source, the
1523 target and the transmitted data. If more than 5% of all transmitted
1524 data is not printable, then the trace output is in a hex dump
1525 format. Specifying --packet-trace enables script tracing too.
1526
1527 --script-updatedb .
1528 This option updates the script database found in scripts/script.db
1529 which is used by Nmap to determine the available default scripts
1530 and categories. It is only necessary to update the database if you
1531 have added or removed NSE scripts from the default scripts
1532 directory or if you have changed the categories of any script. This
1533 option is generally used by itself: nmap --script-updatedb.
1534
1536 One of my highest Nmap development priorities has always been
1537 performance. A default scan (nmap hostname) of a host on my local
1538 network takes a fifth of a second. That is barely enough time to blink,
1539 but adds up when you are scanning hundreds or thousands of hosts.
1540 Moreover, certain scan options such as UDP scanning and version
1541 detection can increase scan times substantially. So can certain
1542 firewall configurations, particularly response rate limiting. While
1543 Nmap utilizes parallelism and many advanced algorithms to accelerate
1544 these scans, the user has ultimate control over how Nmap runs. Expert
1545 users carefully craft Nmap commands to obtain only the information they
1546 care about while meeting their time constraints.
1547
1548 Techniques for improving scan times include omitting non-critical
1549 tests, and upgrading to the latest version of Nmap (performance
1550 enhancements are made frequently). Optimizing timing parameters can
1551 also make a substantial difference. Those options are listed below.
1552
1553 Some options accept a time parameter. This is specified in seconds by
1554 default, though you can append ‘ms’, ‘s’, ‘m’, or ‘h’ to the value to
1555 specify milliseconds, seconds, minutes, or hours. So the --host-timeout
1556 arguments 900000ms, 900, 900s, and 15m all do the same thing.
1557
1558 --min-hostgroup numhosts; --max-hostgroup numhosts (Adjust parallel
1559 scan group sizes) .
1560 Nmap has the ability to port scan or version scan multiple hosts in
1561 parallel. Nmap does this by dividing the target IP space into
1562 groups and then scanning one group at a time. In general, larger
1563 groups are more efficient. The downside is that host results can´t
1564 be provided until the whole group is finished. So if Nmap started
1565 out with a group size of 50, the user would not receive any reports
1566 (except for the updates offered in verbose mode) until the first 50
1567 hosts are completed.
1568
1569 By default, Nmap takes a compromise approach to this conflict. It
1570 starts out with a group size as low as five so the first results
1571 come quickly and then increases the groupsize to as high as 1024.
1572 The exact default numbers depend on the options given. For
1573 efficiency reasons, Nmap uses larger group sizes for UDP or
1574 few-port TCP scans.
1575
1576 When a maximum group size is specified with --max-hostgroup, Nmap
1577 will never exceed that size. Specify a minimum size with
1578 --min-hostgroup and Nmap will try to keep group sizes above that
1579 level. Nmap may have to use smaller groups than you specify if
1580 there are not enough target hosts left on a given interface to
1581 fulfill the specified minimum. Both may be set to keep the group
1582 size within a specific range, though this is rarely desired.
1583
1584 These options do not have an effect during the host discovery phase
1585 of a scan. This includes plain ping scans (-sn). Host discovery
1586 always works in large groups of hosts to improve speed and
1587 accuracy.
1588
1589 The primary use of these options is to specify a large minimum
1590 group size so that the full scan runs more quickly. A common choice
1591 is 256 to scan a network in Class C sized chunks. For a scan with
1592 many ports, exceeding that number is unlikely to help much. For
1593 scans of just a few port numbers, host group sizes of 2048 or more
1594 may be helpful.
1595
1596 --min-parallelism numprobes; --max-parallelism numprobes (Adjust probe
1597 parallelization) .
1598 These options control the total number of probes that may be
1599 outstanding for a host group. They are used for port scanning and
1600 host discovery. By default, Nmap calculates an ever-changing ideal
1601 parallelism based on network performance. If packets are being
1602 dropped, Nmap slows down and allows fewer outstanding probes. The
1603 ideal probe number slowly rises as the network proves itself
1604 worthy. These options place minimum or maximum bounds on that
1605 variable. By default, the ideal parallelism can drop to one if the
1606 network proves unreliable and rise to several hundred in perfect
1607 conditions.
1608
1609 The most common usage is to set --min-parallelism to a number
1610 higher than one to speed up scans of poorly performing hosts or
1611 networks. This is a risky option to play with, as setting it too
1612 high may affect accuracy. Setting this also reduces Nmap´s ability
1613 to control parallelism dynamically based on network conditions. A
1614 value of 10 might be reasonable, though I only adjust this value as
1615 a last resort.
1616
1617 The --max-parallelism option is sometimes set to one to prevent
1618 Nmap from sending more than one probe at a time to hosts. The
1619 --scan-delay option, discussed later, is another way to do this.
1620
1621 --min-rtt-timeout time, --max-rtt-timeout time, --initial-rtt-timeout
1622 time (Adjust probe timeouts) .
1623 Nmap maintains a running timeout value for determining how long it
1624 will wait for a probe response before giving up or retransmitting
1625 the probe. This is calculated based on the response times of
1626 previous probes.
1627
1628 If the network latency shows itself to be significant and variable,
1629 this timeout can grow to several seconds. It also starts at a
1630 conservative (high) level and may stay that way for a while when
1631 Nmap scans unresponsive hosts.
1632
1633 Specifying a lower --max-rtt-timeout and --initial-rtt-timeout than
1634 the defaults can cut scan times significantly. This is particularly
1635 true for pingless (-Pn) scans, and those against heavily filtered
1636 networks. Don´t get too aggressive though. The scan can end up
1637 taking longer if you specify such a low value that many probes are
1638 timing out and retransmitting while the response is in transit.
1639
1640 If all the hosts are on a local network, 100 milliseconds
1641 (--max-rtt-timeout 100ms) is a reasonable aggressive value. If
1642 routing is involved, ping a host on the network first with the ICMP
1643 ping utility, or with a custom packet crafter such as Nping. that
1644 is more likely to get through a firewall. Look at the maximum round
1645 trip time out of ten packets or so. You might want to double that
1646 for the --initial-rtt-timeout and triple or quadruple it for the
1647 --max-rtt-timeout. I generally do not set the maximum RTT below
1648 100 ms, no matter what the ping times are. Nor do I exceed 1000 ms.
1649
1650 --min-rtt-timeout is a rarely used option that could be useful when
1651 a network is so unreliable that even Nmap´s default is too
1652 aggressive. Since Nmap only reduces the timeout down to the minimum
1653 when the network seems to be reliable, this need is unusual and
1654 should be reported as a bug to the nmap-dev mailing list..
1655
1656 --max-retries numtries (Specify the maximum number of port scan probe
1657 retransmissions) .
1658 When Nmap receives no response to a port scan probe, it could mean
1659 the port is filtered. Or maybe the probe or response was simply
1660 lost on the network. It is also possible that the target host has
1661 rate limiting enabled that temporarily blocked the response. So
1662 Nmap tries again by retransmitting the initial probe. If Nmap
1663 detects poor network reliability, it may try many more times before
1664 giving up on a port. While this benefits accuracy, it also lengthen
1665 scan times. When performance is critical, scans may be sped up by
1666 limiting the number of retransmissions allowed. You can even
1667 specify --max-retries 0 to prevent any retransmissions, though that
1668 is only recommended for situations such as informal surveys where
1669 occasional missed ports and hosts are acceptable.
1670
1671 The default (with no -T template) is to allow ten retransmissions.
1672 If a network seems reliable and the target hosts aren´t rate
1673 limiting, Nmap usually only does one retransmission. So most target
1674 scans aren´t even affected by dropping --max-retries to a low value
1675 such as three. Such values can substantially speed scans of slow
1676 (rate limited) hosts. You usually lose some information when Nmap
1677 gives up on ports early, though that may be preferable to letting
1678 the --host-timeout expire and losing all information about the
1679 target.
1680
1681 --host-timeout time (Give up on slow target hosts) .
1682 Some hosts simply take a long time to scan. This may be due to
1683 poorly performing or unreliable networking hardware or software,
1684 packet rate limiting, or a restrictive firewall. The slowest few
1685 percent of the scanned hosts can eat up a majority of the scan
1686 time. Sometimes it is best to cut your losses and skip those hosts
1687 initially. Specify --host-timeout with the maximum amount of time
1688 you are willing to wait. For example, specify 30m to ensure that
1689 Nmap doesn´t waste more than half an hour on a single host. Note
1690 that Nmap may be scanning other hosts at the same time during that
1691 half an hour, so it isn´t a complete loss. A host that times out is
1692 skipped. No port table, OS detection, or version detection results
1693 are printed for that host.
1694
1695 --scan-delay time; --max-scan-delay time (Adjust delay between probes)
1696 .
1697 This option causes Nmap to wait at least the given amount of time
1698 between each probe it sends to a given host. This is particularly
1699 useful in the case of rate limiting.. Solaris machines (among many
1700 others) will usually respond to UDP scan probe packets with only
1701 one ICMP message per second. Any more than that sent by Nmap will
1702 be wasteful. A --scan-delay of 1s will keep Nmap at that slow rate.
1703 Nmap tries to detect rate limiting and adjust the scan delay
1704 accordingly, but it doesn´t hurt to specify it explicitly if you
1705 already know what rate works best.
1706
1707 When Nmap adjusts the scan delay upward to cope with rate limiting,
1708 the scan slows down dramatically. The --max-scan-delay option
1709 specifies the largest delay that Nmap will allow. A low
1710 --max-scan-delay can speed up Nmap, but it is risky. Setting this
1711 value too low can lead to wasteful packet retransmissions and
1712 possible missed ports when the target implements strict rate
1713 limiting.
1714
1715 Another use of --scan-delay is to evade threshold based intrusion
1716 detection and prevention systems (IDS/IPS)..
1717
1718 --min-rate number; --max-rate number (Directly control the scanning
1719 rate) .
1720 Nmap´s dynamic timing does a good job of finding an appropriate
1721 speed at which to scan. Sometimes, however, you may happen to know
1722 an appropriate scanning rate for a network, or you may have to
1723 guarantee that a scan will be finished by a certain time. Or
1724 perhaps you must keep Nmap from scanning too quickly. The
1725 --min-rate and --max-rate options are designed for these
1726 situations.
1727
1728 When the --min-rate option is given Nmap will do its best to send
1729 packets as fast as or faster than the given rate. The argument is a
1730 positive real number representing a packet rate in packets per
1731 second. For example, specifying --min-rate 300 means that Nmap will
1732 try to keep the sending rate at or above 300 packets per second.
1733 Specifying a minimum rate does not keep Nmap from going faster if
1734 conditions warrant.
1735
1736 Likewise, --max-rate limits a scan´s sending rate to a given
1737 maximum. Use --max-rate 100, for example, to limit sending to 100
1738 packets per second on a fast network. Use --max-rate 0.1 for a slow
1739 scan of one packet every ten seconds. Use --min-rate and --max-rate
1740 together to keep the rate inside a certain range.
1741
1742 These two options are global, affecting an entire scan, not
1743 individual hosts. They only affect port scans and host discovery
1744 scans. Other features like OS detection implement their own timing.
1745
1746 There are two conditions when the actual scanning rate may fall
1747 below the requested minimum. The first is if the minimum is faster
1748 than the fastest rate at which Nmap can send, which is dependent on
1749 hardware. In this case Nmap will simply send packets as fast as
1750 possible, but be aware that such high rates are likely to cause a
1751 loss of accuracy. The second case is when Nmap has nothing to send,
1752 for example at the end of a scan when the last probes have been
1753 sent and Nmap is waiting for them to time out or be responded to.
1754 It´s normal to see the scanning rate drop at the end of a scan or
1755 in between hostgroups. The sending rate may temporarily exceed the
1756 maximum to make up for unpredictable delays, but on average the
1757 rate will stay at or below the maximum.
1758
1759 Specifying a minimum rate should be done with care. Scanning faster
1760 than a network can support may lead to a loss of accuracy. In some
1761 cases, using a faster rate can make a scan take longer than it
1762 would with a slower rate. This is because Nmap´s
1763
1764 adaptive retransmission algorithms will detect the network
1765 congestion caused by an excessive scanning rate and increase the
1766 number of retransmissions in order to improve accuracy. So even
1767 though packets are sent at a higher rate, more packets are sent
1768 overall. Cap the number of retransmissions with the --max-retries
1769 option if you need to set an upper limit on total scan time.
1770
1771 --defeat-rst-ratelimit .
1772 Many hosts have long used rate limiting. to reduce the number of
1773 ICMP error messages (such as port-unreachable errors) they send.
1774 Some systems now apply similar rate limits to the RST (reset)
1775 packets they generate. This can slow Nmap down dramatically as it
1776 adjusts its timing to reflect those rate limits. You can tell Nmap
1777 to ignore those rate limits (for port scans such as SYN scan which
1778 don´t treat non-responsive ports as open) by specifying
1779 --defeat-rst-ratelimit.
1780
1781 Using this option can reduce accuracy, as some ports will appear
1782 non-responsive because Nmap didn´t wait long enough for a
1783 rate-limited RST response. With a SYN scan, the non-response
1784 results in the port being labeled filtered rather than the closed
1785 state we see when RST packets are received. This option is useful
1786 when you only care about open ports, and distinguishing between
1787 closed and filtered ports isn´t worth the extra time.
1788
1789 -T paranoid|sneaky|polite|normal|aggressive|insane (Set a timing
1790 template) .
1791 While the fine-grained timing controls discussed in the previous
1792 section are powerful and effective, some people find them
1793 confusing. Moreover, choosing the appropriate values can sometimes
1794 take more time than the scan you are trying to optimize. So Nmap
1795 offers a simpler approach, with six timing templates. You can
1796 specify them with the -T option and their number (0–5) or their
1797 name. The template names are paranoid (0), sneaky (1), polite (2),
1798 normal (3), aggressive (4), and insane (5). The first two are for
1799 IDS evasion. Polite mode slows down the scan to use less bandwidth
1800 and target machine resources. Normal mode is the default and so -T3
1801 does nothing. Aggressive mode speeds scans up by making the
1802 assumption that you are on a reasonably fast and reliable network.
1803 Finally insane mode. assumes that you are on an extraordinarily
1804 fast network or are willing to sacrifice some accuracy for speed.
1805
1806 These templates allow the user to specify how aggressive they wish
1807 to be, while leaving Nmap to pick the exact timing values. The
1808 templates also make some minor speed adjustments for which
1809 fine-grained control options do not currently exist. For example,
1810 -T4. prohibits the dynamic scan delay from exceeding 10 ms for TCP
1811 ports and -T5 caps that value at 5 ms. Templates can be used in
1812 combination with fine-grained controls, and the fine-grained
1813 controls will you specify will take precedence over the timing
1814 template default for that parameter. I recommend using -T4 when
1815 scanning reasonably modern and reliable networks. Keep that option
1816 even when you add fine-grained controls so that you benefit from
1817 those extra minor optimizations that it enables.
1818
1819 If you are on a decent broadband or ethernet connection, I would
1820 recommend always using -T4. Some people love -T5 though it is too
1821 aggressive for my taste. People sometimes specify -T2 because they
1822 think it is less likely to crash hosts or because they consider
1823 themselves to be polite in general. They often don´t realize just
1824 how slow -T polite. really is. Their scan may take ten times
1825 longer than a default scan. Machine crashes and bandwidth problems
1826 are rare with the default timing options (-T3) and so I normally
1827 recommend that for cautious scanners. Omitting version detection is
1828 far more effective than playing with timing values at reducing
1829 these problems.
1830
1831 While -T0. and -T1. may be useful for avoiding IDS alerts, they
1832 will take an extraordinarily long time to scan thousands of
1833 machines or ports. For such a long scan, you may prefer to set the
1834 exact timing values you need rather than rely on the canned -T0 and
1835 -T1 values.
1836
1837 The main effects of T0 are serializing the scan so only one port is
1838 scanned at a time, and waiting five minutes between sending each
1839 probe. T1 and T2 are similar but they only wait 15 seconds and 0.4
1840 seconds, respectively, between probes. T3 is Nmap´s default
1841 behavior, which includes parallelization.. -T4 does the equivalent
1842 of --max-rtt-timeout 1250ms --initial-rtt-timeout 500ms
1843 --max-retries 6 and sets the maximum TCP scan delay to 10
1844 milliseconds. T5 does the equivalent of --max-rtt-timeout 300ms
1845 --min-rtt-timeout 50ms --initial-rtt-timeout 250ms --max-retries 2
1846 --host-timeout 15m as well as setting the maximum TCP scan delay to
1847 5 ms.
1848
1850 Many Internet pioneers envisioned a global open network with a
1851 universal IP address space allowing virtual connections between any two
1852 nodes. This allows hosts to act as true peers, serving and retrieving
1853 information from each other. People could access all of their home
1854 systems from work, changing the climate control settings or unlocking
1855 the doors for early guests. This vision of universal connectivity has
1856 been stifled by address space shortages and security concerns. In the
1857 early 1990s, organizations began deploying firewalls for the express
1858 purpose of reducing connectivity. Huge networks were cordoned off from
1859 the unfiltered Internet by application proxies, network address
1860 translation, and packet filters. The unrestricted flow of information
1861 gave way to tight regulation of approved communication channels and the
1862 content that passes over them.
1863
1864 Network obstructions such as firewalls can make mapping a network
1865 exceedingly difficult. It will not get any easier, as stifling casual
1866 reconnaissance is often a key goal of implementing the devices.
1867 Nevertheless, Nmap offers many features to help understand these
1868 complex networks, and to verify that filters are working as intended.
1869 It even supports mechanisms for bypassing poorly implemented defenses.
1870 One of the best methods of understanding your network security posture
1871 is to try to defeat it. Place yourself in the mind-set of an attacker,
1872 and deploy techniques from this section against your networks. Launch
1873 an FTP bounce scan, idle scan, fragmentation attack, or try to tunnel
1874 through one of your own proxies.
1875
1876 In addition to restricting network activity, companies are increasingly
1877 monitoring traffic with intrusion detection systems (IDS). All of the
1878 major IDSs ship with rules designed to detect Nmap scans because scans
1879 are sometimes a precursor to attacks. Many of these products have
1880 recently morphed into intrusion prevention systems (IPS). that
1881 actively block traffic deemed malicious. Unfortunately for network
1882 administrators and IDS vendors, reliably detecting bad intentions by
1883 analyzing packet data is a tough problem. Attackers with patience,
1884 skill, and the help of certain Nmap options can usually pass by IDSs
1885 undetected. Meanwhile, administrators must cope with large numbers of
1886 false positive results where innocent activity is misdiagnosed and
1887 alerted on or blocked.
1888
1889 Occasionally people suggest that Nmap should not offer features for
1890 evading firewall rules or sneaking past IDSs. They argue that these
1891 features are just as likely to be misused by attackers as used by
1892 administrators to enhance security. The problem with this logic is that
1893 these methods would still be used by attackers, who would just find
1894 other tools or patch the functionality into Nmap. Meanwhile,
1895 administrators would find it that much harder to do their jobs.
1896 Deploying only modern, patched FTP servers is a far more powerful
1897 defense than trying to prevent the distribution of tools implementing
1898 the FTP bounce attack.
1899
1900 There is no magic bullet (or Nmap option) for detecting and subverting
1901 firewalls and IDS systems. It takes skill and experience. A tutorial is
1902 beyond the scope of this reference guide, which only lists the relevant
1903 options and describes what they do.
1904
1905 -f (fragment packets); --mtu (using the specified MTU) .
1906 The -f option causes the requested scan (including ping scans) to
1907 use tiny fragmented IP packets. The idea is to split up the TCP
1908 header over several packets to make it harder for packet filters,
1909 intrusion detection systems, and other annoyances to detect what
1910 you are doing. Be careful with this! Some programs have trouble
1911 handling these tiny packets. The old-school sniffer named Sniffit
1912 segmentation faulted immediately upon receiving the first fragment.
1913 Specify this option once, and Nmap splits the packets into eight
1914 bytes or less after the IP header. So a 20-byte TCP header would be
1915 split into three packets. Two with eight bytes of the TCP header,
1916 and one with the final four. Of course each fragment also has an IP
1917 header. Specify -f again to use 16 bytes per fragment (reducing the
1918 number of fragments).. Or you can specify your own offset size
1919 with the --mtu option. Don´t also specify -f if you use --mtu. The
1920 offset must be a multiple of eight. While fragmented packets won´t
1921 get by packet filters and firewalls that queue all IP fragments,
1922 such as the CONFIG_IP_ALWAYS_DEFRAG option in the Linux kernel,
1923 some networks can´t afford the performance hit this causes and thus
1924 leave it disabled. Others can´t enable this because fragments may
1925 take different routes into their networks. Some source systems
1926 defragment outgoing packets in the kernel. Linux with the iptables.
1927 connection tracking module is one such example. Do a scan while a
1928 sniffer such as Wireshark. is running to ensure that sent packets
1929 are fragmented. If your host OS is causing problems, try the
1930 --send-eth. option to bypass the IP layer and send raw ethernet
1931 frames.
1932
1933 Fragmentation is only supported for Nmap´s raw packet features,
1934 which includes TCP and UDP port scans (except connect scan and FTP
1935 bounce scan) and OS detection. Features such as version detection
1936 and the Nmap Scripting Engine generally don´t support fragmentation
1937 because they rely on your host´s TCP stack to communicate with
1938 target services.
1939
1940 -D decoy1[,decoy2][,ME][,...] (Cloak a scan with decoys) .
1941 Causes a decoy scan to be performed, which makes it appear to the
1942 remote host that the host(s) you specify as decoys are scanning the
1943 target network too. Thus their IDS might report 5–10 port scans
1944 from unique IP addresses, but they won´t know which IP was scanning
1945 them and which were innocent decoys. While this can be defeated
1946 through router path tracing, response-dropping, and other active
1947 mechanisms, it is generally an effective technique for hiding your
1948 IP address.
1949
1950 Separate each decoy host with commas, and you can optionally use
1951 ME. as one of the decoys to represent the position for your real
1952 IP address. If you put ME in the sixth position or later, some
1953 common port scan detectors (such as Solar Designer´s. excellent
1954 Scanlogd). are unlikely to show your IP address at all. If you
1955 don´t use ME, Nmap will put you in a random position. You can also
1956 use RND. to generate a random, non-reserved IP address, or
1957 RND:number to generate number addresses.
1958
1959 Note that the hosts you use as decoys should be up or you might
1960 accidentally SYN flood your targets. Also it will be pretty easy to
1961 determine which host is scanning if only one is actually up on the
1962 network. You might want to use IP addresses instead of names (so
1963 the decoy networks don´t see you in their nameserver logs).
1964
1965 Decoys are used both in the initial ping scan (using ICMP, SYN,
1966 ACK, or whatever) and during the actual port scanning phase. Decoys
1967 are also used during remote OS detection (-O). Decoys do not work
1968 with version detection or TCP connect scan. When a scan delay is in
1969 effect, the delay is enforced between each batch of spoofed probes,
1970 not between each individual probe. Because decoys are sent as a
1971 batch all at once, they may temporarily violate congestion control
1972 limits.
1973
1974 It is worth noting that using too many decoys may slow your scan
1975 and potentially even make it less accurate. Also, some ISPs will
1976 filter out your spoofed packets, but many do not restrict spoofed
1977 IP packets at all.
1978
1979 -S IP_Address (Spoof source address) .
1980 In some circumstances, Nmap may not be able to determine your
1981 source address (Nmap will tell you if this is the case). In this
1982 situation, use -S with the IP address of the interface you wish to
1983 send packets through.
1984
1985 Another possible use of this flag is to spoof the scan to make the
1986 targets think that someone else is scanning them. Imagine a company
1987 being repeatedly port scanned by a competitor! The -e option and
1988 -Pn are generally required for this sort of usage. Note that you
1989 usually won´t receive reply packets back (they will be addressed to
1990 the IP you are spoofing), so Nmap won´t produce useful reports.
1991
1992 -e interface (Use specified interface) .
1993 Tells Nmap what interface to send and receive packets on. Nmap
1994 should be able to detect this automatically, but it will tell you
1995 if it cannot.
1996
1997 --source-port portnumber; -g portnumber (Spoof source port number) .
1998 One surprisingly common misconfiguration is to trust traffic based
1999 only on the source port number. It is easy to understand how this
2000 comes about. An administrator will set up a shiny new firewall,
2001 only to be flooded with complains from ungrateful users whose
2002 applications stopped working. In particular, DNS may be broken
2003 because the UDP DNS replies from external servers can no longer
2004 enter the network. FTP is another common example. In active FTP
2005 transfers, the remote server tries to establish a connection back
2006 to the client to transfer the requested file.
2007
2008 Secure solutions to these problems exist, often in the form of
2009 application-level proxies or protocol-parsing firewall modules.
2010 Unfortunately there are also easier, insecure solutions. Noting
2011 that DNS replies come from port 53 and active FTP from port 20,
2012 many administrators have fallen into the trap of simply allowing
2013 incoming traffic from those ports. They often assume that no
2014 attacker would notice and exploit such firewall holes. In other
2015 cases, administrators consider this a short-term stop-gap measure
2016 until they can implement a more secure solution. Then they forget
2017 the security upgrade.
2018
2019 Overworked network administrators are not the only ones to fall
2020 into this trap. Numerous products have shipped with these insecure
2021 rules. Even Microsoft has been guilty. The IPsec filters that
2022 shipped with Windows 2000 and Windows XP contain an implicit rule
2023 that allows all TCP or UDP traffic from port 88 (Kerberos). In
2024 another well-known case, versions of the Zone Alarm personal
2025 firewall up to 2.1.25 allowed any incoming UDP packets with the
2026 source port 53 (DNS) or 67 (DHCP).
2027
2028 Nmap offers the -g and --source-port options (they are equivalent)
2029 to exploit these weaknesses. Simply provide a port number and Nmap
2030 will send packets from that port where possible. Most scanning
2031 operations that use raw sockets, including SYN and UDP scans,
2032 support the option completely. The option notably doesn´t have an
2033 effect for any operations that use normal operating system sockets,
2034 including DNS requests, TCP connect scan,. version detection, and
2035 script scanning. Setting the source port also doesn´t work for OS
2036 detection, because Nmap must use different port numbers for certain
2037 OS detection tests to work properly.
2038
2039 --data-length number (Append random data to sent packets) .
2040 Normally Nmap sends minimalist packets containing only a header. So
2041 its TCP packets are generally 40 bytes and ICMP echo requests are
2042 just 28. Some UDP ports. and IP protocols. get a custom payload
2043 by default. This option tells Nmap to append the given number of
2044 random bytes to most of the packets it sends, and not to use any
2045 protocol-specific payloads. (Use --data-length 0 for no random or
2046 protocol-specific payloads.. OS detection (-O) packets are not
2047 affected. because accuracy there requires probe consistency, but
2048 most pinging and portscan packets support this. It slows things
2049 down a little, but can make a scan slightly less conspicuous.
2050
2051 --ip-options S|R [route]|L [route]|T|U ... ; --ip-options hex string
2052 (Send packets with specified ip options) .
2053 The IP protocol[13] offers several options which may be placed in
2054 packet headers. Unlike the ubiquitous TCP options, IP options are
2055 rarely seen due to practicality and security concerns. In fact,
2056 many Internet routers block the most dangerous options such as
2057 source routing. Yet options can still be useful in some cases for
2058 determining and manipulating the network route to target machines.
2059 For example, you may be able to use the record route option to
2060 determine a path to a target even when more traditional
2061 traceroute-style approaches fail. Or if your packets are being
2062 dropped by a certain firewall, you may be able to specify a
2063 different route with the strict or loose source routing options.
2064
2065 The most powerful way to specify IP options is to simply pass in
2066 values as the argument to --ip-options. Precede each hex number
2067 with \x then the two digits. You may repeat certain characters by
2068 following them with an asterisk and then the number of times you
2069 wish them to repeat. For example, \x01\x07\x04\x00*36\x01 is a hex
2070 string containing 36 NUL bytes.
2071
2072 Nmap also offers a shortcut mechanism for specifying options.
2073 Simply pass the letter R, T, or U to request record-route,.
2074 record-timestamp,. or both options together, respectively. Loose
2075 or strict source routing. may be specified with an L or S followed
2076 by a space and then a space-separated list of IP addresses.
2077
2078 If you wish to see the options in packets sent and received,
2079 specify --packet-trace. For more information and examples of using
2080 IP options with Nmap, see http://seclists.org/nmap-dev/2006/q3/52.
2081
2082 --ttl value (Set IP time-to-live field) .
2083 Sets the IPv4 time-to-live field in sent packets to the given
2084 value.
2085
2086 --randomize-hosts (Randomize target host order) .
2087 Tells Nmap to shuffle each group of up to 16384 hosts before it
2088 scans them. This can make the scans less obvious to various network
2089 monitoring systems, especially when you combine it with slow timing
2090 options. If you want to randomize over larger group sizes, increase
2091 PING_GROUP_SZ. in nmap.h. and recompile. An alternative solution
2092 is to generate the target IP list with a list scan (-sL -n -oN
2093 filename), randomize it with a Perl script, then provide the whole
2094 list to Nmap with -iL..
2095
2096 --spoof-mac MAC address, prefix, or vendor name (Spoof MAC address) .
2097 Asks Nmap to use the given MAC address for all of the raw ethernet
2098 frames it sends. This option implies --send-eth. to ensure that
2099 Nmap actually sends ethernet-level packets. The MAC given can take
2100 several formats. If it is simply the number 0, Nmap chooses a
2101 completely random MAC address for the session. If the given string
2102 is an even number of hex digits (with the pairs optionally
2103 separated by a colon), Nmap will use those as the MAC. If fewer
2104 than 12 hex digits are provided, Nmap fills in the remainder of the
2105 six bytes with random values. If the argument isn´t a zero or hex
2106 string, Nmap looks through nmap-mac-prefixes to find a vendor name
2107 containing the given string (it is case insensitive). If a match is
2108 found, Nmap uses the vendor´s OUI (three-byte prefix). and fills
2109 out the remaining three bytes randomly. Valid --spoof-mac argument
2110 examples are Apple, 0, 01:02:03:04:05:06, deadbeefcafe, 0020F2, and
2111 Cisco. This option only affects raw packet scans such as SYN scan
2112 or OS detection, not connection-oriented features such as version
2113 detection or the Nmap Scripting Engine.
2114
2115 --badsum (Send packets with bogus TCP/UDP checksums) .
2116 Asks Nmap to use an invalid TCP, UDP or SCTP checksum for packets
2117 sent to target hosts. Since virtually all host IP stacks properly
2118 drop these packets, any responses received are likely coming from a
2119 firewall or IDS that didn´t bother to verify the checksum. For more
2120 details on this technique, see http://nmap.org/p60-12.html
2121
2122 --adler32 (Use deprecated Adler32 instead of CRC32C for SCTP checksums)
2123 .
2124 Asks Nmap to use the deprecated Adler32 algorithm for calculating
2125 the SCTP checksum. If --adler32 is not given, CRC-32C (Castagnoli)
2126 is used. RFC 2960[14] originally defined Adler32 as checksum
2127 algorithm for SCTP; RFC 4960[7] later redefined the SCTP checksums
2128 to use CRC-32C. Current SCTP implementations should be using
2129 CRC-32C, but in order to elicit responses from old, legacy SCTP
2130 implementations, it may be preferable to use Adler32.
2131
2133 Any security tool is only as useful as the output it generates. Complex
2134 tests and algorithms are of little value if they aren´t presented in an
2135 organized and comprehensible fashion. Given the number of ways Nmap is
2136 used by people and other software, no single format can please
2137 everyone. So Nmap offers several formats, including the interactive
2138 mode for humans to read directly and XML for easy parsing by software.
2139
2140 In addition to offering different output formats, Nmap provides options
2141 for controlling the verbosity of output as well as debugging messages.
2142 Output types may be sent to standard output or to named files, which
2143 Nmap can append to or clobber. Output files may also be used to resume
2144 aborted scans.
2145
2146 Nmap makes output available in five different formats. The default is
2147 called interactive output,. and it is sent to standard output
2148 (stdout).. There is also normal output,. which is similar to
2149 interactive except that it displays less runtime information and
2150 warnings since it is expected to be analyzed after the scan completes
2151 rather than interactively.
2152
2153 XML output. is one of the most important output types, as it can be
2154 converted to HTML, easily parsed by programs such as Nmap graphical
2155 user interfaces, or imported into databases.
2156
2157 The two remaining output types are the simple grepable output. which
2158 includes most information for a target host on a single line, and
2159 sCRiPt KiDDi3 0utPUt. for users who consider themselves |<-r4d.
2160
2161 While interactive output is the default and has no associated
2162 command-line options, the other four format options use the same
2163 syntax. They take one argument, which is the filename that results
2164 should be stored in. Multiple formats may be specified, but each format
2165 may only be specified once. For example, you may wish to save normal
2166 output for your own review while saving XML of the same scan for
2167 programmatic analysis. You might do this with the options -oX
2168 myscan.xml -oN myscan.nmap. While this chapter uses the simple names
2169 like myscan.xml for brevity, more descriptive names are generally
2170 recommended. The names chosen are a matter of personal preference,
2171 though I use long ones that incorporate the scan date and a word or two
2172 describing the scan, placed in a directory named after the company I´m
2173 scanning.
2174
2175 While these options save results to files, Nmap still prints
2176 interactive output to stdout as usual. For example, the command nmap
2177 -oX myscan.xml target prints XML to myscan.xml and fills standard
2178 output with the same interactive results it would have printed if -oX
2179 wasn´t specified at all. You can change this by passing a hyphen
2180 character as the argument to one of the format types. This causes Nmap
2181 to deactivate interactive output, and instead print results in the
2182 format you specified to the standard output stream. So the command nmap
2183 -oX - target will send only XML output to stdout.. Serious errors may
2184 still be printed to the normal error stream, stderr..
2185
2186 Unlike some Nmap arguments, the space between the logfile option flag
2187 (such as -oX) and the filename or hyphen is mandatory. If you omit the
2188 flags and give arguments such as -oG- or -oXscan.xml, a backwards
2189 compatibility feature of Nmap will cause the creation of normal format
2190 output files named G- and Xscan.xml respectively.
2191
2192 All of these arguments support strftime-like. conversions in the
2193 filename. %H, %M, %S, %m, %d, %y, and %Y are all exactly the same as
2194 in strftime. %T is the same as %H%M%S, %R is the same as %H%M, and %D
2195 is the same as %m%d%y. A % followed by any other character just yields
2196 that character (%% gives you a percent symbol). So -oX ´scan-%T-%D.xml´
2197 will use an XML file with a name in the form of scan-144840-121307.xml.
2198
2199 Nmap also offers options to control scan verbosity and to append to
2200 output files rather than clobbering them. All of these options are
2201 described below.
2202
2203 Nmap Output Formats
2204
2205 -oN filespec (normal output) .
2206 Requests that normal output be directed to the given filename. As
2207 discussed above, this differs slightly from interactive output.
2208
2209 -oX filespec (XML output) .
2210 Requests that XML output be directed to the given filename. Nmap
2211 includes a document type definition (DTD) which allows XML parsers
2212 to validate Nmap XML output. While it is primarily intended for
2213 programmatic use, it can also help humans interpret Nmap XML
2214 output. The DTD defines the legal elements of the format, and often
2215 enumerates the attributes and values they can take on. The latest
2216 version is always available from http://nmap.org/data/nmap.dtd.
2217
2218 XML offers a stable format that is easily parsed by software. Free
2219 XML parsers are available for all major computer languages,
2220 including C/C++, Perl, Python, and Java. People have even written
2221 bindings for most of these languages to handle Nmap output and
2222 execution specifically. Examples are Nmap::Scanner[15]. and
2223 Nmap::Parser[16]. in Perl CPAN. In almost all cases that a
2224 non-trivial application interfaces with Nmap, XML is the preferred
2225 format.
2226
2227 The XML output references an XSL stylesheet which can be used to
2228 format the results as HTML. The easiest way to use this is simply
2229 to load the XML output in a web browser such as Firefox or IE. By
2230 default, this will only work on the machine you ran Nmap on (or a
2231 similarly configured one) due to the hard-coded nmap.xsl filesystem
2232 path. Use the --webxml or --stylesheet options to create portable
2233 XML files that render as HTML on any web-connected machine.
2234
2235 -oS filespec (ScRipT KIdd|3 oUTpuT) .
2236 Script kiddie output is like interactive output, except that it is
2237 post-processed to better suit the l33t HaXXorZ who previously
2238 looked down on Nmap due to its consistent capitalization and
2239 spelling. Humor impaired people should note that this option is
2240 making fun of the script kiddies before flaming me for supposedly
2241 “helping them”.
2242
2243 -oG filespec (grepable output) .
2244 This output format is covered last because it is deprecated. The
2245 XML output format is far more powerful, and is nearly as convenient
2246 for experienced users. XML is a standard for which dozens of
2247 excellent parsers are available, while grepable output is my own
2248 simple hack. XML is extensible to support new Nmap features as they
2249 are released, while I often must omit those features from grepable
2250 output for lack of a place to put them.
2251
2252 Nevertheless, grepable output is still quite popular. It is a
2253 simple format that lists each host on one line and can be trivially
2254 searched and parsed with standard Unix tools such as grep, awk,
2255 cut, sed, diff, and Perl. Even I usually use it for one-off tests
2256 done at the command line. Finding all the hosts with the SSH port
2257 open or that are running Solaris takes only a simple grep to
2258 identify the hosts, piped to an awk or cut command to print the
2259 desired fields.
2260
2261 Grepable output consists of comments (lines starting with a pound
2262 (#)). and target lines. A target line includes a combination of
2263 six labeled fields, separated by tabs and followed with a colon.
2264 The fields are Host, Ports, Protocols, Ignored State, OS, Seq
2265 Index, IP ID, and Status.
2266
2267 The most important of these fields is generally Ports, which gives
2268 details on each interesting port. It is a comma separated list of
2269 port entries. Each port entry represents one interesting port, and
2270 takes the form of seven slash (/) separated subfields. Those
2271 subfields are: Port number, State, Protocol, Owner, Service, SunRPC
2272 info, and Version info.
2273
2274 As with XML output, this man page does not allow for documenting
2275 the entire format. A more detailed look at the Nmap grepable output
2276 format is available from
2277 http://nmap.org/book/output-formats-grepable-output.html.
2278
2279 -oA basename (Output to all formats) .
2280 As a convenience, you may specify -oA basename to store scan
2281 results in normal, XML, and grepable formats at once. They are
2282 stored in basename.nmap, basename.xml, and basename.gnmap,
2283 respectively. As with most programs, you can prefix the filenames
2284 with a directory path, such as ~/nmaplogs/foocorp/ on Unix or
2285 c:\hacking\sco on Windows.
2286
2287 Verbosity and debugging options
2288
2289 -v (Increase verbosity level) .
2290 Increases the verbosity level, causing Nmap to print more
2291 information about the scan in progress. Open ports are shown as
2292 they are found and completion time estimates are provided when Nmap
2293 thinks a scan will take more than a few minutes. Use it twice or
2294 more for even greater verbosity: -vv, or give a verbosity level
2295 directly, for example -v3..
2296
2297 Most changes only affect interactive output, and some also affect
2298 normal and script kiddie output. The other output types are meant
2299 to be processed by machines, so Nmap can give substantial detail by
2300 default in those formats without fatiguing a human user. However,
2301 there are a few changes in other modes where output size can be
2302 reduced substantially by omitting some detail. For example, a
2303 comment line in the grepable output that provides a list of all
2304 ports scanned is only printed in verbose mode because it can be
2305 quite long.
2306
2307 -d (Increase debugging level) .
2308 When even verbose mode doesn´t provide sufficient data for you,
2309 debugging is available to flood you with much more! As with the
2310 verbosity option (-v), debugging is enabled with a command-line
2311 flag (-d) and the debug level can be increased by specifying it
2312 multiple times,. as in -dd, or by setting a level directly. For
2313 example, -d9 sets level nine. That is the highest effective level
2314 and will produce thousands of lines unless you run a very simple
2315 scan with very few ports and targets.
2316
2317 Debugging output is useful when a bug is suspected in Nmap, or if
2318 you are simply confused as to what Nmap is doing and why. As this
2319 feature is mostly intended for developers, debug lines aren´t
2320 always self-explanatory. You may get something like: Timeout vals:
2321 srtt: -1 rttvar: -1 to: 1000000 delta 14987 ==> srtt: 14987 rttvar:
2322 14987 to: 100000. If you don´t understand a line, your only
2323 recourses are to ignore it, look it up in the source code, or
2324 request help from the development list (nmap-dev).. Some lines are
2325 self explanatory, but the messages become more obscure as the debug
2326 level is increased.
2327
2328 --reason (Host and port state reasons) .
2329 Shows the reason each port is set to a specific state and the
2330 reason each host is up or down. This option displays the type of
2331 the packet that determined a port or hosts state. For example, A
2332 RST packet from a closed port or an echo reply from an alive host.
2333 The information Nmap can provide is determined by the type of scan
2334 or ping. The SYN scan and SYN ping (-sS and -PS) are very detailed,
2335 but the TCP connect scan (-sT) is limited by the implementation of
2336 the connect system call. This feature is automatically enabled by
2337 the debug option (-d). and the results are stored in XML log files
2338 even if this option is not specified.
2339
2340 --stats-every time (Print periodic timing stats) .
2341 Periodically prints a timing status message after each interval of
2342 time. The time is a specification of the kind described in the
2343 section called “TIMING AND PERFORMANCE”; so for example, use
2344 --stats-every 10s to get a status update every 10 seconds. Updates
2345 are printed to interactive output (the screen) and XML output.
2346
2347 --packet-trace (Trace packets and data sent and received) .
2348 Causes Nmap to print a summary of every packet sent or received.
2349 This is often used for debugging, but is also a valuable way for
2350 new users to understand exactly what Nmap is doing under the
2351 covers. To avoid printing thousands of lines, you may want to
2352 specify a limited number of ports to scan, such as -p20-30. If you
2353 only care about the goings on of the version detection subsystem,
2354 use --version-trace instead. If you only care about script tracing,
2355 specify --script-trace. With --packet-trace, you get all of the
2356 above.
2357
2358 --open (Show only open (or possibly open) ports) .
2359 Sometimes you only care about ports you can actually connect to
2360 (open ones), and don´t want results cluttered with closed,
2361 filtered, and closed|filtered ports. Output customization is
2362 normally done after the scan using tools such as grep, awk, and
2363 Perl, but this feature was added due to overwhelming requests.
2364 Specify --open to only see hosts with at least one open,
2365 open|filtered, or unfiltered port, and only see ports in those
2366 states. These three states are treated just as they normally are,
2367 which means that open|filtered and unfiltered may be condensed into
2368 counts if there are an overwhelming number of them.
2369
2370 --iflist (List interfaces and routes) .
2371 Prints the interface list and system routes as detected by Nmap.
2372 This is useful for debugging routing problems or device
2373 mischaracterization (such as Nmap treating a PPP connection as
2374 ethernet).
2375
2376 --log-errors (Log errors/warnings to normal mode output file) .
2377 Warnings and errors printed by Nmap usually go only to the screen
2378 (interactive output), leaving any normal-format output files
2379 (usually specified with -oN) uncluttered. When you do want to see
2380 those messages in the normal output file you specified, add this
2381 option. It is useful when you aren´t watching the interactive
2382 output or when you want to record errors while debugging a problem.
2383 The error and warning messages will still appear in interactive
2384 mode too. This won´t work for most errors related to bad
2385 command-line arguments because Nmap may not have initialized its
2386 output files yet. In addition, some Nmap error and warning messages
2387 use a different system which does not yet support this option.
2388
2389 An alternative to --log-errors is redirecting interactive output
2390 (including the standard error stream) to a file. Most Unix shells
2391 make this approach easy, though it can be difficult on Windows.
2392
2393 Miscellaneous output options
2394
2395 --append-output (Append to rather than clobber output files) .
2396 When you specify a filename to an output format flag such as -oX or
2397 -oN, that file is overwritten by default. If you prefer to keep the
2398 existing content of the file and append the new results, specify
2399 the --append-output option. All output filenames specified in that
2400 Nmap execution will then be appended to rather than clobbered. This
2401 doesn´t work well for XML (-oX) scan data as the resultant file
2402 generally won´t parse properly until you fix it up by hand.
2403
2404 --resume filename (Resume aborted scan) .
2405 Some extensive Nmap runs take a very long time—on the order of
2406 days. Such scans don´t always run to completion. Restrictions may
2407 prevent Nmap from being run during working hours, the network could
2408 go down, the machine Nmap is running on might suffer a planned or
2409 unplanned reboot, or Nmap itself could crash. The administrator
2410 running Nmap could cancel it for any other reason as well, by
2411 pressing ctrl-C. Restarting the whole scan from the beginning may
2412 be undesirable. Fortunately, if normal (-oN) or grepable (-oG) logs
2413 were kept, the user can ask Nmap to resume scanning with the target
2414 it was working on when execution ceased. Simply specify the
2415 --resume option and pass the normal/grepable output file as its
2416 argument. No other arguments are permitted, as Nmap parses the
2417 output file to use the same ones specified previously. Simply call
2418 Nmap as nmap --resume logfilename. Nmap will append new results to
2419 the data files specified in the previous execution. Resumption does
2420 not support the XML output format because combining the two runs
2421 into one valid XML file would be difficult.
2422
2423 --stylesheet path or URL (Set XSL stylesheet to transform XML output) .
2424 Nmap ships with an XSL. stylesheet. named nmap.xsl. for viewing
2425 or translating XML output to HTML.. The XML output includes an
2426 xml-stylesheet directive which points to nmap.xml where it was
2427 initially installed by Nmap. Run the XML file through an XSLT
2428 processor such as xsltproc[17]. to produce an HTML file. Directly
2429 opening the XML file in a browser no longer works well because
2430 modern browsers limit the locations a stylesheet may be loaded
2431 from. If you wish to use a different stylesheet, specify it as the
2432 argument to --stylesheet. You must pass the full pathname or URL.
2433 One common invocation is --stylesheet
2434 http://nmap.org/svn/docs/nmap.xsl. This tells an XSLT processor to
2435 load the latest version of the stylesheet from Nmap.Org. The
2436 --webxml option does the same thing with less typing and
2437 memorization. Loading the XSL from Nmap.Org makes it easier to view
2438 results on a machine that doesn´t have Nmap (and thus nmap.xsl)
2439 installed. So the URL is often more useful, but the local
2440 filesystem location of nmap.xsl is used by default for privacy
2441 reasons.
2442
2443 --webxml (Load stylesheet from Nmap.Org) .
2444 This is a convenience option, nothing more than an alias for
2445 --stylesheet http://nmap.org/svn/docs/nmap.xsl.
2446
2447 --no-stylesheet (Omit XSL stylesheet declaration from XML) .
2448 Specify this option to prevent Nmap from associating any XSL
2449 stylesheet with its XML output. The xml-stylesheet directive is
2450 omitted.
2451
2453 This section describes some important (and not-so-important) options
2454 that don´t really fit anywhere else.
2455
2456 -6 (Enable IPv6 scanning) .
2457 Since 2002, Nmap has offered IPv6 support for its most popular
2458 features. In particular, ping scanning (TCP-only), connect
2459 scanning, and version detection all support IPv6. The command
2460 syntax is the same as usual except that you also add the -6 option.
2461 Of course, you must use IPv6 syntax if you specify an address
2462 rather than a hostname. An address might look like
2463 3ffe:7501:4819:2000:210:f3ff:fe03:14d0, so hostnames are
2464 recommended. The output looks the same as usual, with the IPv6
2465 address on the “interesting ports” line being the only IPv6
2466 giveaway.
2467
2468 While IPv6 hasn´t exactly taken the world by storm, it gets
2469 significant use in some (usually Asian) countries and most modern
2470 operating systems support it. To use Nmap with IPv6, both the
2471 source and target of your scan must be configured for IPv6. If your
2472 ISP (like most of them) does not allocate IPv6 addresses to you,
2473 free tunnel brokers are widely available and work fine with Nmap. I
2474 use the free IPv6 tunnel broker. service at
2475 http://www.tunnelbroker.net. Other tunnel brokers are listed at
2476 Wikipedia[18]. 6to4 tunnels are another popular, free approach.
2477
2478 -A (Aggressive scan options) .
2479 This option enables additional advanced and aggressive options. I
2480 haven´t decided exactly which it stands for yet. Presently this
2481 enables OS detection (-O), version scanning (-sV), script scanning
2482 (-sC) and traceroute (--traceroute).. More features may be added
2483 in the future. The point is to enable a comprehensive set of scan
2484 options without people having to remember a large set of flags.
2485 However, because script scanning with the default set is considered
2486 intrusive, you should not use -A against target networks without
2487 permission. This option only enables features, and not timing
2488 options (such as -T4) or verbosity options (-v) that you might want
2489 as well.
2490
2491 --datadir directoryname (Specify custom Nmap data file location) .
2492 Nmap obtains some special data at runtime in files named
2493 nmap-service-probes, nmap-services, nmap-protocols, nmap-rpc,
2494 nmap-mac-prefixes, and nmap-os-db. If the location of any of these
2495 files has been specified (using the --servicedb or --versiondb
2496 options), that location is used for that file. After that, Nmap
2497 searches these files in the directory specified with the --datadir
2498 option (if any). Any files not found there, are searched for in the
2499 directory specified by the NMAPDIR. environment variable. Next
2500 comes ~/.nmap. for real and effective UIDs (POSIX systems only) or
2501 location of the Nmap executable (Win32 only), and then a
2502 compiled-in location such as /usr/local/share/nmap or
2503 /usr/share/nmap . As a last resort, Nmap will look in the current
2504 directory.
2505
2506 --servicedb services file (Specify custom services file) .
2507 Asks Nmap to use the specified services file rather than the
2508 nmap-services data file that comes with Nmap. Using this option
2509 also causes a fast scan (-F) to be used. See the description for
2510 --datadir for more information on Nmap´s data files.
2511
2512 --versiondb service probes file (Specify custom service probes file) .
2513 Asks Nmap to use the specified service probes file rather than the
2514 nmap-service-probes data file that comes with Nmap. See the
2515 description for --datadir for more information on Nmap´s data
2516 files.
2517
2518 --send-eth (Use raw ethernet sending) .
2519 Asks Nmap to send packets at the raw ethernet (data link) layer
2520 rather than the higher IP (network) layer. By default, Nmap chooses
2521 the one which is generally best for the platform it is running on.
2522 Raw sockets (IP layer). are generally most efficient for Unix
2523 machines, while ethernet frames are required for Windows operation
2524 since Microsoft disabled raw socket support. Nmap still uses raw IP
2525 packets on Unix despite this option when there is no other choice
2526 (such as non-ethernet connections).
2527
2528 --send-ip (Send at raw IP level) .
2529 Asks Nmap to send packets via raw IP sockets rather than sending
2530 lower level ethernet frames. It is the complement to the --send-eth
2531 option discussed previously.
2532
2533 --privileged (Assume that the user is fully privileged) .
2534 Tells Nmap to simply assume that it is privileged enough to perform
2535 raw socket sends, packet sniffing, and similar operations that
2536 usually require root privileges. on Unix systems. By default Nmap
2537 quits if such operations are requested but geteuid is not zero.
2538 --privileged is useful with Linux kernel capabilities and similar
2539 systems that may be configured to allow unprivileged users to
2540 perform raw-packet scans. Be sure to provide this option flag
2541 before any flags for options that require privileges (SYN scan, OS
2542 detection, etc.). The NMAP_PRIVILEGED. environment variable may be
2543 set as an equivalent alternative to --privileged.
2544
2545 --unprivileged (Assume that the user lacks raw socket privileges) .
2546 This option is the opposite of --privileged. It tells Nmap to treat
2547 the user as lacking network raw socket and sniffing privileges.
2548 This is useful for testing, debugging, or when the raw network
2549 functionality of your operating system is somehow broken. The
2550 NMAP_UNPRIVILEGED. environment variable may be set as an
2551 equivalent alternative to --unprivileged.
2552
2553 --release-memory (Release memory before quitting) .
2554 This option is only useful for memory-leak debugging. It causes
2555 Nmap to release allocated memory just before it quits so that
2556 actual memory leaks are easier to spot. Normally Nmap skips this as
2557 the OS does this anyway upon process termination.
2558
2559 -V; --version (Print version number) .
2560 Prints the Nmap version number and exits.
2561
2562 -h; --help (Print help summary page) .
2563 Prints a short help screen with the most common command flags.
2564 Running Nmap without any arguments does the same thing.
2565
2567 During the execution of Nmap, all key presses are captured. This allows
2568 you to interact with the program without aborting and restarting it.
2569 Certain special keys will change options, while any other keys will
2570 print out a status message telling you about the scan. The convention
2571 is that lowercase letters increase the amount of printing, and
2572 uppercase letters decrease the printing. You may also press ‘?’ for
2573 help.
2574
2575 v / V
2576 Increase / decrease the verbosity level
2577
2578 d / D
2579 Increase / decrease the debugging Level
2580
2581 p / P
2582 Turn on / off packet tracing
2583
2584 ?
2585 Print a runtime interaction help screen
2586
2587 Anything else
2588 Print out a status message like this:
2589
2590 Stats: 0:00:07 elapsed; 20 hosts completed (1 up), 1 undergoing Service Scan
2591 Service scan Timing: About 33.33% done; ETC: 20:57 (0:00:12 remaining)
2592
2594 Here are some Nmap usage examples, from the simple and routine to a
2595 little more complex and esoteric. Some actual IP addresses and domain
2596 names are used to make things more concrete. In their place you should
2597 substitute addresses/names from your own network. While I don´t think
2598 port scanning other networks is or should be illegal, some network
2599 administrators don´t appreciate unsolicited scanning of their networks
2600 and may complain. Getting permission first is the best approach.
2601
2602 For testing purposes, you have permission to scan the host
2603 scanme.nmap.org.. This permission only includes scanning via Nmap and
2604 not testing exploits or denial of service attacks. To conserve
2605 bandwidth, please do not initiate more than a dozen scans against that
2606 host per day. If this free scanning target service is abused, it will
2607 be taken down and Nmap will report Failed to resolve given hostname/IP:
2608 scanme.nmap.org. These permissions also apply to the hosts
2609 scanme2.nmap.org, scanme3.nmap.org, and so on, though those hosts do
2610 not currently exist.
2611
2612 nmap -v scanme.nmap.org
2613
2614 This option scans all reserved TCP ports on the machine scanme.nmap.org
2615 . The -v option enables verbose mode.
2616
2617 nmap -sS -O scanme.nmap.org/24
2618
2619 Launches a stealth SYN scan against each machine that is up out of the
2620 256 IPs on the class C sized network where Scanme resides. It also
2621 tries to determine what operating system is running on each host that
2622 is up and running. This requires root privileges because of the SYN
2623 scan and OS detection.
2624
2625 nmap -sV -p 22,53,110,143,4564 198.116.0-255.1-127
2626
2627 Launches host enumeration and a TCP scan at the first half of each of
2628 the 255 possible eight-bit subnets in the 198.116 class B address
2629 space. This tests whether the systems run SSH, DNS, POP3, or IMAP on
2630 their standard ports, or anything on port 4564. For any of these ports
2631 found open, version detection is used to determine what application is
2632 running.
2633
2634 nmap -v -iR 100000 -Pn -p 80
2635
2636 Asks Nmap to choose 100,000 hosts at random and scan them for web
2637 servers (port 80). Host enumeration is disabled with -Pn since first
2638 sending a couple probes to determine whether a host is up is wasteful
2639 when you are only probing one port on each target host anyway.
2640
2641 nmap -Pn -p80 -oX logs/pb-port80scan.xml -oG logs/pb-port80scan.gnmap
2642 216.163.128.20/20
2643
2644 This scans 4096 IPs for any web servers (without pinging them) and
2645 saves the output in grepable and XML formats.
2646
2648 While this reference guide details all material Nmap options, it can´t
2649 fully demonstrate how to apply those features to quickly solve
2650 real-world tasks. For that, we released Nmap Network Scanning: The
2651 Official Nmap Project Guide to Network Discovery and Security Scanning.
2652 Topics include subverting firewalls and intrusion detection systems,
2653 optimizing Nmap performance, and automating common networking tasks
2654 with the Nmap Scripting Engine. Hints and instructions are provided for
2655 common Nmap tasks such as taking network inventory, penetration
2656 testing, detecting rogue wireless access points, and quashing network
2657 worm outbreaks. Examples and diagrams show actual communication on the
2658 wire. More than half of the book is available free online. See
2659 http://nmap.org/book for more information.
2660
2662 Like its author, Nmap isn´t perfect. But you can help make it better by
2663 sending bug reports or even writing patches. If Nmap doesn´t behave the
2664 way you expect, first upgrade to the latest version available from
2665 http://nmap.org. If the problem persists, do some research to determine
2666 whether it has already been discovered and addressed. Try searching for
2667 the error message on our search page at http://insecure.org/search.html
2668 or at Google. Also try browsing the nmap-dev archives at
2669 http://seclists.org/.. Read this full manual page as well. If nothing
2670 comes of this, mail a bug report to nmap-dev@insecure.org. Please
2671 include everything you have learned about the problem, as well as what
2672 version of Nmap you are running and what operating system version it is
2673 running on. Problem reports and Nmap usage questions sent to
2674 nmap-dev@insecure.org are far more likely to be answered than those
2675 sent to Fyodor directly. If you subscribe to the nmap-dev list before
2676 posting, your message will bypass moderation and get through more
2677 quickly. Subscribe at
2678 http://cgi.insecure.org/mailman/listinfo/nmap-dev.
2679
2680 Code patches to fix bugs are even better than bug reports. Basic
2681 instructions for creating patch files with your changes are available
2682 at http://nmap.org/data/HACKING. Patches may be sent to nmap-dev
2683 (recommended) or to Fyodor directly.
2684
2686 Gordon “Fyodor” Lyon fyodor@insecure.org (http://insecure.org)
2687
2688 Hundreds of people have made valuable contributions to Nmap over the
2689 years. These are detailed in the CHANGELOG. file which is distributed
2690 with Nmap and also available from http://nmap.org/changelog.html.
2691
2693 Nmap Copyright and Licensing
2694 The Nmap Security Scanner is (C) 1996–2011 Insecure.Com LLC. Nmap is
2695 also a registered trademark of Insecure.Com LLC. This program is free
2696 software; you may redistribute and/or modify it under the terms of the
2697 GNU General Public License as published by the Free Software
2698 Foundation; Version 2 with the clarifications and exceptions described
2699 below. This guarantees your right to use, modify, and redistribute this
2700 software under certain conditions. If you wish to embed Nmap technology
2701 into proprietary software, we sell alternative licenses (contact
2702 sales@insecure.com). Dozens of software vendors already license Nmap
2703 technology such as host discovery, port scanning, OS detection, and
2704 version detection.
2705
2706 Note that the GPL places important restrictions on “derived works”, yet
2707 it does not provide a detailed definition of that term. To avoid
2708 misunderstandings, we consider an application to constitute a
2709 “derivative work” for the purpose of this license if it does any of the
2710 following:
2711
2712 · Integrates source code from Nmap
2713
2714 · Reads or includes Nmap copyrighted data files, such as nmap-os-db
2715 or nmap-service-probes.
2716
2717 · Executes Nmap and parses the results (as opposed to typical shell
2718 or execution-menu apps, which simply display raw Nmap output and so
2719 are not derivative works.)
2720
2721 · Integrates/includes/aggregates Nmap into a proprietary executable
2722 installer, such as those produced by InstallShield.
2723
2724 · Links to a library or executes a program that does any of the
2725 above.
2726
2727 The term “Nmap” should be taken to also include any portions or derived
2728 works of Nmap. This list is not exclusive, but is meant to clarify our
2729 interpretation of derived works with some common examples. Our
2730 interpretation applies only to Nmap—we don´t speak for other people´s
2731 GPL works.
2732
2733 If you have any questions about the GPL licensing restrictions on using
2734 Nmap in non-GPL works, we would be happy to help. As mentioned above,
2735 we also offer alternative license to integrate Nmap into proprietary
2736 applications and appliances. These contracts have been sold to many
2737 security vendors, and generally include a perpetual license as well as
2738 providing for priority support and updates as well as helping to fund
2739 the continued development of Nmap technology. Please email
2740 sales@insecure.com for further information.
2741
2742 As a special exception to the GPL terms, Insecure.Com LLC grants
2743 permission to link the code of this program with any version of the
2744 OpenSSL library which is distributed under a license identical to that
2745 listed in the included COPYING.OpenSSL file, and distribute linked
2746 combinations including the two.. You must obey the GNU GPL in all
2747 respects for all of the code used other than OpenSSL. If you modify
2748 this file, you may extend this exception to your version of the file,
2749 but you are not obligated to do so.
2750
2751 If you received these files with a written license agreement or
2752 contract stating terms other than the terms above, then that
2753 alternative license agreement takes precedence over these comments.
2754
2755 Creative Commons License for this Nmap Guide
2756 This Nmap Reference Guide is (C) 2005–2011 Insecure.Com LLC. It is
2757 hereby placed under version 3.0 of the Creative Commons Attribution
2758 License[19]. This allows you redistribute and modify the work as you
2759 desire, as long as you credit the original source. Alternatively, you
2760 may choose to treat this document as falling under the same license as
2761 Nmap itself (discussed previously).
2762
2763 Source Code Availability and Community Contributions
2764 Source is provided to this software because we believe users have a
2765 right to know exactly what a program is going to do before they run it.
2766 This also allows you to audit the software for security holes (none
2767 have been found so far).
2768
2769 Source code also allows you to port Nmap to new platforms, fix bugs,
2770 and add new features. You are highly encouraged to send your changes to
2771 nmap-dev@insecure.org for possible incorporation into the main
2772 distribution. By sending these changes to Fyodor or one of the
2773 Insecure.Org development mailing lists, it is assumed that you are
2774 offering the Nmap Project (Insecure.Com LLC) the unlimited,
2775 non-exclusive right to reuse, modify, and relicense the code. Nmap will
2776 always be available open source,. but this is important because the
2777 inability to relicense code has caused devastating problems for other
2778 Free Software projects (such as KDE and NASM). We also occasionally
2779 relicense the code to third parties as discussed above. If you wish to
2780 specify special license conditions of your contributions, just say so
2781 when you send them.
2782
2783 No Warranty.
2784 This program is distributed in the hope that it will be useful, but
2785 WITHOUT ANY WARRANTY; without even the implied warranty of
2786 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2787 General Public License v2.0 for more details at
2788 http://www.gnu.org/licenses/gpl-2.0.html, or in the COPYING file
2789 included with Nmap.
2790
2791 It should also be noted that Nmap has occasionally been known to crash
2792 poorly written applications, TCP/IP stacks, and even operating
2793 systems.. While this is extremely rare, it is important to keep in
2794 mind. Nmap should never be run against mission critical systems unless
2795 you are prepared to suffer downtime. We acknowledge here that Nmap may
2796 crash your systems or networks and we disclaim all liability for any
2797 damage or problems Nmap could cause.
2798
2799 Inappropriate Usage
2800 Because of the slight risk of crashes and because a few black hats like
2801 to use Nmap for reconnaissance prior to attacking systems, there are
2802 administrators who become upset and may complain when their system is
2803 scanned. Thus, it is often advisable to request permission before doing
2804 even a light scan of a network.
2805
2806 Nmap should never be installed with special privileges (e.g. suid root)
2807 for security reasons..
2808
2809 Third-Party Software
2810 This product includes software developed by the Apache Software
2811 Foundation[20]. A modified version of the Libpcap portable packet
2812 capture library[21]. is distributed along with Nmap. The Windows
2813 version of Nmap utilized the Libpcap-derived WinPcap library[22].
2814 instead. Regular expression support is provided by the PCRE
2815 library[23],. which is open-source software, written by Philip Hazel..
2816 Certain raw networking functions use the Libdnet[24]. networking
2817 library, which was written by Dug Song.. A modified version is
2818 distributed with Nmap. Nmap can optionally link with the OpenSSL
2819 cryptography toolkit[25]. for SSL version detection support. The Nmap
2820 Scripting Engine uses an embedded version of the Lua programming
2821 language[26].. All of the third-party software described in this
2822 paragraph is freely redistributable under BSD-style software licenses.
2823
2824 Binary packages for Windows and Mac OS X include support libraries
2825 necessary to run Zenmap and Ndiff with Python and PyGTK. (Unix
2826 platforms commonly make these libraries easy to install, so they are
2827 not part of the packages.) A listing of these support libraries and
2828 their licenses is included in the LICENSES files.
2829
2830 United States Export Control.
2831 Nmap only uses encryption when compiled with the optional OpenSSL
2832 support and linked with OpenSSL. When compiled without OpenSSL support,
2833 Insecure.Com LLC believes that Nmap is not subject to U.S. Export
2834 Administration Regulations (EAR)[27] export control. As such, there is
2835 no applicable ECCN (export control classification number) and
2836 exportation does not require any special license, permit, or other
2837 governmental authorization.
2838
2839 When compiled with OpenSSL support or distributed as source code,
2840 Insecure.Com LLC believes that Nmap falls under U.S. ECCN 5D002[28]
2841 (“Information Security Software”). We distribute Nmap under the TSU
2842 exception for publicly available encryption software defined in EAR
2843 740.13(e)[29].
2844
2846 1. Nmap Network Scanning: The Official Nmap Project Guide to Network
2847 Discovery and Security Scanning
2848 http://nmap.org/book/
2849
2850 2. RFC 1122
2851 http://www.rfc-editor.org/rfc/rfc1122.txt
2852
2853 3. RFC 792
2854 http://www.rfc-editor.org/rfc/rfc792.txt
2855
2856 4. RFC 950
2857 http://www.rfc-editor.org/rfc/rfc950.txt
2858
2859 5. RFC 1918
2860 http://www.rfc-editor.org/rfc/rfc1918.txt
2861
2862 6. UDP
2863 http://www.rfc-editor.org/rfc/rfc768.txt
2864
2865 7. SCTP
2866 http://www.rfc-editor.org/rfc/rfc4960.txt
2867
2868 8. TCP RFC
2869 http://www.rfc-editor.org/rfc/rfc793.txt
2870
2871 9. RFC 959
2872 http://www.rfc-editor.org/rfc/rfc959.txt
2873
2874 10. RFC 1323
2875 http://www.rfc-editor.org/rfc/rfc1323.txt
2876
2877 11. Lua programming language
2878 http://lua.org
2879
2880 12. precedence
2881 http://www.lua.org/manual/5.1/manual.html#2.5.3
2882
2883 13. IP protocol
2884 http://www.rfc-editor.org/rfc/rfc791.txt
2885
2886 14. RFC 2960
2887 http://www.rfc-editor.org/rfc/rfc2960.txt
2888
2889 15. Nmap::Scanner
2890 http://sourceforge.net/projects/nmap-scanner/
2891
2892 16. Nmap::Parser
2893 http://nmapparser.wordpress.com/
2894
2895 17. xsltproc
2896 http://xmlsoft.org/XSLT/
2897
2898 18. listed at Wikipedia
2899 http://en.wikipedia.org/wiki/List_of_IPv6_tunnel_brokers
2900
2901 19. Creative Commons Attribution License
2902 http://creativecommons.org/licenses/by/3.0/
2903
2904 20. Apache Software Foundation
2905 http://www.apache.org
2906
2907 21. Libpcap portable packet capture library
2908 http://www.tcpdump.org
2909
2910 22. WinPcap library
2911 http://www.winpcap.org
2912
2913 23. PCRE library
2914 http://www.pcre.org
2915
2916 24. Libdnet
2917 http://libdnet.sourceforge.net
2918
2919 25. OpenSSL cryptography toolkit
2920 http://www.openssl.org
2921
2922 26. Lua programming language
2923 http://www.lua.org
2924
2925 27. Export Administration Regulations (EAR)
2926 http://www.access.gpo.gov/bis/ear/ear_data.html
2927
2928 28. 5D002
2929 http://www.access.gpo.gov/bis/ear/pdf/ccl5-pt2.pdf
2930
2931 29. EAR 740.13(e)
2932 http://www.access.gpo.gov/bis/ear/pdf/740.pdf
2933
2934
2935
2936Nmap 02/11/2011 NMAP(1)