nmap
Overview
The nmap
(Network Mapper) command is a security scanner used to discover hosts and services on a computer network, creating a map of the network.
Syntax
nmap [options] target
Common Options
Option | Description |
---|---|
-sS |
TCP SYN scan |
-sT |
TCP connect scan |
-sU |
UDP scan |
-sP |
Ping scan |
-p ports |
Port range |
-F |
Fast scan |
-v |
Verbose output |
-A |
Aggressive scan |
-O |
OS detection |
-sV |
Version detection |
-T0-5 |
Timing template |
-oN file |
Normal output |
Scan Types
Type | Description |
---|---|
TCP SYN | Stealth scan |
TCP Connect | Full connect |
UDP | UDP ports |
FIN | FIN flag set |
XMAS | FIN,PSH,URG |
NULL | No flags set |
ACK | ACK flag only |
Window | Window scan |
Maimon | FIN/ACK probe |
Key Use Cases
- Network discovery
- Port scanning
- Service detection
- OS fingerprinting
- Security auditing
Examples with Explanations
Example 1: Basic Scan
nmap 192.168.1.1
Scan single host
Example 2: Network Scan
nmap 192.168.1.0/24
Scan network range
Example 3: Service Detection
nmap -sV target
Detect service versions
Common Usage Patterns
Quick scan:
nmap -F target
Comprehensive:
nmap -A target
Port range:
nmap -p 1-100 target
Security Considerations
- Permission requirements
- Network impact
- Detection risk
- Legal implications
- Resource usage
Additional Resources
Best Practices
- Permission check
- Timing control
- Output logging
- Target verification
- Regular audits
Output Formats
- Normal (-oN)
- XML (-oX)
- Grepable (-oG)
- Script kiddie (-oS)
- All formats (-oA)
Troubleshooting
- Access denied
- Timeouts
- False positives
- Rate limiting
- Firewall blocks
NSE Scripts
- Default
- Discovery
- Safe
- Intrusive
- All