Service Enumeration
Service Enumeration Overview
Purpose:
Identify the application/service and its version.
Use version info to scan for known vulnerabilities and, if possible, analyze the source code.
Exact version numbers allow more precise exploit searches targeting the service and the underlying OS.
Service Version Detection
Initial Steps:
Quick Port Scan:
Run a fast, low-traffic port scan to get an overview of open ports.
Advantages: Lower traffic reduces the chance of detection/blocking by security mechanisms.
Full Port Scan:
After initial discovery, run a full port scan (
p-
) in the background to show all open ports.
Nmap Options:
p-
: Scans all ports.sV
: Performs version detection on the identified open ports.v
/vv
: Increases verbosity (more detailed output; shows open ports as they’re detected).-stats-every=5s
: Displays scan progress every 5 seconds.Additional Options:
Pn
: Disables ICMP echo requests.n
: Disables DNS resolution.-disable-arp-ping
: Disables ARP ping.-packet-trace
: Logs all packets sent/received for debugging or detailed analysis.
Examples:
Basic Version Detection:
With Progress Updates:
Increased Verbosity:
Output Details:
Shows each port’s:
Port number and protocol (e.g., 22/tcp)
State (e.g., open, filtered)
Service name (e.g., ssh, smtp, http)
Version details (e.g., OpenSSH 7.6p1 Ubuntu)
Also includes host information (e.g., MAC Address, OS, CPE identifier).
Banner Grabbing
Process:
Nmap largely relies on service banners for version detection.
If a banner is unavailable, Nmap uses a signature-based matching system (which can slow down the scan).
Limitation:
Automated scans might miss some details if the service does not present its banner or if the banner is modified/removed.
Detailed Example with SMTP:
Nmap Output:
Shows basic info (e.g., port 25 is running Postfix smtpd).
Additional Banner Info from Traffic:
Using TCP packet tracing or manual tools (like
nc
), you can capture the full banner.Example banner from SMTP:
Reveals more detail, such as the Linux distribution (Ubuntu) not fully shown in the Nmap output.
Manual Banner Grabbing & Packet Analysis
Using
nc
(Netcat):Command:
Outcome:
Connects to the SMTP port and retrieves the banner manually.
Banner Example:
220 inlane ESMTP Postfix (Ubuntu)
Using
tcpdump
:Command:
Captured Traffic:
Shows the TCP three-way handshake (SYN, SYN-ACK, ACK).
Illustrates the [PSH-ACK] packet that carries the SMTP banner.
Sequence of Packets:
SYN: Client sends to server.
SYN-ACK: Server responds.
ACK: Client acknowledges.
PSH-ACK: Server sends banner (data push with acknowledgment).
ACK: Client confirms receipt of the banner.
Key Note:
The PSH flag in the TCP header indicates that the data (banner) is being actively pushed to the client.
Summary
Service Enumeration & Version Detection are critical for:
Identifying target service versions for vulnerability assessment.
Allowing more targeted exploits.
Nmap is the primary tool used, with options to:
Scan all ports.
Detect service versions.
Increase verbosity and monitor progress.
Banner Grabbing and Packet Tracing (using tools like
nc
andtcpdump
) can reveal additional details not captured by Nmap’s automated output.
These notes should serve as a quick reference guide to the concepts and commands involved in service enumeration and version detection using Nmap and related tools.