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
# Debian/Ubuntu/Kalisudo apt install nmap -y
# Check versionnmap --versionEssential scan types
1. Basic port scan
# Scan the 1000 most common portsnmap 192.168.1.1
# Scan a specific host with DNS resolutionnmap scanme.nmap.org2. SYN scan (Half-Open) — The most used
# Requires root privilegessudo nmap -sS 192.168.1.1
# With version detectionsudo nmap -sS -sV 192.168.1.1The 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
# Scan all 65535 portssudo nmap -p- 192.168.1.1
# With aggressive speedsudo nmap -p- --min-rate 5000 192.168.1.14. OS and version detection
# Operating system detectionsudo nmap -O 192.168.1.1
# Aggressive scan (OS + version + scripts + traceroute)sudo nmap -A 192.168.1.1NSE Scripts (Nmap Scripting Engine)
NSE scripts are one of Nmap’s most powerful features.
# Scan with default scriptsnmap -sC 192.168.1.1
# List all available scriptsls /usr/share/nmap/scripts/
# Use a specific scriptnmap --script=http-title 192.168.1.1
# Vulnerability scriptsnmap --script=vuln 192.168.1.1
# SMB script (very useful on Windows networks)nmap --script=smb-vuln-ms17-010 192.168.1.1My reconnaissance workflow
This is the flow I use in pentests and CTFs:
# 1. Quick discovery of active hostssudo 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 scansudo nmap -p- --min-rate 5000 -T4 192.168.1.1 -oN ports.txt
# 4. Deep scan of discovered portsPORTS=$(cat ports.txt | grep "^[0-9]" | cut -d'/' -f1 | tr '\n' ',')sudo nmap -sC -sV -p$PORTS 192.168.1.1 -oN services.txtFirewall / IDS Evasion
# Packet fragmentationsudo nmap -f 192.168.1.1
# Using decoyssudo nmap -D RND:10 192.168.1.1
# Slow scan to evade IDSsudo nmap -T1 192.168.1.1
# MAC address spoofingsudo nmap --spoof-mac 0 192.168.1.1
# Scan from a specific source IPsudo nmap -S 192.168.1.100 -e eth0 192.168.1.1Saving results
# Normal formatnmap -oN result.txt 192.168.1.1
# XML format (to import into other tools)nmap -oX result.xml 192.168.1.1
# Grepable formatnmap -oG result.gnmap 192.168.1.1
# All formats at oncenmap -oA result 192.168.1.1Quick reference
| Flag | Description |
|---|---|
-sS | SYN scan (stealth) |
-sU | UDP scan |
-p- | All ports |
-sV | Version detection |
-sC | Default scripts |
-O | OS detection |
-A | Aggressive mode |
-T4 | Fast speed |
--open | Only open ports |
-oN | Text 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/