Nmap - Intro

Introduction
Nmap, short for "Network Mapper," is a powerful open-source tool primarily used for network discovery and security auditing. It's designed to scan networks, identify hosts, services, and their corresponding ports, and analyze network configurations. It is generally used for footprinting or reconnaissance.
Uses
Enumerating targets
Live hosts discovery
Open ports identification
Reverse-DNS lookup
Port scanning
Version detection
OS detection
Running scripts
Vulnerability assessment
Security auditing
Nmap scanning types
UDP scan (-sU)
This scan sends packets to every ports of the target system to identify open UDP ports. UDP does not establish a connection before sending data, making UDP scanning more challenging compared to TCP scanning.
Basic command:
nmap -sU [target]
Ping scan (-sP)
It is used only to find out whether the host is available or not, i.e. for host discovery and not for port scanning.
Basic command:
nmap -sP [target]
TCP SYN scan (-sS)
In a scan, also known as a half-open scan, Nmap sends SYN packets to target ports and analyzes the responses to determine the state of the ports. It is stealthier as it does not complete TCP handshake. For the SYN packets, if an is received, the port is marked as open, while if a is received, it's marked as closed. If no response is received, the port is considered filtered.
Basic command:
nmap -sS [target]
TCP Connect scan (-sT)
It is a TCP scan that establishes full TCP connection with the target port by initiating a three-way handshake. If a connection is successfully established (i.e., the target responds with a SYN-ACK packet), the scanning tool considers the port to be open. If no response or an error response (such as a RST packet) is received, the port is considered closed.
Basic command:
nmap -sT [target]
Null scan (-sN)
This scan sends packets with no flags set. For this, closed ports respond with an RST packet, while open ports ignore the packet.
Basic command:
nmap -sN [target]
FIN scan (-sF)
It sends FIN packets to the target. If a port is closed, an RST packet is sent back. If no response is received, the port is considered open or filtered.
Basic commands:
nmap -sF [target]
XMAS scan (-sX)
It sends malformed packets with the flags like FIN, PSH, and URG. It is similar to a FIN scan, and relies on the lack of response to determine open ports, by responding with RST for closed port.
Basic command:
nmap -sX [target]
Custom Scan
If you want to experiment with a new TCP flag combination beyond the built-in TCP scan types, you can do so using --scanflags
. For instance, if you want to set SYN, RST, and FIN simultaneously, you can do so using --scanflags RSTSYNFIN
.
Basic command:
nmap --scanflags [custom_flags] [target]
Last updated