Skip to content
Tutorials Center
My learning

Topics

Lesson 20 of 36 ยท Service and OS Detection

Banner Grabbing and Probes

See how services announce themselves and how scanners send probes, using small Node.js servers and clients that run only on loopback.

Many network services greet you the moment you connect. An SSH server sends a line such as SSH-2.0-OpenSSH_9.6, an SMTP server sends 220 hostname ESMTP, an FTP server sends a welcome code. That first message is a banner. Reading it is called banner grabbing, and it is the simplest form of what nmap -sV does for you.

Other services stay silent until the client speaks. A web server waits for a request. For those, a scanner sends a probe: a small message chosen so that the right kind of service replies in a recognisable way. In this lesson you build a tiny lab entirely on your own machine's loopback address, 127.0.0.1, so no other computer is ever contacted. You will see exactly why Nmap needs both banners and probes.

Only connect to systems you own or are explicitly allowed to test. The examples here talk to servers that the example program itself starts on 127.0.0.1 and stops again. Never point this kind of code at someone else's address.

Talkative and silent services

The table shows the two behaviours and how a scanner copes with each.

Kind Examples Scanner behaviour
Server speaks first SSH, FTP, SMTP, POP3, IMAP Connect, wait, read the banner
Client speaks first HTTP, DNS over TCP, TLS, Redis Send a matching probe, read the reply
Strict about input Databases, industrial protocols Wrong probes can be ignored or cause errors
sequenceDiagram
    participant C as Client (scanner)
    participant S as Talkative server
    participant W as Silent server
    C->>S: TCP connect
    S-->>C: banner line
    C->>W: TCP connect
    Note over W: says nothing
    C->>W: probe (HTTP request)
    W-->>C: reply with Server header

A talkative service answers on connect, a silent one needs a probe.

Grabbing banners from a local lab

The program below starts three small servers on loopback with automatic port numbers. One imitates an SSH greeting, one an SMTP greeting, and one is an HTTP server that stays silent until it receives a request. A client then connects to each. The fake banners are our own text.

Node.js Banner grabbing on loopback

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 node:readline or process.stdin), it gets the next line from this box.

The first two ports reveal themselves immediately. The web port reports silence until a probe arrives, and then it identifies itself in the Server header. This is the whole idea behind the NULL probe (just wait) and the GET / probe (ask politely) of Nmap's version detection.

Choosing the right probe

A scanner cannot know a service type in advance, so it keeps an ordered list. Which probe comes first depends on the port number: Nmap tries HTTP probes first on port 8080, a DNS probe first on port 53. If the first reply is ambiguous, it tries the next probe. The stand-in below mimics this strategy with a "service type" decided from the reply text.

Node.js Stand-in: first probe that gets a recognisable reply

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 node:readline or process.stdin), it gets the next line from this box.

Limits of banner grabbing

  • Banners can be changed. Administrators often hide versions (ServerTokens Prod in Apache) or even fake them. A banner is a claim, not a proof.
  • Encrypted services hide their banner until a TLS handshake is done. Nmap performs the handshake and then probes inside it.
  • Application behaviour can be more reliable than the greeting. Subtle differences in error pages and header order identify servers even when the name is removed. Nmap's match rules use such details.
  • Banners may contain sensitive hints (internal host names, software versions). From the defender's side, trim them where possible and monitor for anyone collecting them, as shown in Detecting Scans in Logs.

For quick manual checks on hosts you own, simple tools show the same thing. These are read-only examples:

Terminal
# Example commands (read-only)
nc -v 192.0.2.10 22          # connect and print the greeting
printf 'HEAD / HTTP/1.0\r\n\r\n' | nc 192.0.2.10 80
nmap -sV --version-trace -p 22 192.0.2.10   # show every probe Nmap sends
nmap --script banner -p 21,22,25 192.0.2.10 # NSE script that prints raw banners

The banner script is covered with the others in Common NSE Scripts.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why does a scanner send a probe to some ports?

    Silent services need a request that makes them reply. Nmap's probe list contains HTTP, TLS, DNS and many other opening messages.
  2. 2. Which of these is a server that speaks first?

    SSH sends its protocol identification line immediately after the connection opens. HTTP, TLS and Redis wait for the client.
  3. 3. Why is a banner not proof of the real software version?

    The text is chosen by the server's configuration. Treat it as a claim, and confirm with other evidence such as behaviour or the host's package list.
  4. 4. In the lab program, which address do the servers listen on, and why?

    Loopback traffic never leaves your computer, so the exercise cannot touch anyone else's system.

Summary

  • Some services send a banner on connect; others need a probe that matches their protocol.
  • Nmap's version detection combines waiting, ordered probes and pattern matching.
  • Banners are claims that can be hidden or faked; confirm with other evidence.
  • Practise only on your own machine or lab, for example on 127.0.0.1.

Next: Aggressive Scan and Traceroute