Skip to content

Intermediate · Scanning with nmap · topic 14 of 35 · 20 min

Service, version and OS detection, and NSE

Explanation

nmap can go beyond open/closed: -sV finds the service and version on each port, -O guesses the operating system, and the Nmap Scripting Engine (NSE) runs small scripts for extra checks. These turn a port list into a detailed picture — and into a to-do list for the defender too.

From "open" to "what exactly"

An open port tells you a door is unlocked. Version detection tells you what is behind it. The -sV flag makes nmap talk to each open port and work out the service and, often, its exact version. This is the single most useful upgrade to a basic scan.

bash
nmap -sV 192.168.56.102        # detect service and version on open ports
nmap -sV -O 192.168.56.102     # also guess the operating system
nmap -A 192.168.56.102         # aggressive: -sV, -O, default scripts and traceroute
Service, version and OS detection against an authorised lab target.

Reading version output

A -sV result line might read "80/tcp open http Apache httpd 2.4.49". That tells you the port, that it is open, the service (http) and the exact software and version (Apache 2.4.49). With the version in hand, a tester checks whether that version has known issues (the next module covers CVEs). A defender reads the same line as "we are advertising our exact version — let us hide that".

The Nmap Scripting Engine (NSE)

NSE lets nmap run small scripts for extra tasks: checking for a specific known issue, grabbing a banner, listing website directories, and more. Scripts are grouped into categories such as "default", "safe", "discovery" and "vuln".

bash
nmap -sC 192.168.56.102                 # run the default script set
nmap --script safe 192.168.56.102       # run only scripts marked "safe"
nmap --script http-title 192.168.56.102 # run one named script
Running NSE scripts. Prefer "safe"/"default" scripts; some categories are intrusive.
Careful: Some NSE categories, such as "vuln" or "intrusive", actively probe and can disturb a service. On real engagements, only run scripts allowed by the rules of engagement, and prefer "safe" and "default" unless told otherwise. In your own lab you can experiment freely.

Detection and defence

Detection: version probes and scripts send extra, unusual requests that stand out in logs and to an IDS. Defence: hide or fake version banners, patch so a known version is not a liability, disable services you do not need, and watch for script-like traffic. Every version a server reveals is a hint; a good defender reveals as little as possible.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Service, version and OS detection, and NSE · 1/7

open → what exactly?

An open port is a door; version detection says what is behind it.

Prefer a video by a teacher? Find free videos on “nmap service version detection sV nse scripts tutorial” on YouTube ↗

In real life: Turning a port into a plan

A tester scans a lab web server with -sV and reads "Apache httpd 2.4.49". She notes the version, then (in the next phase) checks whether that version has a published issue. In her report she writes two lines: the finding (an outdated, known-vulnerable web server version is exposed) and the fix (update the web server and hide the version banner). The version string did the work of pointing both attack and defence.

Practice (0/3 done)

Task 1 · Question

Which nmap flag detects service versions?

Task 2 · Question

NSE is…

Task 3 · Practice

You scanned a lab host with -sV and found "21/tcp open ftp vsftpd 2.3.4". Write a two-line finding: the attacker view and the defender fix.

Quick quiz

Question 1

1.-O in nmap attempts to…

Question 2

2.Which NSE category is safest to run on a sensitive target?

Question 3

3.Why is a revealed version string valuable to an attacker?

Question 4

4.A matching defence is to…

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

-O in nmap attempts to…

Answer: Guess the operating system

-O does OS detection.

Which NSE category is safest to run on a sensitive target?

Answer: safe

The "safe" category avoids disruptive probes.

Why is a revealed version string valuable to an attacker?

Answer: It lets them check for known issues in that exact version

An exact version can be matched against known vulnerabilities.

A matching defence is to…

Answer: Hide/patch versions and disable unused services

Reveal less, patch, and reduce the attack surface.

Why save nmap output with -oA?Related

Answer: It keeps evidence and notes for the report

Saved output is your evidence and reference for the report.

From nmap scan types

Why does the service version matter?Related

Answer: It tells you whether that exact software has known issues

A specific version lets a tester check for known weaknesses.

From Ports, services and what scanning does

Which port does HTTPS use by default?Related

Answer: 443

HTTPS uses TCP 443 (and UDP 443 for HTTP/3).

From Ports and protocols

Which service, if it allows a zone transfer, can leak a whole domain map?Related

Answer: DNS

A misconfigured DNS server allowing zone transfers reveals all its records.

From Enumeration: digging into services

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. This is the last topic of “Scanning with nmap”. The module exam comes next.
  2. Module 4 exam: scanning with nmap · 12 questions · 20 min, without help. 3 topics of this module still to finish first.
  3. Then the next module, Enumeration and vulnerability assessment. 35 topics left in the course before the final exam.

← Previous: nmap scan types