Nmap

From aldeid
Jump to: navigation, search
French.png
This article is also available in one or more other languages
To view this article in French, click here
VoirAussi.png
You might also see: Zenmap, Nmap's graphical frontend
Nmap-network-scanning.png

Description

Nmap is certainly THE scanner to know. Thanks to its numerous parameters, it is a swiss army knife to all situations where network identification is needed. It enables among other things to list network hosts and scan their ports.

Installation

From the package

This method shows how to install Nmap-5.00 from packages. Simply run:

$ sudo apt-get install nmap

From sources

First install development sources of libpcap:

$ sudo apt-get install libpcap-dev

Installing Nmap from sources enables, among other things, to obtain the last development revision (5.35-DC1).

$ cd /data/src/
$ wget http://nmap.org/dist/nmap-5.35DC1.tar.bz2
$ bzip2 -cd nmap-5.35DC1.tar.bz2 | tar xf -
$ cd nmap-5.35DC1/
$ .configure
$ make
$ sudo make install

Without change in the configuration options, Nmap installs in /usr/local/bin/nmap.

Usage

Basic syntax

$ ./nmap [Scan Type(s)] [Options] {target specification}

Options

Target Specification

-iL <inputfilename>
Input from list of hosts/networks
-iR <num hosts>
Choose random targets
--exclude <host1[,host2][,host3],...>
Exclude hosts/networks
--excludefile <exclude_file>
Exclude list from file

Host Discovery

-sL
List Scan - simply list targets to scan
-sn
Ping Scan - disable port scan
-Pn
Treat all hosts as online -- skip host discovery
-PS/PA/PU/PY[portlist]
TCP SYN/ACK, UDP or SCTP discovery to given ports
-PE/PP/PM
ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]
IP Protocol Ping
-n/-R
Never do DNS resolution/Always resolve [default: sometimes]
--dns-servers <serv1[,serv2],...>
Specify custom DNS servers
--system-dns
Use OS's DNS resolver
--traceroute
Trace hop path to each host

Scan techniques

-sS/sT/sA/sW/sM
TCP SYN/Connect()/ACK/Window/Maimon scans
-sU
UDP Scan
-sN/sF/sX
TCP Null, FIN, and Xmas scans
--scanflags <flags>
Customize TCP scan flags
-sI <zombie host[:probeport]>
Idle scan
-sY/sZ
SCTP INIT/COOKIE-ECHO scans
-sO
IP protocol scan
-b <FTP relay host>
FTP bounce scan

Port Specification and Scan Order

-p <port ranges>
Only scan specified ports
Ex: -p22 | -p1-65535 | -p U:53,111,137,T:21-25,80,139,8080,S:9
-F
Fast mode - Scan fewer ports than the default scan
-r
Scan ports consecutively - don't randomize
--top-ports <number>
Scan <number> most common ports
--port-ratio <ratio>
Scan ports more common than <ratio>

Service/Version Detection

-sV
Probe open ports to determine service/version info
--version-intensity <level>
Set from 0 (light) to 9 (try all probes)
--version-light
Limit to most likely probes (intensity 2)
--version-all
Try every single probe (intensity 9)
--version-trace
Show detailed version scan activity (for debugging)

Script Scan

-sC
equivalent to --script=default
--script=<Lua scripts>
<Lua scripts> is a comma separated list of directories, script-files or script-categories
--script-args=<n1=v1,[n2=v2,...]>
provide arguments to scripts
--script-trace
Show all data sent and received
--script-updatedb
Update the script database.

OS Detection

-O
Enable OS detection
--osscan-limit
Limit OS detection to promising targets
--osscan-guess
Guess OS more aggressively

Timing and Performance

Info.png
Note
Options which take