NMAP: Advanced Scan

Let us talk about using advanced scans in NMAP. The idea here is to present different scans from the default ones presented in the post: NMAP: TCP and UDP port mapping.

This way, we will present ways of scanning that can identify services using an unorthodox approach.

If this is your first time on Nmap, we suggest you return to the previous post concerning nmap.

See more posts from our NMAP tutorial:

Article 01 – NMAP: TCP and UDP port mapping

Article 02 – NMAP: Advanced Scan

Article 03 – NMAP: Identify the version of a service

This article presents:

TCP NULL Scan

The first type of scan we will look at is TCP NULL. In this scanning mode, we will use a null TCP flag header.

Therefore, NMAP sets the field which refers to the flags to zero. For that, we will use the “-sN” option. See the command below.

sudo nmap -sN -p 80 192.168.0.1
Escaneamento TCP NULL para a porta 80 do host 192.168.0.1
TCP NULL scan to port 80 host 192.168.0.1
Escaneamento TCP NULL para as portas 20 a 25  do host 192.168.0.1
TCP NULL scan for ports 20 to 25 of host 192.168.0.1

We can see in Wireshark that the TCP segments flag field sent to the target is null.

Additionally, in this type of scan, the target’s lack of response Indicates that the port is open or filtered by a firewall.

Wireshark: TCP flags = NULL
Wireshark: TCP flags = NULL 

Scan TCP FIN

This scan sends TCP segments with the FIN flag. Thus, when receiving a FIN flag for a port that is not open, the system responds with a RST.

Thus, if a target does not respond to a specific port, it will be considered open or filtered.

At first, Nmap has no way of knowing if the port is open or if there is some security mechanism preventing the response.

The command below uses the -sF  option to indicate that a segment with the FIN flag should be sent.

sudo -sF -p 20-25 192.168.0.1
Escaneamento usando TCP FIN para as portas 20 a 25.
Scan using TCP FIN for ports 20 to 25.
Wireshark: verificação da flag FIN do escaneamento TCP FIN
Wireshark: Scan FIN flag

TCP ACK Scan

We now present a different scan in terms of its functioning and its purpose. First, let us talk about the objective of our scan, which is to get information if the firewall is stateful.

That way, we do not want to know whether the doors are open. Instead, we want to check if there is an RST response to our query.

If the target responds with RST, we assume we do not have a stateful firewall rule before the analyzed service.

Therefore, this scan is helpful to verify if we have correctly configured the firewall.

Example of a scan using ACK to a host at address 192.168.0.1 and ports 20 to 25:

sudo nmap -sA -p 20-25 192.168.0.1
nmap scan tcp ack
nmap scan tcp ack

We can see that the answer was that the ports were not filtered. Thus, we can deduce that we do not have a stateful firewall between source and destination.

In addition, we can check the TCP segments with ACK in the Wireshark and the corresponding responses with RST.

Therefore, this result proves the thesis that the system is responding to ACK indiscriminately.

Wireshark nmap scan tcp ack
Wireshark nmap scan tcp ack

TCP Window Scan

Now let us look at a scan similar to TCP ACK that checks if the RST response uses a positive window size. This behavior is expected on some systems and can be used to check if a port is open.

Thus, in some systems, we have an RST with a positive window size, while for closed ports, we have an RST with a size 0. Therefore, it is an unusual way to obtain information about services using an advanced Scan in NMAP.

Example of a scan using TCP WINDOW for a host at address 192.168.0.1 and ports 20 to 25:

sudo nmap -sW -p 20-25 192.168.0.1
nmap RST Window
nmap RST Window. Podemos verificar que esse sistema não responde com tamanho de janela diferente.
nmap RST Window. We can see that this system does not respond with different window size.

Advanced NMAP Scan with multiple flags

Another scanning option is to send a TCP segment with all flags set or a combination of more than one flag. In this way, we can verify how the target system will respond to this type of segment.

It is noteworthy that it does not matter the order in which we insert the flags in the command. This behavior occurs because the command only marks which flags we will use in the TCP segment.

Example of a scan using multiple TCP flags for a host at address 192.168.0.1 and ports 20 to 25:

sudo nmap -scanflags URGACKPSHRSTSYNFIN -p 20-25 192.168.0.1
NMAP Escaneamento com várias flags
NMAP Scan with multiple flags
Wireshark Escaneamento com várias flags
Wireshark Scanning with multiple flags

See more posts from our NMAP tutorial:

Article 01 – NMAP: TCP and UDP port mapping

Article 02 – NMAP: Advanced Scan

Article 03 – NMAP: Identify the version of a service

Juliana Mascarenhas

Data Scientist and Master in Computer Modeling by LNCC.
Computer Engineer