Table of Contents


Description

Nmap (Network Mapper) is an open-source tool used for network discovery, port scanning, and vulnerability assessment. It helps identify live hosts, open ports, services, and operating system details on a network.


Favorites

My go-to favorite scans to run ASAP.

The Overseer - Quick TCP, full TCP and a UDP scan all in one!
sudo nmap <target> -sC -sV -Pn && sleep 5 && sudo nmap <target> -Pn -p- && sleep 5 && sudo nmap <target> -sU -Pn

The Overseer with a file
sudo nmap -iL <TARGET FILE> -sC -sV -Pn && sleep 5 && sudo nmap -iL <TARGET FILE> -Pn -p- && sleep 5 && sudo nmap -iL <TARGET FILE> -sU -Pn

Quick TCP scan
sudo nmap <target> -sV -sC -Pn -vvv

Quick full TCP scan
sudo nmap <target> -p- -Pn -vvv

Full targeted TCP scan
sudo nmap <target> -p <port> -A -Pn -vvv

UDP scan
sudo nmap <target> -sU -Pn -vvv
If it’s too long, add -F flag to scan the essentials


Tips

Default scans

The default Nmap scan type (when run as a normal user) is a TCP Connect scan (-sT), which completes the full three-way handshake with each target port.
When using sudo, Nmap defaults to a SYN scan (-sS), which is faster and stealthier because it sends SYN packets but does not complete the handshake.

Try to always run sudo as -sS is better.

Aggressive scan
-A is a combination of multiple Nmap flags:

  • -sC → Runs default NSE scripts.
  • -sV → Detects service versions.
  • -O → Detects the operating system.
  • --traceroute → Maps network paths.

It’s an aggressive scan, providing detailed info but making more noise on the network.

IPs in a file

You can specify host IPs in a file and run them with -iL like so - sudo nmap -iL ips.txt -sC -sV -Pn.

TTL OS version verification

Besides using -O to know the OS version of the scanned host we can also look at the TTL in the scan.
Based on it, we can tell what OS is running on the target host.0

Operating SystemTCP/UDP
Windows 95/98/ME32
Linux64
FreeBSD
64
Mac OS X64
Windows XP, 7, 8, 2004, 2008128
Solaris255

You can find way more examples here.

Filtering

Sometimes there is ICMP filtering in the firewalls. Try to always use the -Pn flag.
It that’s not the case, maybe it’s because ARP pings. use --disable-arp-ping to test that.

If you encounter further issues, consider --packet-trace and --reason flags for troubleshooting.

Saving results

You can save your scans by adding -oA <filename> to your command.

tcpwrapped

When Nmap reports tcpwrapped it usually means the port is open, but the service immediately closes the connection from Nmap, often because TCP Wrappers or similar access controls reject the connection.

TCP Wrappers are a host-based access-control mechanism used mainly on older Unix/Linux systems. They can restrict network access to services based on the connecting IP address, using /etc/hosts.allow and /etc/hosts.deny.


Proxychains

nmap works with proxy chains, although a bit gimmicy, it’s pretty slow, work best - if not only - with -sT scans, and can give false-positives when you run a more complicated commands.

Here are some examples of usage:
sudo proxychains nmap -sT --top-ports=20 -Pn 172.16.194.240
proxychains nmap 172.16.5.19 -p3389 -sT -v -Pn
proxychains nmap -v -sn 172.16.5.1-200
sudo proxychains nmap -vvv -sT --top-ports=20 -Pn 172.16.50.217


States

Explanation of states of the scans.

StateDescription
openThis indicates that the connection to the scanned port has been established. These connections can be TCP connections, UDP datagrams as well as SCTP associations.
closedWhen the port is shown as closed, the TCP protocol indicates that the packet we received back contains an RST flag. This scanning method can also be used to determine if our target is alive or not.
filteredNmap cannot correctly identify whether the scanned port is open or closed because either no response is returned from the target for the port or we get an error code from the target.
unfilteredThis state of a port only occurs during the TCP-ACK scan and means that the port is accessible, but it cannot be determined whether it is open or closed.
open|filteredIf we do not get a response for a specific port, Nmap will set it to that state. This indicates that a firewall or packet filter may protect the port.
closed|filteredThis state only occurs in the IP ID idle scans and indicates that it was impossible to determine if the scanned port is closed or filtered by a firewall.

Timing templates

Details of scanning when using the -T flag like -T4 for example.

T0T1T2T3T4T5
NameParanoidSneakyPoliteNormalAggressiveInsane
min-rtt-timeout100ms100ms100ms100ms100ms50ms
max-rtt-timeout5m15s10s10s1250ms300ms
initial-rtt-timeout5m15s1s1s500ms250ms
max-retries1010101062
Initial (and minimum) scan delay (—scan-delay)5m15s400ms000
Maximum TCP scan delay5m15s1s1s10ms5ms
Maximum UDP scan delay5m15s1s1s1s1s
host-timeout0000015m
script-timeout0000010m
min-parallelismDynamicNotAffectedByTimingTemplates
max-parallelism111DynamicDynamicDynamic
min-hostgroupDynamicNotAffectedByTimingTemplates
max-hostgroupDynamicNotAffectedByTimingTemplates
min-rateNoMinimumRateLimit
max-rateNoMaximumRateLimit
defeat-rst-ratelimitNotEnabledByDefault

Scripts

Nmap Scripting Engine (NSE) is another handy feature of Nmap. It provides us with the possibility to create scripts in Lua for interaction with certain services. There are a total of 14 categories into which these scripts can be divided:

CategoryDescription
authDetermination of authentication credentials.
broadcastScripts, which are used for host discovery by broadcasting and the discovered hosts, can be automatically added to the remaining scans.
bruteExecutes scripts that try to log in to the respective service by brute-forcing with credentials.
defaultDefault scripts executed by using the -sC option.
discoveryEvaluation of accessible services.
dosThese scripts are used to check services for denial of service vulnerabilities and are used less as it harms the services.
exploitThis category of scripts tries to exploit known vulnerabilities for the scanned port.
externalScripts that use external services for further processing.
fuzzerThis uses scripts to identify vulnerabilities and unexpected packet handling by sending different fields, which can take much time.
intrusiveIntrusive scripts that could negatively affect the target system.
malwareChecks if some malware infects the target system.
safeDefensive scripts that do not perform intrusive and destructive access.
versionExtension for service detection.
vulnIdentification of specific vulnerabilities.

We have several ways to define the desired scripts in nmap

Default scripts

-sC flag runs default scripts.
sudo nmap <target> -sC

Specific scripts category

sudo nmap <target> --script <category>

Defined scripts

This will run all scripts that contain “smb” in their name.
sudo nmap <target> --script "*smb*"

This will run directly specified scripts.
sudo nmap <target> --script <script-name>,<script-name>


References

https://nmap.org/book/performance-timing-templates.html - Time templates
https://ostechnix.com/identify-operating-system-ttl-ping/ - TTL OS versions cheatsheet