How Nmap Scanner works?
Nmap is a very effective port scanner, known as the de-facto tool for finding open ports and services.Nmap performs several phases in order to achieve its purpose:
IP Address Lookup or IP Locator is a tool that allows you to see where your IP address is located. Find my network router. It can also be used to lookup other IPs and find their IP Location. A WhoIs Lookup is a tool that will give you pertinent information about the owner of the IP address. IP address lookup, location, proxy detection, email tracing, IP hiding tips, blacklist check, speed test, and forums. Find, get, and show my IP address.
Engineer wrote:I used QFinder while connected to my home network.It recognized the NAS but when digging around for more info, it doesn't show me the external IP address. When accessing the web interface of my router, it shows the NAS is connected, but doesn't give me the external IP address eithe.
1. Nmap host discovery
The first phase of a port scan is host discovery. Here the scanner attempts to check if the target host is live before actually probing for open ports. This phase is needed mainly when scanning a large range of IP addresses in order to optimize the time for the whole scan. It does not make any sense to waste time probing for open ports on a 'dead' host (ex. there is no server at a given IP).However, this phase can sometimes lead to not finding some open ports because the host 'liveness' cannot be always correctly detected (ex. because of firewalls which permit access only to a certain port and drop everything else). In this case you have the option 'Don't ping host' (or Nmap -Pn) which skips the host discovery phase and just does the port scanning.
2. Open ports detection
In order to determine if a TCP port is open, Nmap takes advantage of the Three way handshake mechanism used by TCP to establish a connection between a client and a server.There are two main methods for detecting open TCP ports:
Connect-Scan (Nmap -sT)
In this case Nmap does a full three-way handshake with the target server, establishing a full TCP connection. The sequence of packets for this type of scan is:SYN
, SYN-ACK
, ACK
, RST
.The advantage of this method is that it does not require root/administrator access on the client machine, while the disadvantage is that it is rather noisy and the server can log the connections attempted from other hosts.
SYN-Scan (Nmap -sS)
This is the default scanning method, also enabled in our scanner. In this method, Nmap does a half-open TCP connection, knowing that the port is open immediately after the server responds withSYN-ACK
. The sequence of packets in this case is: SYN
,However, this phase can sometimes lead to not finding some open ports because the host 'liveness' cannot be always correctly detected (ex. because of firewalls which permit access only to a certain port and drop everything else). In this case you have the option 'Don't ping host' (or Nmap -Pn) which skips the host discovery phase and just does the port scanning.
2. Open ports detection
In order to determine if a TCP port is open, Nmap takes advantage of the Three way handshake mechanism used by TCP to establish a connection between a client and a server.There are two main methods for detecting open TCP ports:
Connect-Scan (Nmap -sT)
In this case Nmap does a full three-way handshake with the target server, establishing a full TCP connection. The sequence of packets for this type of scan is:SYN
, SYN-ACK
, ACK
, RST
.The advantage of this method is that it does not require root/administrator access on the client machine, while the disadvantage is that it is rather noisy and the server can log the connections attempted from other hosts.
SYN-Scan (Nmap -sS)
This is the default scanning method, also enabled in our scanner. In this method, Nmap does a half-open TCP connection, knowing that the port is open immediately after the server responds withSYN-ACK
. The sequence of packets in this case is: SYN
, SYN-ACK
, RST
. The advantage of this method is that it is stealthier than a Connect-Scan but it does require Nmap to run with root/administrator privileges (because it needs to create low-level raw sockets to send the individual packets, instead of leaving the kernel stack to do the connection).
2. Nmap service detection
After Nmap has found a list of ports, it can do a more in-depth check to determine the exact type of service that is running on that port, including its version. This is needed because it is possible for common services to run on non-standard ports (ex. a web server running on port 32566). Service detection is enabled with the commandNmap -sV
.Nmap does service detection by sending a number of predefined probes for various protocols to the target port in order to see if it responds accordingly. For example, it sends:
- SSL CLIENT HELLO - to check for SSL services
- HTTP GET request - to check for HTTP service
- SIP OPTIONS - to check for SIP/RTSP protocol
- and many others
A brief history of Nmap Port Scanner
Nmap was first introduced in September 1997 in the article The Art of Scanning, in the well known Phrack Magazine, by its author - Fyodor (Gordon Lyon).Since it got a lot of notoriety, Nmap has been referenced in multiple books and it was also used in several artistic movies as a hacking tool (ex. The Matrix).