Nmap (”Network Mapper”) is a free open source utility for network exploration or security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. Nmap runs on most types of computers and both console and graphical versions are available. (source)
First and foremost we will download, compile and install nmap from scratch under Linux. The latest Nmap sources available for download is 4.21ALPHA4 which you can download from here: http://download.insecure.org/nmap/dist/nmap-4.21ALPHA4.tar.bz2
However the stable version is 4.20 .
First we will download the latest source from it’s website:
Now we are going to go through the process Extracting the bzip2 file, “configure” it and “make install” it from the source. With this commands:
bzip2 -cd nmap-4.21ALPHA4.tar.bz2 | tar xvf -
cd nmap-4.21ALPHA4
./configure
make
su root
make install
During the process of installing I get this error:
nmapfe.c:114:2: error: #error “Your system does not appear to have GTK (www.gtk.org) installed. Thus the Nmap X Front End will not compile. You should still be able to use Nmap the normal way (via text console). GUIs are for wimps anyway :)”
Like it said GUIs are for wimps anyways. And besides we will be mostly using console for this demonstration.
You can look at the whole output from my console, during the installation here:
http://www.linuxhaxor.net/nmap_output.html
Nmap has a huge list of scanning options and scanning modes, here is the output list of options:
pavs@uberhaxor:~$ nmap
Nmap 4.21ALPHA4 ( http://insecure.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
-iL: Input from list of hosts/networks
-iR: Choose random targets
–exclude: Exclude hosts/networks
–excludefile: Exclude list from file
HOST DISCOVERY:
-sL: List Scan - simply list targets to scan
-sP: Ping Scan - go no further than determining if host is online
-P0: Treat all hosts as online — skip host discovery
-PS/PA/PU [portlist]: TCP SYN/ACK or UDP discovery to given ports
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
–dns-servers: Specify custom DNS servers
–system-dns: Use OS’s DNS resolver
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: Customize TCP scan flags
-sI: Idlescan
-sO: IP protocol scan
-b: FTP bounce scan
–traceroute: Trace hop path to each host
PORT SPECIFICATION AND SCAN ORDER:
-p: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080
-F: Fast - Scan only the ports listed in the nmap-services file)
-r: Scan ports consecutively - don’t randomize
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
–version-intensity: 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=safe,intrusive
–script=: is a comma separated list of dirs or scripts
–script-trace: Show all data sent and received
–script-updatedb: Update the script database. Only performed if -sC or –script was also given.
OS DETECTION:
-O: Enable OS detection (try 2nd generation w/fallback to 1st)
-O2: Only use the new OS detection system (no fallback)
-O1: Only use the old (1st generation) OS detection system
–osscan-limit: Limit OS detection to promising targets
–osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
Options which takeSEE THE MAN PAGE FOR MANY MORE OPTIONS, DESCRIPTIONS, AND EXAMPLES