Skip to content
Tutorials Center
My learning

Topics

Lesson 18 of 36 ยท Service and OS Detection

Service and Version Detection (-sV)

Learn how Nmap -sV turns an open port into a product name and version: probes, match rules, intensity levels and how to read the results safely.

A port scan tells you that port 8080 is open. It does not tell you what is listening there. It could be a web server, a development proxy, a database admin page or something else entirely. Service and version detection answers that question: Nmap talks to the open port, studies the reply and names the product and its version, for example nginx 1.24.0 or OpenSSH 9.6.

For defenders this is one of the most useful features of Nmap. An inventory of "port 443 open on 120 hosts" is almost useless; an inventory of "OpenSSH 7.4 on 14 hosts" tells you exactly what to patch. Everything in this lesson applies only to systems you own or have written permission to test (see Legal and Ethical Scanning).

Nmap cannot run inside this website. The command output below is example output, labelled as such. The runnable examples are small Python stand-ins that reproduce the idea of how Nmap matches replies, so you can understand the mechanism without any scanning.

Turning it on

Add -sV to a scan. Nmap first finds open ports, then probes each one:

Terminal
# Example command (read-only): version detection on two ports of a lab host you own
nmap -sV -p 22,80 192.0.2.10

Example output (illustrative, from a lab machine):

TEXT
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 9.6p1 Ubuntu 3ubuntu13 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.24.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Without -sV, the SERVICE column is only a guess taken from a table of well-known port numbers (80 becomes http). With -sV, the guess is replaced by evidence from the live service, and the column gains a VERSION field.

How detection works

Nmap keeps a database file, nmap-service-probes. It contains probes (data to send) and match rules (patterns that identify a reply). The process for each open TCP port is:

  1. Wait for a banner. Many services (SSH, FTP, SMTP) speak first. Nmap listens for a few seconds. If a banner arrives, it is tested against the match rules.
  2. Send probes. If the port stays silent or the banner is not recognised, Nmap sends probes in turn: a plain NULL probe, an HTTP GET /, a TLS hello, a DNS request and many more. Probes are tried in order of how likely they are for that port number.
  3. Match. Each reply is compared with regular-expression rules. A matching rule gives the product, version, extra information and a CPE identifier.
  4. Fall back. A rule can say "this looks like a service of type X, try the probes tagged for X". If nothing matches, Nmap prints unrecognized and a fingerprint you can submit.
flowchart TD
    A["Open port found"] --> B["Wait for banner"]
    B -->|"banner matches"| M["Report product and version"]
    B -->|"silence or no match"| C["Send next probe"]
    C --> D{"Reply matches a rule?"}
    D -->|yes| M
    D -->|no| E{"More probes at this intensity?"}
    E -->|yes| C
    E -->|no| U["Report unrecognized, print fingerprint"]

Probe-and-match loop of -sV. The intensity setting decides how many probes are allowed.

A match rule in Python

A match rule is a regular expression with capture groups for the version. The stand-in below uses the same idea on a few made-up banners. It is not Nmap's database, only the mechanism.

Python Stand-in: matching banners with rules

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that the Postfix banner has no version number. Nmap would report the product only, because the evidence did not contain a version. Detection can never be more precise than the reply allows.

Intensity: how hard to try

--version-intensity takes a number from 0 to 9. Each probe in the database has a rarity value, and Nmap only sends probes whose rarity is at or below the intensity. The default is 7.

Option Meaning
--version-light Same as intensity 2: only the most likely probes. Fast.
--version-intensity 5 Middle ground.
--version-all Same as intensity 9: every probe. Slow but thorough.
--version-trace Print every probe and reply, useful for learning and debugging.

The next stand-in models the trade-off: a higher intensity can find more services but sends more probes, and so takes more time and creates more traffic.

Python Stand-in: intensity versus number of probes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Reading the output carefully

  • tcpwrapped means the connection was opened and then closed straight away, usually by TCP wrappers or a firewall that decides after the handshake. It is not an application name.
  • ssl/http means TLS was detected and the service behind it speaks HTTP. Nmap tunnels through TLS automatically when OpenSSL support is compiled in.
  • Service Info lines summarise hints such as the host operating system (see OS fingerprinting) and device type.
  • softmatch (only with --version-trace) means Nmap knows the service type but not yet the product, so it narrows the probes.
  • Banners can lie. An administrator can hide or fake a version string. Treat results as strong clues, and confirm with package managers or configuration management on hosts you control.

A useful habit is to save results so you can compare them later, which you will do in Reporting and Automation.

Common mistakes

  • Using -sV on every port of a large network and being surprised it takes hours. Limit the ports (-p) or lower the intensity first.
  • Believing the version string as proof of patch level. Linux distributions backport fixes, so OpenSSH 8.9p1 Ubuntu may already contain fixes that the upstream 8.9 lacked.
  • Running probes against production systems during business hours without telling the owners. Some fragile devices (old printers, industrial controllers) react badly to unusual probes.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does -sV add to a basic port scan?

    -sV (service/version detection) sends probes to open ports and matches the replies against the nmap-service-probes database. The OS is a separate feature (-O).
  2. 2. What does --version-intensity control?

    Each probe has a rarity. Only probes whose rarity is at or below the intensity (0 to 9, default 7) are used, which trades thoroughness against time and traffic.
  3. 3. A scan shows 'tcpwrapped' for a port. What is the best interpretation?

    tcpwrapped means the TCP handshake succeeded and the remote side dropped the connection before sending data, often due to access rules.
  4. 4. Why should you not treat a version string as proof that a host is vulnerable?

    Backporting means the banner can show an older upstream version although the fix is installed. Confirm patch levels with the host's package manager.

Summary

  • -sV identifies the product and version behind each open port by sending probes and matching replies.
  • Match rules are regular expressions with capture groups; the evidence limits how precise the result is.
  • --version-intensity (0 to 9) balances thoroughness against time and traffic.
  • Read tcpwrapped, ssl/http and Service Info lines carefully, and remember that banners can be hidden or backported.

Next: OS Fingerprinting (-O)