04. Nmap OS and Service Version Scanning
Nmap Command Notes
1. nmap -O 192.168.0.1
- Purpose: OS Detection
- Explanation:
-O: Enables Operating System Detection using TCP/IP stack fingerprinting.- Nmap analyzes subtle differences in how the target OS responds to specific network probes to identify the operating system and version.
- OS detection is not guaranteed if the target is behind a firewall or has restrictive network configurations.
- Requirements:
- OS detection requires root/admin privileges for accurate results.
- Use Case:
- Identifying the operating system of the target, which helps tailor further attacks or assessments.
- Example Command:
- Output:
- Reports the OS name, version, and other details like device type (e.g., router, firewall).
2. nmap -O -sV 192.168.0.1
- Purpose: OS Detection with Version Detection
- Explanation:
-O: Enables OS detection.-sV: Enables Service Version Detection.- It probes open ports and attempts to determine the versions of services running on those ports (e.g., Apache 2.4.41).
- Combining these options provides detailed information about the operating system and service versions.
- Use Case:
- Ideal for fingerprinting the target system's operating system and the exact versions of running services.
-
Example Command:
-
Output:
- OS details, version information of services running on open ports, and device type.
3. nmap -A 192.168.0.1 -p-
- Purpose: Aggressive Scan with Full Port Range
- Explanation:
-A: Enables Aggressive Scan.- Aggressive scans perform:
- OS detection (
-O) - Service version detection (
-sV) - Script scanning (
--script=default) - Traceroute analysis
- OS detection (
- Aggressive scans perform:
-p-: Scans all 65,535 ports (both TCP and UDP).- Without specifying
-p-, Nmap scans only the top 1,000 ports by default.
- Without specifying
- Use Case:
- Used for comprehensive reconnaissance to gather extensive information about the target.
- Detects all open ports, services, and operating system details.
- Caution:
- This is a noisy scan—easily detected by intrusion detection systems (IDS) or firewalls.
- Scanning all ports can take significant time depending on the network and system configurations.
-
Example Command:
-
Output:
- List of all open ports.
- Detailed version information about services.
- OS fingerprinting results.
- Script output (e.g., vulnerabilities, service configurations).
- Traceroute details.
Summary Table¶
| Command | Purpose | Key Options | Details Gathered | Use Case |
|---|---|---|---|---|
nmap -O 192.168.0.1 |
OS Detection | -O |
Target OS details | Identify operating system |
nmap -O -sV 192.168.0.1 |
OS + Service Version Detection | -O, -sV |
OS + Version info of running services | Detailed OS and service scan |
nmap -A 192.168.0.1 -p- |
Aggressive Full Port Scan | -A, -p- |
OS, services, scripts, traceroute | Comprehensive reconnaissance |
Key Notes:¶
- Use
-Ofor OS detection, but ensure you have root privileges. - Combine
-Owith-sVfor both OS and service version details. - Use
-Awith-p-for a full and aggressive scan, but be aware of detection risks.