In Nmap 7.991, how does -sV pin an open port to a specific nginx version, and what do --version-intensity and softmatch change?
answer
- port scan first, then interrogation
- banner wait, registered probes, rarity
- regex match lines extract the version
- default intensity is in the middle
basics
~20 sAfter the port scan, -sV listens for a banner on each open port, tries probes registered to that port, then others up to the chosen rarity. A match line in nmap-service-probes extracts product and version. Default intensity is 7.
solid answer
~40 s`-sV` runs after ports are found. For TCP, Nmap first connects and waits for a banner (the NULL probe), then sends the probes that `nmap-service-probes` registers for that port, then other probes in rarity order up to `--version-intensity`, which runs 0 to 9 with a default of **7**. `--version-light` is intensity 2 and `--version-all` is 9. Each reply is tested against `match` lines: a regex on `Server: nginx/1.18.0` yields product nginx, version 1.18.0 and a CPE. A `softmatch` names only the service, so Nmap continues with probes that can identify it. Results are reported as what the service said, not proof of what is installed. (Nmap 7.991.)
code
bash · 2 lines# Inventory check inside the signed scope: version detection on two web ports.
nmap -sV --version-intensity 5 --version-trace -p 80,443 web01.example.internalgo deeper
Know that -sV asks open ports what is running and recall the default intensity of 7.
Explain the order of the banner wait, registered probes and rarity, plus match lines and softmatch, and what --version-light and --version-all change.
Defend how far to trust a reported version and what in the service's logs shows a version scan was made.
Set the standard intensity and exclusion policy for recurring inventory scans, and who approves any deviation.
## What -sV is for A port table says only that something answers. The service name beside it comes from a **lookup of the port number** in `nmap-services`, which is usually right and sometimes not: people run services on strange ports. `-sV` (version detection) interrogates the open ports to learn the protocol, application name, version, host name, device type and OS family, plus a CPE identifier where it can. `-A` switches it on together with other features. Version detection also probes `open|filtered` TCP and UDP ports and changes them to open when a response arrives. ## Probe order, step by step For each open TCP port Nmap follows the logic in its probe database: 1. **The NULL probe.** It connects and sends nothing, waiting for a banner (the shipped file waits up to six seconds). Many services, such as SSH and SMTP, announce themselves immediately. 2. **Probes registered to the port.** The `ports` and `sslports` lines of each probe say which port numbers it suits. These run **regardless of intensity**, so the web request probe `GetRequest` is tried against 80 and 8080 and the DNS probes against 53. 3. **Remaining probes by rarity**, lowest first, up to the intensity. 4. **TLS handling.** If SSL is detected and Nmap was built with OpenSSL, it opens the TLS session and runs the same logic inside it, so output reads `ssl/http`. The shipped database does not probe TCP ports 9100 to 9107 (an `Exclude` line), because some printers print whatever they receive; `--allports` overrides it. ## Intensity and rarity Every probe has a **rarity** from 1 (effective against many common services) to 9 (rarely useful). The intensity chooses how far down that ranking Nmap goes. | Option | Intensity | Effect | |---|---|---| | `--version-light` | 2 | Much faster, slightly less likely to identify services | | (default) | 7 | The default for `--version-intensity` | | `--version-all` | 9 | Every probe tried against each port | | `--version-intensity n` | 0 to 9 | Any value in between | Higher intensity identifies more but takes longer, and means more traffic hitting each service. ## How an nginx version is pinned The database holds `match` lines: a regular expression over the response plus templates that fill `p/` (product), `v/` (version), `i/` (extra info) and `cpe:`. For nginx there are several. One matches a header of the form `Server: nginx/<version>` and extracts the version; another matches a bare `Server: nginx` header and yields the product with no version; others match nginx's default error pages. The reply to a plain `GET / HTTP/1.0` is enough. The result then appears in the `VERSION` column, and host-wide details land on the `Service Info` line. ## Anatomy of the probe database The file `nmap-service-probes` is plain text. A `Probe` line names the protocol, a name and the bytes to send. Directives that follow tune it: `rarity` (1 to 9), `ports` and `sslports` (where the probe is registered), `totalwaitms` (how long to wait for a reply), `tcpwrappedms` (the short-close threshold on the NULL probe), `fallback` (which other probes' match lines to try as well), and a series of `match` and `softmatch` lines. One `Exclude` line at the top lists ports never probed. Reading the file is the fastest way to answer "why did Nmap call this nginx", because the answer is a line you can grep. ## Soft matches A `softmatch` line recognises a service but cannot extract a product or version. Nmap records the service name, then keeps probing, but **only** with probes that can identify that service, unless `--version-all` is used. A hard `match` ends the process. ## Reading the result - The version is **what the service said or what a pattern extracted**. A distribution may back-port a fix into a build that still reports an old version number, so the number is not a verdict about whether the host is vulnerable; how a vulnerability scanner turns a version into a finding is a separate subject. - With `-sV`, a name from the port lookup alone carries a trailing `?` (for example `http-proxy?`), and the XML records `method="table"` for such a name and `method="probed"` where a probe matched. - A response that matches nothing makes Nmap print a service fingerprint it asks you to submit. ## Defender's side The service's own logs show a version scan as a short run of differently shaped first requests (an empty connection, a plain `GET`, an `OPTIONS`) from one source against one port. In an authorised audit, tell the SOC the scan window and the source address so the pattern is explained rather than escalated. ## Common mistakes - Assuming intensity is a hard limit on every probe: registered probes run regardless. - Treating the version column as a package inventory. - Assuming the service name came from a probe when it is a table lookup.
- Why would you choose --version-light for a production inventory?Light mode is intensity 2: fewer probes, faster and less traffic to each service, at the cost of a slightly lower chance of identifying unusual services. Agree the choice in the scope document, because a less thorough scan can leave a service unidentified.
- What does the VERSION column record when a service is behind TLS?Nmap negotiates TLS, runs its probes inside the session and prefixes the service name with ssl/, such as ssl/http. The reported product and version describe the service behind the encryption, not the TLS library.
- Why does -sV skip TCP port 9100 by default?The database's Exclude line covers TCP 9100 to 9107 because some printers print whatever arrives on that port, so version probes could waste paper. The --allports option removes the exclusion, which should only happen with the owner's approval.
- Intensity is a hard cap on every probe.
- --version-all is the default intensity.
- The service name always comes from probing.
- VERSION shows the installed package version.
- A softmatch is a failed probe, so Nmap gives up.
Assumes Nmap 7.991: default --version-intensity 7, light mode as intensity 2, and the probe order read in its reference guide and source.