Host discovery & network mapping workflow
The recon sequence that is in the beggining of any penetration test.
nmap·1 min read··INE Certification
Network mapping answers three questions in order: what’s alive, what ports are open on it, and what’s actually running there. Jumping straight to a full port scan across a whole subnet works, but a discovery pass first is faster and quieter. Nmap is usually the go-to.
Host discovery
## Ping scan
sudo nmap -sn <TARGET_IP/NETWORK>
## ARP scan
netdiscover -i eth1 -r <TARGET_IP/NETWORK>
A good default: ping sweep for a fast first pass, then TCP SYN discovery to catch hosts that block ICMP (most Windows machines) before committing to a full port scan. Scanning ports on hosts that are down wastes time and resources.
Port scanning
nmap <TARGET_IP>
## Skip ping
nmap -Pn <TARGET_IP>
## Scan all ports
nmap -p- <TARGET_IP>
## Port 80 only scan
nmap -p 80 <TARGET_IP>
## Custom list of ports scan
nmap -p 80,445,3389,8080 <TARGET_IP>
## Custom ports range scan
nmap -p1-2000 <TARGET_IP>
## Fast mode & verbose scan
nmap -F <TARGET_IP> -v
## UDP scan
nmap -sU <TARGET_IP>
Service, OS and script detection
## Service scan
nmap -sV <TARGET_IP>
## Service + O.S. detection scan
sudo nmap -sV -O <TARGET_IP>
## Default Scripts scan
nmap -sC <TARGET_IP>
nmap -Pn -F -sV -O -sC <TARGET_IP>
## Aggressive scan
nmap -Pn -F -A <TARGET_IP>
Timing and output
## Timing (T0=slow ... T5=insanely fast) scan
nmap -Pn -F -T5 -sV -O -sC <TARGET_IP> -v
## Output scan
nmap -Pn -F -oN outputfile.txt <TARGET_IP>
nmap -Pn -F -oX outputfile.xml <TARGET_IP>
## Output to all formats
nmap -Pn -sV -sC -O -oA outputfile <TARGET_IP>
nmap -Pn -sV -sC -O -oA outputfile <TARGET_IP>
nmap -A -oA outputfile <TARGET_IP>
Related
- Nmap: scan types, NSE scripts and evasion in depth
- Host discovery quick tools: other tools for basic discovery
- Passive information gathering & OSINT: what to do before touching the target
- From service version to working exploit: next step once you have services and versions
- Metasploit Framework: importing scan results into the MSF database