Skip to content
Visual explainer 5h to learn 4 steps

Service & version enumeration

Identify service versions and configurations on lab hosts with nmap scripts.

By Invicly Tech, , in Ethical Hacking & Penetration Testing. About 9 minutes to read.

Topic 10 of 32

In short

Once ports are known, enumeration identifies the exact service and version behind each one. nmap's version detection and safe NSE scripts gather this detail on lab hosts, which later maps to known vulnerabilities.

Explained simply

Knowing that port 21 is open is a start. Knowing that it runs vsftpd version 2.3.4 with anonymous login allowed is much more useful. Enumeration means asking each open port politely for details: what software, which version, which settings.

Services often introduce themselves. When you connect, many send a short greeting called a banner, like "220 (vsFTPd 2.3.4)" or "SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.10". nmap's version detection (-sV) goes further: it sends a series of probes and compares the answers with a large database of known services.

nmap also has a scripting engine called NSE. Scripts can read a web page title, list SSH encryption options, show SMB settings, or check whether FTP allows anonymous login. Scripts are grouped into categories, and some are safe while others are intrusive or even harmful, so you choose them deliberately.

Everything you learn here feeds the next step: matching versions to known vulnerabilities. Write down each detail together with the command that produced it, so the evidence is ready for the report.

Press Play on a diagram to walk through it one step at a time.

FlowService enumeration
  1. Step 1
    Version detect

    Identify service and version.

  2. Step 2
    Run NSE

    Use safe info scripts.

  3. Step 3
    Enumerate

    Gather service details.

  4. Step 4
    Record

    Note findings and evidence.

MapWhat to enumerate on common ports
Open port
  • 21 FTP
    • Banner and version
    • Anonymous login?
  • 22 SSH
    • Version
    • Algorithms and host key
  • 80/443 HTTP(S)
    • Title and headers
    • Methods
    • Certificate
  • 445 SMB
    • OS and domain
    • Signing required?
    • Anonymous shares
  • 3306/5432 DB
    • Should it be exposed?
    • Version
    • Authentication
  • 161/udp SNMP
    • Version
    • Default community string

In depth

How version detection works

For each open port, nmap first waits a few seconds for a banner (the NULL probe), because many services talk first. If that is not enough, it sends probes from its nmap-service-probes file, starting with the ones most likely for that port, and matches the replies against thousands of patterns. A match can name the product, version, extra info such as the OS, and a CPE (Common Platform Enumeration) name used later for vulnerability lookups.

--version-intensity from 0 to 9 sets how many probes to try; the default is 7. --version-light is 2 and --version-all is 9. A question mark after a service name, such as http?, means nmap is guessing. tcpwrapped means the connection opened and then closed without data, often because a wrapper or firewall only accepts certain clients.

  • NULL probe: listen for a banner first
  • Then targeted probes from nmap-service-probes
  • Output includes product, version and CPE
  • --version-intensity 0-9, default 7
  • tcpwrapped: connection closed with no data

NSE script categories and how to choose

NSE scripts belong to categories: auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version and vuln. -sC runs the default category, which is useful but, as the nmap documentation warns, includes some scripts considered intrusive. For a cautious first pass, run --script "default and safe". Avoid brute, dos, exploit, fuzzer and intrusive unless the RoE clearly allows them; dos scripts can crash services.

Ask before you run: nmap --script-help ftp-anon shows what a script does and its categories. Scripts in external send data to third-party services, which matters if the scope or confidentiality terms forbid that. -A is a shortcut for -O, -sV, -sC and --traceroute, which is convenient in a lab but noisy on a real engagement.

CompareNSE categories by risk
Usually fine in scope
  • safe
  • version
  • discovery (most scripts)
  • default and safe together
Check the RoE first
  • default (some intrusive)
  • auth
  • vuln
  • external (sends data out)
Only with explicit approval
  • brute
  • intrusive
  • exploit
  • dos (can crash services)

Enumerating common services

Each common service has a few standard questions. FTP (21): does anonymous login work (ftp-anon)? SSH (22): which version and algorithms (ssh2-enum-algos, ssh-hostkey)? HTTP and HTTPS (80, 443, 8080): the title, headers, methods and certificate (http-title, http-headers, http-methods, ssl-cert). SMB (139, 445): OS, signing and shares (smb-os-discovery, smb2-security-mode; smbclient -L //host -N for an anonymous share list). Databases such as MySQL (3306), PostgreSQL (5432) and Redis (6379): are they exposed at all, and do they require a password? SNMP (UDP 161): does it accept a default community string like public?

Manual checks complement nmap. nc -nv host 21 shows the raw FTP banner, and curl -sI shows web headers. Comparing manual and automated results catches mistakes.

  • FTP: anonymous login, banner
  • SSH: version, algorithms, auth methods
  • HTTP(S): title, headers, methods, certificate
  • SMB: OS, signing, anonymous shares
  • Databases and SNMP: exposed? default credentials?

Trusting versions and helping defenders

Version strings can mislead. Linux distributions backport security fixes: Ubuntu may ship a patched package that still reports the old upstream version, with the patch shown only in the suffix (for example 3ubuntu0.10). Admins can also change banners on purpose. So record the full banner exactly as seen, and treat the version as a strong hint, not proof.

For defenders, enumeration findings map to clear fixes: disable anonymous FTP or replace FTP with SFTP; require SMB signing and disable SMBv1; never expose database ports to untrusted networks; move SNMP to v3 with authentication; remove unnecessary version details from banners. Defenders can also spot NSE in logs: its HTTP requests carry a default user agent that mentions the Nmap Scripting Engine, and version probes leave unusual entries in service logs.

Learn it in 4 short steps

About 1h 15m each. Track them with a timer in your plan.

  1. 1
    Run version detection~1h 15m
  2. 2
    Use safe NSE scripts~1h 15m
  3. 3
    Enumerate common services~1h 15m
  4. 4
    Note findings and their evidence~1h 15m

Key points

  • Version detection names the service behind a port.
  • NSE scripts gather extra detail safely.
  • Accurate versions enable vulnerability mapping.
  • Document each finding with its evidence.

Key terms

Tap a card to flip it. 0/4 known

Examples

bash
# Against a lab host you are authorised to test
nmap -sV 192.168.56.10            # service and version
nmap -sV --script=default 192.168.56.10   # safe NSE scripts

Run only against lab hosts in scope.

Enumerate Metasploitable 2 in the lab

Metasploitable 2 is your own lab VM at 192.168.56.103. Step 1: run version detection on the ports found earlier, with only default-and-safe scripts. Step 2: read the results: vsftpd 2.3.4 on 21, OpenSSH 4.7p1 on 22, Apache 2.2.8 on 80, MySQL 5.0.51a on 3306, and many more. Step 3: ftp-anon reports whether anonymous FTP is allowed. Step 4: grab one banner by hand to double-check. Step 5: everything goes into scans/ for the report.

bash
T=192.168.56.103
PORTS=$(grep -oP '\d+/open' scans/tcp-all.gnmap | cut -d/ -f1 | sort -un | paste -sd,)
sudo nmap -sV --script "default and safe" -p "$PORTS" -oA scans/svc "$T"

# check one banner by hand
nc -nv -w 3 "$T" 21
# 220 (vsFTPd 2.3.4)

Enumerate SMB on a lab host safely

Step 1: run the SMB discovery scripts, which only read information. Step 2: smb-os-discovery shows the OS, computer name and workgroup or domain. Step 3: smb2-security-mode shows whether message signing is required; "enabled but not required" is a finding, because unsigned SMB allows relay attacks. Step 4: list shares with a null (anonymous) session. Step 5: recommendations: require signing, disable SMBv1, and remove anonymous share access.

bash
T=192.168.56.103
sudo nmap -p 139,445 --script smb-os-discovery,smb2-security-mode "$T"
smbclient -L "//$T" -N        # anonymous share list
# Look for: Message signing enabled but not required
# and shares readable without a password

Quick reference

  • nmap -sV detects service and version; add --version-all for stubborn ports
  • -sC equals --script=default; --script "default and safe" is more cautious
  • nmap --script-help NAME shows what a script does and its categories
  • Avoid brute, dos, exploit and intrusive scripts unless the RoE allows them
  • nc -nv HOST PORT grabs a raw banner by hand
  • smbclient -L //HOST -N lists SMB shares without a password
  • A version string is a hint: distributions backport fixes without changing it

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1What does tcpwrapped mean in nmap output?

Question 2

2Which NSE category should you avoid unless explicitly approved, because it can crash services?

Question 3

3nmap reports OpenSSH 8.9p1 Ubuntu-3ubuntu0.10. Why can't you assume every 8.9p1 CVE applies?

Question 4

4smb2-security-mode reports "Message signing enabled but not required". What do you recommend?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Run version detection on your DVWA or Juice Shop container and write down the product and version for each open port.

  2. Exercise 2medium

    List all NSE scripts for SSH and HTTP that are in the safe category, then run two of them against a lab host.

  3. Exercise 3hard

    Write a script that reads an nmap XML file and prints a CSV of host, port, service, product and version for every open port.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

What is the difference between -sV and -A in nmap?
-sV only detects service versions. -A also turns on OS detection, default scripts and traceroute, which gives more information but is noisier.
Are nmap NSE scripts safe to run?
Many are, but not all. Check categories with --script-help, prefer safe and default scripts, and only run intrusive, brute or dos scripts when the rules of engagement allow them.
Why does nmap show a different version than the software really runs?
Banners can be changed by admins, and Linux distributions often backport fixes without changing the upstream version number. Confirm with the package version or the vendor's advisory.

Go deeper

ShareXLinkedInWhatsApp