Nmap is Network Mapper. It is a security scanner used to discover hosts and services on a network. It sends certain special packets to the target host and analyses the response obtained.
How to Install Nmap?
Now, to install Nmap , execute the following command:
$ sudo apt-get install nmap
How to find the OS of a Remote Host using Nmap ?
The method of finding the OS of a remote host is called OS fingerprint detection. To perform this, execute the following command:
$ sudo nmap -w -O <remote_host_ipaddress>
eg. sudo nmap -w -O 127.0.0.1
If you run the above command, your terminal will look like this:
preethi@preethi:~$ sudo nmap -w -O 10.30.52.160
[sudo] password for preethi:
Starting Nmap 5.21 ( http://nmap.org ) at 2013-01-29 18:14 IST
Nmap scan report for 10.30.52.160
Host is up (0.00044s latency).
Not shown: 995 closed ports
PORT STATE SERVICE
22/tcp open ssh
23/tcp open telnet
80/tcp open http
139/tcp open netbios-ssn
445/tcp open microsoft-ds
MAC Address: A0:B3:CC:F7:8D:64 (Unknown)
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=5.21%D=1/29%OT=22%CT=1%CU=33388%PV=Y%DS=1%DC=D%G=Y%M=A0B3CC%TM=51
OS:07C427%P=x86_64-unknown-linux-gnu)SEQ(SP=108%GCD=1%ISR=10E%TI=Z%CI=Z%II=
OS:I%TS=8)OPS(O1=M5B4ST11NW7%O2=M5B4ST11NW7%O3=M5B4NNT11NW7%O4=M5B4ST11NW7%
OS:O5=M5B4ST11NW7%O6=M5B4ST11)WIN(W1=3890%W2=3890%W3=3890%W4=3890%W5=3890%W
OS:6=3890)ECN(R=Y%DF=Y%T=40%W=3908%O=M5B4NNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=
OS:O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD
OS:=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0
OS:%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1
OS:(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI
OS:=N%T=40%CD=S)
Network Distance: 1 hop
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.03 seconds
From the result obtained after executing the command, we found that the OS of the remote host is Linux.
How to perform Port Scanning Using Nmap?
Using Nmap ports can be scanned by the following command:
$ nmap <ipaddress>
The result of this command is:
preethi@preethi:~$ nmap 10.30.52.160
Starting Nmap 5.21 ( http://nmap.org ) at 2013-01-29 18:36 IST
Nmap scan report for 10.30.52.160
Host is up (0.00035s latency).
Not shown: 995 closed ports
PORT STATE SERVICE
22/tcp open ssh
23/tcp open telnet
80/tcp open http
139/tcp open netbios-ssn
445/tcp open microsoft-ds
Nmap done: 1 IP address (1 host up) scanned in 0.09 seconds