COMP-221 · Lesson 6 of 12 · 20 min
Service and operating system fingerprinting
▶ Video coming soon A video version of this lesson is on the way.
A list of open ports is a list of doors. Fingerprinting tells you what is behind each one. On Wednesday, October 7, Tobias ran version detection against Prairiefold's external hosts and found that the port numbers had been telling the truth about most services, and not about all of them. The legacy file transfer server, for one, answered on port 22 with a software version older than some of the interns at Ironwhistle.
This lesson covers banner grabbing (objective 2.1), operating system fingerprinting, service discovery and protocol enumeration (objective 2.2), and the Nmap Scripting Engine (objective 2.4). It also covers sniffing IoT and operational technology protocols, which objective 2.1 lists under network sniffing, because identifying those devices is a fingerprinting problem with extra safety rules.
What fingerprinting means
Fingerprinting identifies the product, version and configuration of a service, or the family and version of an operating system, from how it behaves. The goal is precision: not just "a web server" but which server software and version, on which operating system, with which modules. Precise identification lets the team match services to known vulnerabilities later, prioritize unsupported software and spot configuration weaknesses.
Fingerprints vary in how much they can be trusted. A service's self-description can be changed or hidden; its behaviour under unusual requests is harder to fake; agreement between several independent sources is strongest. Good testers record not just what they think a service is, but how confident they are and why.
Banner grabbing
Many services announce themselves when a client connects. SSH servers send a version string before anything else; SMTP and FTP servers send a greeting line; web servers include a Server header in responses. Banner grabbing means connecting and recording that announcement. It is simple, fast and often enough to identify a service, but banners are self-reported and administrators can change or suppress them.
# Connect and read whatever the service sends first (SSH, FTP and SMTP greet immediately)
nc -nv 203.0.113.40 22
# Fetch only the response headers from a web server
curl -sI https://www.prairiefold.example/
# Inspect a TLS service: certificate, protocol and cipher negotiated
openssl s_client -connect 203.0.113.44:3389 -servername 203.0.113.44 </dev/null(UNKNOWN) [203.0.113.40] 22 (ssh) open SSH-2.0-OpenSSH_7.4 HTTP/2 200 server: nginx content-type: text/html; charset=utf-8 strict-transport-security: max-age=31536000
The SSH banner on the legacy file transfer server, OpenSSH 7.4, pointed to software released at the end of 2016. On its own that was a hypothesis: some operating system vendors backport security fixes without changing the version string, so a banner can look older than the code really is. Version detection and the operating system fingerprint would help decide.
Nmap version detection
Nmap's version detection (-sV) goes beyond banners. For each open port it sends a sequence of probes, from a simple wait for a greeting to protocol-specific requests, and compares the responses to a database of thousands of match patterns. When a pattern matches, Nmap reports the product, version and sometimes extra information such as the operating system or device type. The --version-intensity option, from 0 to 9, controls how many probes are tried; higher intensity identifies more services but takes longer and sends more traffic.
sudo nmap -sV -p 22,443,3389,8443 203.0.113.40,41,44Nmap scan report for sftp-statements.prairiefold.example (203.0.113.40) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4 (protocol 2.0) Nmap scan report for 203.0.113.41 PORT STATE SERVICE VERSION 443/tcp open ssl/http (firewall vendor) web management interface 8443/tcp open ssl/http (firewall vendor) SSL VPN portal Nmap scan report for 203.0.113.44 PORT STATE SERVICE VERSION 443/tcp open ssl/http Microsoft IIS httpd 10.0 3389/tcp open ms-wbt-server Microsoft Terminal Services Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Two details in this output are worth knowing. The ssl/ prefix means Nmap detected TLS and probed the service inside it. The CPE (Common Platform Enumeration) identifier is a standardized name for a product that vulnerability databases also use, which makes it easy to carry results into the vulnerability analysis covered in COMP-222.
Operating system fingerprinting
Operating systems implement TCP/IP slightly differently. The initial time-to-live (TTL) on packets, the TCP window size, the order and values of TCP options, how the stack responds to odd flag combinations, and how it numbers IP identification fields all vary. Active OS fingerprinting sends a set of crafted probes and compares the responses to a database. Nmap's -O option does this; it needs at least one open and one closed port on the target to work well, and it reports a best guess with a confidence level when no exact match exists.
Passive OS fingerprinting draws the same kind of inference from traffic already on the network, without sending probes. A quick rule of thumb uses the TTL: many Linux and Unix-like systems start at 64, Windows at 128, and many network devices at 255. A received TTL slightly below one of those values, after a few router hops, suggests the family. TTL alone is weak evidence, because it can be changed, but combined with window size and options it narrows the field.
| Clue | Typical values | Strength |
|---|---|---|
| Initial TTL | 64 (Linux and many Unix-like systems), 128 (Windows), 255 (many network devices) | Weak alone; easy to change |
| TCP window size and options | Distinctive combinations per OS family and version | Moderate |
| Responses to crafted probes (Nmap -O) | Matched against a large database | Strong when the match is exact |
| Service banners and behaviour | IIS implies Windows; some SSH builds name the distribution | Moderate to strong |
| Certificate details and host names | Default Windows certificates on RDP name the host | Supporting evidence |
The -A option combines OS detection, version detection, default scripts and traceroute in one run. It is convenient for a small number of hosts but sends a lot of traffic, so Ironwhistle used it only on hosts where the extra detail was needed, and never on fragile devices.
The Nmap Scripting Engine
The Nmap Scripting Engine (NSE) extends Nmap with scripts, written in the Lua language, that perform specific checks: retrieving a web page title, reading a certificate, listing SMB shares, querying SNMP, checking for particular vulnerabilities and much more. Scripts are grouped into categories, and choosing categories carefully is how a tester keeps NSE inside the rules of engagement.
| Category | What its scripts do | Use in an engagement |
|---|---|---|
| default | A curated set run with -sC: fast, useful, generally safe | Routine enumeration |
| safe | Scripts not expected to crash services or be intrusive | Preferred on production systems |
| discovery | Gather more information about the network and services | Enumeration |
| version | Extend version detection; run automatically with -sV | Fingerprinting |
| auth | Check authentication settings, such as anonymous access | Enumeration with care |
| vuln | Check for specific known vulnerabilities | Vulnerability discovery, per the rules of engagement |
| intrusive | May crash services, use significant resources or be seen as attacks | Only with explicit approval |
| brute | Guess credentials | Only with explicit approval and lockout awareness |
| dos | May cause denial of service | Normally prohibited |
| exploit | Actively exploit a vulnerability | Outside reconnaissance; only with explicit approval |
| broadcast and external | Discover hosts by broadcast; query third-party services | Know that external scripts send data to third parties |
# Default scripts plus version detection (equivalent to -sC -sV)
sudo nmap -sC -sV -p 443,3389 203.0.113.44
# Specific safe scripts by name
sudo nmap -p 443 --script ssl-cert,ssl-enum-ciphers,http-title 203.0.113.30
# Scripts that are both in the discovery category and safe
sudo nmap -p 445 --script "discovery and safe" 192.0.2.20sudo nmap -p 3389 --script rdp-ntlm-info,ssl-cert 203.0.113.44PORT STATE SERVICE 3389/tcp open ms-wbt-server | rdp-ntlm-info: | Target_Name: PFVENDOR | NetBIOS_Computer_Name: PF-VENDOR-RS01 | DNS_Computer_Name: PF-VENDOR-RS01 | Product_Version: 10.0.17763 |_ System_Time: 2026-10-07T15:12:44+00:00 | ssl-cert: Subject: commonName=PF-VENDOR-RS01 | Not valid before: 2022-03-02T18:40:11 |_Not valid after: 2026-09-01T18:40:11
This output gave Gwendolyn's team what they needed to trace the server: a host name, a domain name that matched the vendor support arrangement, and a certificate created in March 2022. The Windows build number pointed to Windows Server 2019, matching the Shodan screenshot. Three independent sources now agreed, so Tobias recorded the identification with high confidence.
Protocol enumeration
Objective 2.2 lists protocol enumeration: asking a service, through its own protocol, to describe its capabilities and configuration. It overlaps with fingerprinting but goes further.
| Protocol | What enumeration can reveal | Common tools |
|---|---|---|
| TLS | Supported protocol versions, cipher suites, certificate chain and expiry | NSE ssl-enum-ciphers, sslscan, testssl.sh |
| SSH | Key exchange and cipher algorithms, host key types, authentication methods | NSE ssh2-enum-algos, ssh-auth-methods |
| SMTP | Supported commands and extensions, whether VRFY or EXPN reveal users | NSE smtp-commands, manual connection |
| SNMP | With a valid community string: system description, interfaces, routing tables, sometimes accounts and software | snmpwalk, onesixtyone, NSE snmp scripts |
| SMB | Dialects supported, signing requirements, host and domain names | NSE smb-protocols, smb2-security-mode |
| HTTP | Methods allowed, headers, technologies | NSE http-methods, http-headers, whatweb |
Protocol enumeration produced several of Prairiefold's external findings. The file transfer server offered SSH key exchange algorithms that current guidance treats as weak. The old VPN portal accepted TLS 1.0. Internally, SNMP on network printers and the building automation controller answered to the vendor's default community string, which allowed anyone on the network to read their configuration. Ironwhistle used only read requests, as the rules of engagement required; writing to SNMP could change device configuration and was prohibited.
IoT and operational technology
Networks increasingly contain devices that are not computers in the usual sense: cameras, badge readers, building automation controllers, industrial controllers. They often speak specialized protocols, such as BACnet for building automation, Modbus for industrial control, and MQTT for IoT messaging, and many of them were never designed to withstand scanning. A routine version scan can crash an old programmable logic controller or a building system.
| Protocol | Typical port | Used for |
|---|---|---|
| Modbus/TCP | 502/tcp | Industrial controllers and sensors |
| BACnet/IP | 47808/udp | Building automation: heating, ventilation, lighting |
| MQTT | 1883/tcp (8883 with TLS) | IoT publish and subscribe messaging |
| DNP3 | 20000/tcp | Utility and SCADA systems |
| EtherNet/IP | 44818/tcp | Industrial automation |
The safe approach is to start passively. Capturing traffic with Wireshark, which decodes these protocols, shows which devices talk to which, what they are and often their firmware, without sending a packet. Active queries come later, if at all, with the device owner present and the lightest possible probes. At Branch 07, a short capture showed BACnet traffic from the building automation controller found by ARP in lesson 4. Ironwhistle identified it from the capture alone and left it untouched apart from the single SNMP read already agreed. Attacks on specialized systems are covered in COMP-223, PenTest+: Attacks and Exploits.
Recording fingerprints so others can use them
A fingerprint is only useful if the next person can trust it. Ana Sokolova-Reyes reviewed the fingerprint records every Friday, and she rejected any entry that did not say where its information came from. Her template had one row per service, and the confidence column was not optional. A record that said "Windows" with no source might be a guess from a TTL; a record that said "Windows Server 2019, build from rdp-ntlm-info, matched by Shodan screenshot and certificate dates, high confidence" could go straight into the report and into vulnerability analysis.
| Field | Example for 203.0.113.44, port 3389 |
|---|---|
| Service and product | Remote Desktop, Microsoft Terminal Services |
| Version or build | 10.0.17763 (Windows Server 2019) |
| Sources | Nmap -sV; NSE rdp-ntlm-info and ssl-cert; Shodan record from July 2026 |
| Confidence | High: three independent sources agree |
| Notes | Self-signed certificate expired September 1, 2026; host name PF-VENDOR-RS01 |
| Evidence files | E1-sV-20261007 (XML), E1-nse-rdp-20261007 (normal) |
Recording confidence honestly also protects the client from false alarms. A version guessed from a banner alone, flagged as critical in a report, can send an operations team chasing a vulnerability that a backported patch had already fixed. Ana's rule was that anything below high confidence went into the report as "indicated" rather than "confirmed", with the steps needed to confirm it, so the reader always knew which findings rested on firm ground.
Fingerprints also age. Software is upgraded, services move and banners change. Every record carried the date of the scan, and before the final report Tobias re-ran version detection on the external hosts to confirm that nothing had changed since early October. Two things had: the remote support server had been switched off, and the old VPN portal now redirected to the current one. Both changes were recorded as remediation already in progress, which is good news a report should include.
Defending against fingerprinting
Hiding banners and version strings slows down casual attackers and automated scanners but does not stop determined ones, because behaviour-based fingerprinting still works. The real defences are to run supported, patched software, to expose as few services as possible, to disable weak protocol versions and algorithms, and to change default credentials and community strings. Banner minimization is still worth recommending as part of hardening; it just should not be the only recommendation.
Worked problem
How confident are we?
For 203.0.113.40, Tobias has: an SSH banner reading OpenSSH 7.4; Nmap -O guessing a Linux 3.x kernel with 90 percent confidence; an archived job posting mentioning a statement delivery server; and a CT log certificate for sftp-statements first issued in 2017. How should he record the fingerprint?
Show solution
- Product and version: OpenSSH 7.4, from the banner and confirmed by version detection.
- Operating system: Linux, probably an older enterprise distribution, from -O and consistent with the banner era. Exact distribution unknown.
- Role: statement delivery file transfer server, from the job posting and hostname.
- Caveat: the distribution may have backported fixes; vulnerability matching must account for that.
Answer: High confidence in the service and role, moderate confidence in the operating system, with a note about possible backported patches.
Common mistakes
MistakeTrusting a banner as proof of the exact version.
InsteadTreat banners as one source; confirm with behaviour and other evidence, and remember backported fixes.
MistakeRunning every NSE script with --script all.
InsteadChoose categories such as default and safe, and run intrusive, brute or vuln scripts only with approval.
MistakeUsing -A against every host.
InsteadUse it selectively; it sends a lot of traffic and can disturb fragile devices.
MistakeVersion-scanning industrial or building controllers like servers.
InsteadStart with passive capture and probe lightly only with the owner's agreement.
MistakeRecommending only banner hiding.
InsteadRecommend patching, reducing exposure and removing weak protocols as well.
Summary and key terms
- Fingerprinting identifies products, versions and operating systems from behaviour, with recorded confidence.
- Banner grabbing is quick but self-reported; tools include netcat, curl and openssl.
- Nmap -sV matches probe responses to a database and reports CPE identifiers.
- Nmap -O compares TCP/IP stack behaviour to known fingerprints; TTL gives a rough passive clue.
- NSE scripts are chosen by category; default and safe suit production, while intrusive, brute, dos and exploit need approval.
- Protocol enumeration reveals TLS, SSH, SMTP, SNMP, SMB and HTTP capabilities and weaknesses.
- IoT and OT devices are identified passively first because active probing can disrupt them.
- Fingerprinting
- Identifying software or operating systems from how they behave.
- Banner grabbing
- Connecting to a service and recording the identification it sends.
- Version detection
- Nmap's probing of services to determine product and version (-sV).
- CPE
- Common Platform Enumeration, a standard naming scheme for products and versions.
- NSE
- The Nmap Scripting Engine, which runs Lua scripts for specific checks.
- Passive OS fingerprinting
- Inferring an operating system from observed traffic without sending probes.
- Community string
- The shared secret used for SNMP versions 1 and 2c, often left at a default value.
- BACnet
- A protocol used for building automation and control networks.
Practice problems
Work each problem on paper first, then reveal the answer to check.
A host replies with a TTL of 125 from a few hops away. What operating system family does that suggest?
Show answer
Windows, whose initial TTL is usually 128.
Which NSE categories would you avoid on production systems without explicit approval?
Show answer
intrusive, brute, dos, exploit, and usually vuln.
Why might an old-looking version banner not mean the software is vulnerable?
Show answer
Some vendors backport security fixes without changing the upstream version string.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.