427 words
2 minutes
Complete Nmap Guide: Network reconnaissance from scratch

What is Nmap?#

Nmap (Network Mapper) is the most widely used reconnaissance tool in the pentesting world. It lets you discover active hosts, open ports, running services and even the operating system of your targets.

⚠️ Disclaimer: Use Nmap only on networks and systems for which you have explicit authorization. Unauthorized scanning is illegal.


Installation#

Terminal window
# Debian/Ubuntu/Kali
sudo apt install nmap -y
# Check version
nmap --version

Essential scan types#

1. Basic port scan#

Terminal window
# Scan the 1000 most common ports
nmap 192.168.1.1
# Scan a specific host with DNS resolution
nmap scanme.nmap.org

2. SYN scan (Half-Open) — The most used#

Terminal window
# Requires root privileges
sudo nmap -sS 192.168.1.1
# With version detection
sudo nmap -sS -sV 192.168.1.1

The SYN scan sends a SYN packet and waits for SYN-ACK without completing the TCP handshake. It’s faster and less detectable than a full scan.

3. Scan all ports#

Terminal window
# Scan all 65535 ports
sudo nmap -p- 192.168.1.1
# With aggressive speed
sudo nmap -p- --min-rate 5000 192.168.1.1

4. OS and version detection#

Terminal window
# Operating system detection
sudo nmap -O 192.168.1.1
# Aggressive scan (OS + version + scripts + traceroute)
sudo nmap -A 192.168.1.1

NSE Scripts (Nmap Scripting Engine)#

NSE scripts are one of Nmap’s most powerful features.

Terminal window
# Scan with default scripts
nmap -sC 192.168.1.1
# List all available scripts
ls /usr/share/nmap/scripts/
# Use a specific script
nmap --script=http-title 192.168.1.1
# Vulnerability scripts
nmap --script=vuln 192.168.1.1
# SMB script (very useful on Windows networks)
nmap --script=smb-vuln-ms17-010 192.168.1.1

My reconnaissance workflow#

This is the flow I use in pentests and CTFs:

Terminal window
# 1. Quick discovery of active hosts
sudo nmap -sn 192.168.1.0/24
# 2. Quick port scan (top 1000)
sudo nmap -sS -T4 --open 192.168.1.1
# 3. Full port scan
sudo nmap -p- --min-rate 5000 -T4 192.168.1.1 -oN ports.txt
# 4. Deep scan of discovered ports
PORTS=$(cat ports.txt | grep "^[0-9]" | cut -d'/' -f1 | tr '\n' ',')
sudo nmap -sC -sV -p$PORTS 192.168.1.1 -oN services.txt

Firewall / IDS Evasion#

Terminal window
# Packet fragmentation
sudo nmap -f 192.168.1.1
# Using decoys
sudo nmap -D RND:10 192.168.1.1
# Slow scan to evade IDS
sudo nmap -T1 192.168.1.1
# MAC address spoofing
sudo nmap --spoof-mac 0 192.168.1.1
# Scan from a specific source IP
sudo nmap -S 192.168.1.100 -e eth0 192.168.1.1

Saving results#

Terminal window
# Normal format
nmap -oN result.txt 192.168.1.1
# XML format (to import into other tools)
nmap -oX result.xml 192.168.1.1
# Grepable format
nmap -oG result.gnmap 192.168.1.1
# All formats at once
nmap -oA result 192.168.1.1

Quick reference#

FlagDescription
-sSSYN scan (stealth)
-sUUDP scan
-p-All ports
-sVVersion detection
-sCDefault scripts
-OOS detection
-AAggressive mode
-T4Fast speed
--openOnly open ports
-oNText output

In upcoming posts we’ll see how to combine Nmap with other tools like Gobuster, Nikto and Burp Suite for complete web reconnaissance.

Happy hacking 🔐

Complete Nmap Guide: Network reconnaissance from scratch
https://oguiii.xyz/en/posts/guia-nmap-completa/
Author
Oguiii
Published at
2025-01-15
License
CC BY-NC-SA 4.0