Intermediate · Scanning with nmap · topic 14 of 35 · 20 min
Service, version and OS detection, and NSE
Explanation
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.
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 tracerouteReading 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".
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 scriptDetection 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
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)
Which nmap flag detects service versions?
NSE is…
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
Read more (free)
Related help
Before this, learn
This topic builds on these. If something here feels new, open them first.
Related topics
- Ports and protocolsCyber Security: from zero to SOC analyst · Networking for security
- Enumeration: digging into servicesEnumeration and vulnerability assessment
- Cross-site scripting (XSS)Web attacks and their fixes
- Node.js basicsJavaScript Programming (language in depth) · Performance and Node.js
- Metasploit basics (in the lab)Deeper lab skills: passwords, privilege, Metasploit, wireless
- Vulnerability scanners: OpenVAS and Nessus (concepts)Enumeration and vulnerability assessment
Questions people ask about this
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.
Which port does HTTPS use by default?Related
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.
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
- This is the last topic of “Scanning with nmap”. The module exam comes next.
- Module 4 exam: scanning with nmap · 12 questions · 20 min, without help. 3 topics of this module still to finish first.
- Then the next module, Enumeration and vulnerability assessment. 35 topics left in the course before the final exam.