Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 37 ยท Auxiliary and Scanning

Service Version Scanners and Banner Grabbing

Learn how version scanners and banner grabbing identify services, what Metasploit's SSH, HTTP and SMB scanners report, and how to hide or verify banners.

An open port tells you something is listening. A version scanner tells you what it is. Knowing "OpenSSH 8.2" or "Apache 2.4.49" lets an assessor check the vendor's advisories and lets a defender see which servers need updates. Metasploit has dozens of small scanner modules for this, each speaking one protocol.

You will meet the idea of a banner (the greeting a service sends), the modules that read them, and how to parse and compare versions in code. The earlier lesson on port scanning produced the list of open ports; this lesson identifies what runs on them.

Banners

Many protocols announce themselves immediately. SSH, FTP and SMTP servers send a line the moment you connect:

TEXT
SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13
220 mail.lab.example ESMTP Postfix (Ubuntu)
220 (vsFTPd 3.0.5)

HTTP needs a request first, then the Server: header names the software. Other services need a protocol handshake before they reveal a version, which is why separate modules exist per protocol.

The common scanner modules

Module Reports
auxiliary/scanner/ssh/ssh_version SSH banner and supported details
auxiliary/scanner/http/http_version Server header
auxiliary/scanner/http/title HTML page title
auxiliary/scanner/ftp/ftp_version FTP banner
auxiliary/scanner/smtp/smtp_version SMTP greeting
auxiliary/scanner/smb/smb_version SMB dialect and OS hints
auxiliary/scanner/mysql/mysql_version MySQL server version
TEXT
msf6 > use auxiliary/scanner/ssh/ssh_version
msf6 auxiliary(scanner/ssh/ssh_version) > set RHOSTS file:lab-hosts.txt
msf6 auxiliary(scanner/ssh/ssh_version) > run
[+] 192.0.2.5:22   - SSH server version: SSH-2.0-OpenSSH_9.6p1 Ubuntu-3ubuntu13
[+] 192.0.2.30:22  - SSH server version: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.5
[*] Scanned 2 of 2 hosts (100% complete)

The output is stored under services, so later services -S OpenSSH filters by name.

Version strings come from the service itself. They can be wrong, or hidden. Backports (Linux distributions fixing a bug without changing the version number) mean "OpenSSH 8.2" might already be patched. Always confirm before reporting.

Parsing banners

You can write a small parser to pull the product and version from a banner. It is also a handy way to understand how scanners build the info column of the services table.

Python Parse banners into product and version

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Comparing against a minimum version

Once versions are extracted, a defender compares them with the minimum safe version for each product. Doing this on your own inventory is a cheap, high-value habit.

Python Flag outdated services

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Note the two versions are compared as number tuples, never as strings: as text, "2.4.9" sorts after "2.4.58".

Fingerprinting beyond banners

When banners are removed, scanners infer the product from behaviour: how a server orders headers, which error pages it returns, which protocol options it supports. Nmap's -sV and Metasploit's scanners both do this, and results come with a confidence level. Treat low-confidence guesses as leads.

Defender actions

  • Remove or generalise banners where possible (ServerTokens Prod, server_tokens off). This only slows enemies; it does not replace patching.
  • Maintain an inventory with versions and compare it with advisories.
  • Close management services (databases, SMB, remote admin) to the internet.
  • Alert on version-scan behaviour: a connection that reads the greeting and disconnects immediately, repeated across hosts.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is a banner?

    Services such as SSH, FTP and SMTP announce their software and version on connect.
  2. 2. Why can a reported version be misleading?

    Backported patches and edited banners both mean the string needs verification.
  3. 3. How should versions be compared in code?

    String comparison puts '2.4.9' after '2.4.58'; numeric tuples compare correctly.
  4. 4. Does hiding the banner replace patching?

    Security through obscurity is not a fix; update the software.

Summary

  • Banners and handshakes reveal product and version; one scanner module per protocol.
  • Results go into services and can be filtered and exported.
  • Backports and edited banners mean versions need confirmation.
  • Compare versions numerically and track them in an inventory.
  • Hide banners only as a minor extra, never instead of patching.

Next: Credential Auditing with Login Scanners