skip to content

OS Fingerprinting

OS detection guesses the operating system from how its TCP/IP stack answers crafted probes, matched against nmap-os-db. Interviewers ask about confidence scores and the open-plus-closed-port rule.

on this pageshow

questions

5

In Nmap 7.991, how does the -O option arrive at an operating-system guess, and why is the answer a guess and not a fact?

level: juniorimportance: must knowfreq 45%

answer

  1. Crafted packets, not banners
  2. Quirks of the IP stack
  3. A reference file of known stacks
  4. Whatever device answers is measured
  5. Hint with a confidence

basics

~20 s

Nmap -O sends crafted TCP, UDP and ICMP probes and compares how the target's IP stack answers with the reference fingerprints in nmap-os-db. That is an inference from behaviour, so the result is a hint with a confidence, not a fact.

solid answer

~40 s

`-O` makes Nmap send a round of about sixteen probes: six TCP SYNs with differing options to an open port, two ICMP echo requests, an ECN probe, TCP packets with unusual flag combinations, and a UDP datagram to a closed port. It records initial sequence numbers, TCP options and their order, initial window sizes, IP ID behaviour and TTL, then scores them against the thousands of reference fingerprints in `nmap-os-db`. A perfect match prints `OS details`; otherwise Nmap lists near-matches with a percentage. It is a guess because it measures the stack that answered the probes, not the host's configuration, so a middlebox, an unusual stack or a missing database entry gives a wrong or empty result.

go deeper

for a junior

Recall that -O sends probes and compares the stack's answers with nmap-os-db, and that the output is a guess with a percentage.

for a middle

Explain what is measured (sequence numbers, options, windows, IP ID, TTL), the probe sets by name, and why a perfect match is still only the best database entry.

for a senior

Say what the measurement cannot distinguish: the answering device against the host, and a family against a patch level. Name the evidence you would add before an inventory field changes.

for a principal

Frame fingerprinting as one weak signal in an asset-data model: define which fields are observed, which are authoritative, and which decisions need a verified value.

## What -O is for Remote OS detection answers a plain inventory question: what kind of thing is at this address? In an audit it separates a printer from a router, a Windows desktop from a Unix server, a firewall from a load balancer, and it can flag an unmanaged device that should not be on a segment. You switch it on with `-O`; `-A` turns it on together with version detection, script scanning and traceroute. Because it sends crafted raw packets it needs raw-packet privilege (root on Unix, Npcap on Windows), and Nmap stops with an error if an unprivileged user asks for it. ## What one probe round sends Nmap does not read a banner and does not ask the host anything. It measures how the TCP/IP stack answers a fixed set of packets. The probe sets carry the same names as the tests in the reference database: | Probe set | Count | Sent to | What it measures | |---|---|---|---| | SEQ, OPS, WIN (with T1) | 6 TCP SYNs, 100 ms apart | an open TCP port | initial sequence number behaviour, TCP options and their order, initial window sizes, IP ID and timestamp behaviour | | IE | 2 ICMP echo requests | the host | IP ID behaviour, don't-fragment bit, ICMP response code | | ECN | 1 TCP probe | an open TCP port | whether the stack answers explicit congestion notification | | T2 to T4 | 3 TCP probes: no flags, an odd flag mix, a bare ACK | an open TCP port | flags, sequence and acknowledgement numbers, window, options | | T5 to T7 | 3 TCP probes | a closed TCP port | the same fields, as a closed port answers | | U1 | 1 UDP datagram | a closed UDP port | the ICMP port-unreachable reply and which fields of the original it echoes back | That is about sixteen packets in one round. If no perfect match comes back, Nmap repeats the round, up to five times by default when conditions are good. ## How the comparison works Each response becomes a test result, and the set of results is the observed fingerprint. Every entry in `nmap-os-db` holds the same tests as expected values, ranges or alternatives, plus a free-form description, one or more `Class` lines (vendor, OS family, generation, device type) and usually a CPE name. The first element of the file, `MatchPoints`, says how many points each test is worth; tests that are numerous and correlated, such as TTL and don't-fragment, count for less than a test used once, such as the timestamp. - A **perfect match** means every test fell inside the entry's allowed values. - Otherwise Nmap scores each entry by the share of weighted points that matched and keeps the best, ignoring anything below 85%. - The percentage printed beside a guess is that weighted share, not a calibrated probability. ## Why the answer is a guess 1. **It measures the stack that answered.** A firewall, NAT device, proxy or load balancer in the path can answer instead of the host you meant to identify. 2. **The database is finite.** A new release, an appliance or an unusual build may have no entry, so the nearest entry is printed with a lower score or nothing is printed. 3. **Stacks overlap.** Neighbouring versions of one product often behave identically, so a result can name a family or a range of generations, and rarely a patch level. 4. **Conditions distort the measurement.** Packet loss, a long path, probes filtered in transit, or no open or no closed port to aim at all lower the quality of the fingerprint. 5. **Configuration moves behaviour.** A stack tuned away from its defaults can match a different entry or none. ## What to do with the result - Record it as an observation with its source (Nmap 7.991 `-O`), date, device class and percentage, never as the confirmed OS. - Confirm from an authoritative source before any decision that depends on the version: configuration management, the vendor console, or an authenticated check by the system owner. - Treat a second scan that agrees with the first as the same measurement repeated, not as verification, because it crosses the same path and meets the same device. - Keep the written scope and authorisation with the result: the probes are crafted packets to a host you are permitted to test.

  • What else does -O enable besides the OS name, and how far should you trust it?
    With verbose output it also prints a TCP sequence predictability classification, the IP ID generation class and an uptime guess taken from the TCP timestamp option. The uptime guess can be wrong because the counter may not start at zero or may wrap, so the reference guide shows it only in verbose mode. All three are inferences like the OS match.
  • Why does Nmap refuse -O for an ordinary unprivileged user?
    The probes are hand-built packets with unusual options and flag combinations, and only raw-packet access can send them; the operating system's normal sockets cannot. Nmap therefore stops with an error saying that OS scanning requires root privileges (or Npcap on Windows) rather than running a weaker version.

Identifying a handwriting sample by comparing it with a file of known samples: you get a likelihood from how many traits match, never a signature, and a ghost-writer or a forger can mislead the comparison.

  • Nmap -O reads the operating system out of service banners.
  • A printed OS match is a verified fact about the host.
  • A 100% match proves no other product could produce that fingerprint.
  • An unprivileged user can run -O the same way as root.
  • A second scan that agrees confirms the first result.
open as a page

Why does Nmap 7.991 OS detection want one open and one closed TCP port, and what does --osscan-limit do when a host lacks them?

level: middleimportance: must knowfreq 33%

basics

~20 s

Some probe sets need a listening TCP port and others a closed one, so without both Nmap has fewer tests to compare. It still runs and warns that results may be unreliable; with --osscan-limit it skips that host instead.

open as a page

An Nmap 7.991 -O run prints 'No exact OS matches' with no candidate list; what does that mean, and what does --osscan-guess add?

level: middleimportance: should knowfreq 28%

basics

~20 s

'No exact OS matches' means no reference fingerprint fitted every measured test. --osscan-guess (alias --fuzzy) makes Nmap list near-matches as 'Aggressive OS guesses', each with a percentage that is a similarity score, not a probability.

open as a page

An Nmap -O scan of an unidentified appliance's address returns a firewall's OS match; why might something else sit behind it, and how do you record the entry?

level: seniorimportance: should knowfreq 20%

basics

~20 s

Each probe is answered by whichever device holds the address, so a firewall, proxy or load balancer can be fingerprinted instead of the host behind it. Record the result as an observed hint with its confidence and source, then verify it another way.

open as a page

What does an Nmap -O probe round look like in the target's firewall and sensor logs, and what does a result expose about an Internet-facing host?

level: seniorimportance: nice to knowfreq 11%

basics

~20 s

A round is about sixteen crafted TCP, ICMP and UDP probes from one source in a short burst, repeated if nothing matches. It shows in firewall and sensor logs, not application logs, and exposes the device class and OS family.

open as a page