TExcelTAD

Technology Identification

Knowing that a host runs "a web server" tells a tester little. Knowing that it runs nginx in front of PHP 8.1 with a WordPress 6.4 site and a jQuery 1.12 front end tells them which vulnerability classes to look for, which advisories to read and which configuration mistakes are typical. Technology identification (fingerprinting) collects that knowledge from what the system shows: banners, headers, cookie names, file paths, page markup and behaviour. Each clue is weak on its own and can be faked; several clues that agree are evidence. This lesson fingerprints a toy application in your sandbox, records the evidence and confidence for each conclusion, and ends with what defenders should and shouldn't do about banners.

Where the clues are

Clue Example Reliability
Server header Server: nginx/1.18.0 (Ubuntu) low to medium: configurable, often hidden or set by a proxy in front
X-Powered-By and framework headers X-Powered-By: PHP/8.1.2, X-AspNet-Version medium: often left on by default
Cookie names PHPSESSID, JSESSIONID, ASP.NET_SessionId, laravel_session, csrftoken (Django) medium to high: hard to change without code
Markup <meta name="generator" content="WordPress 6.4.2">, /wp-content/ paths, framework-specific attributes (ng-version, data-reactroot) high for the platform, medium for the version
Static files /static/js/jquery-1.12.4.min.js, version comments in CSS and JS high for the library version
Error pages a default 404 page, a stack trace format high: each framework's default error page is distinctive
TLS and protocol behaviour certificate fields, supported versions, HTTP/2, the order of headers medium; tools like nmap -sV match behaviour against a database

Versions matter most and are the least reliable. Linux distributions backport security fixes without changing the upstream version number, so OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 may contain fixes that a plain "OpenSSH 8.9" lacks. The version string is a lead for the triage step, never proof of a vulnerability.

Fingerprinting a toy application

The session starts a toy shop on 127.0.0.1:8000 that imitates a typical PHP/WordPress stack (it is a few lines of Python, which is itself a lesson: every one of these clues can be faked). A small Python fingerprinter then collects clues from one page and one missing page and reports each conclusion with its evidence. Two requests in total: a light touch, as recon should be.

bash · try it yourself
cat > shop.py <<'PY'
from wsgiref.simple_server import make_server, WSGIRequestHandler, ServerHandler
ServerHandler.server_software = "nginx/1.18.0 (Ubuntu)"     # the toy lies about its server
class Quiet(WSGIRequestHandler):
    def log_message(self, *a): pass
PAGE = b"""<!doctype html><html><head><meta name="generator" content="WordPress 6.4.2">
<link rel="stylesheet" href="/wp-content/themes/shop/style.css?ver=6.4.2">
<script src="/wp-includes/js/jquery/jquery.min.js?ver=3.7.1"></script></head>
<body><h1>Lab Shop</h1></body></html>"""
def app(env, start):
    if env["PATH_INFO"] == "/":
        start("200 OK", [("Content-Type", "text/html"), ("X-Powered-By", "PHP/8.1.2-1ubuntu2.14"),
                         ("Set-Cookie", "PHPSESSID=lab0001; path=/"), ("Link", '<http://lab.test/wp-json/>; rel="https://api.w.org/"')])
        return [PAGE]
    start("404 Not Found", [("Content-Type", "text/html"), ("X-Powered-By", "PHP/8.1.2-1ubuntu2.14")])
    return [b"<html><body class='error404'>Page not found - Lab Shop</body></html>"]
make_server("127.0.0.1", 8000, app, handler_class=Quiet).serve_forever()
PY
python3 shop.py &
for i in $(seq 50); do curl -s -o /dev/null http://127.0.0.1:8000/ && break; sleep 0.1; done
curl -s -D home.hdr -o home.html http://127.0.0.1:8000/
curl -s -D miss.hdr -o miss.html http://127.0.0.1:8000/no-such-page-check
kill %1
cat > fingerprint.py <<'PY'
import re
hdr = open("home.hdr").read() + open("miss.hdr").read()
html = open("home.html").read() + open("miss.html").read()
RULES = [  # (technology, where, regex, version group?)
    ("web server",   hdr,  r"^Server: ([^\r\n]+)", True),
    ("PHP",          hdr,  r"^X-Powered-By: PHP/([^\r\n]+)", True),
    ("PHP",          hdr,  r"Set-Cookie: PHPSESSID=", False),
    ("WordPress",    html, r'name="generator" content="WordPress ([\d.]+)"', True),
    ("WordPress",    html, r"/wp-content/|/wp-includes/", False),
    ("WordPress",    hdr,  r"rel=\"https://api\.w\.org/\"", False),
    ("WordPress",    html, r"class='error404'", False),
    ("jQuery",       html, r"jquery(?:\.min)?\.js\?ver=([\d.]+)", True),
]
found = {}
for tech, text, rx, has_ver in RULES:
    m = re.search(rx, text, re.M | re.I)
    if m:
        entry = found.setdefault(tech, {"clues": 0, "version": None})
        entry["clues"] += 1
        if has_ver:
            entry["version"] = m.group(1)
for tech, e in found.items():
    conf = "high" if e["clues"] >= 3 else "medium" if e["clues"] == 2 else "low"
    print(f"{tech:<11} version {e['version'] or '?':<24} clues {e['clues']}  confidence {conf}")
PY
python3 fingerprint.py
web server  version nginx/1.18.0 (Ubuntu)    clues 1  confidence low
PHP         version 8.1.2-1ubuntu2.14        clues 2  confidence medium
WordPress   version 6.4.2                    clues 4  confidence high
jQuery      version 3.7.1                    clues 1  confidence low

WordPress is identified by four independent clues (the generator tag, the wp-content paths, the REST API link header, the error404 body class), so the platform is certain even though any single clue could be faked. The web server is a single header: low confidence, and in this toy it is in fact a lie told by a Python program. The PHP version string 8.1.2-1ubuntu2.14 carries a distribution suffix, which says it is Ubuntu's package with backported fixes: the upstream number alone would overstate the vulnerabilities.

How fingerprinting is detected

A careful fingerprint (a few ordinary requests) looks like a visitor and is practically invisible. Tool-driven fingerprinting is not: nmap -sV sends probe strings that appear in logs, scanners request hundreds of known paths (/wp-admin/, /phpmyadmin/, /.git/HEAD) in seconds, and WAFs recognise their user agents and patterns. Requests for a burst of non-existent, technology-specific paths from one source are a standard alert.

How exposure is reduced (and what doesn't help)

  • Patch. The only real fix for "an old version is visible" is a current version. Hiding the banner of an outdated server only slows the inventory, the attacker's and yours.
  • Reduce gratuitous detail: server_tokens off; in nginx, ServerTokens Prod and ServerSignature Off in Apache, expose_php = Off in php.ini, remove generator tags. This makes mass scanning less precise and is a low-cost hygiene item. It is never rated above "informational" or "low" in a report.
  • Custom error pages that don't reveal the framework or stack traces.
  • Keep an inventory of your own technologies and versions (an SBOM for applications), so you know before the tester does.

Pitfalls

  • Version → vulnerability without triage. Backports and configuration decide whether a CVE applies.
  • One clue, high confidence. Count independent clues; headers are the easiest thing to fake or for a proxy to rewrite.
  • Noisy tools in recon. Path-guessing scanners are active testing; they belong in the window and the RoE.
  • Forgetting the layers: CDN, load balancer, WAF, reverse proxy, application server and application each add their own headers; identify which layer each clue comes from.

Practice

  1. Add a rule for the jQuery version found in a JavaScript file's header comment (/*! jQuery v3.7.1 |), and explain why it is more reliable than the ?ver= query string.
  2. The client asks you to recommend "hiding all versions" as the fix for an outdated PHP. What do you write?
Answers
  1. Fetch the script and match r"/\*! jQuery v([\d.]+)". The comment is inside the file that actually runs; the ?ver= parameter is a cache-busting string set by the platform and can differ from the real file.
  2. That hiding versions is a hygiene measure (low priority), and that the finding is the outdated PHP itself: upgrade to a supported release line, then optionally set expose_php = Off. A hidden banner doesn't remove the vulnerability, and scanners identify PHP by behaviour anyway.

Test yourself

Why is a version number from a banner not proof that a CVE applies?

  1. Banners are encrypted
  2. Distributions backport fixes without changing the upstream version, and banners can be changed or rewritten by proxies
  3. CVEs don't use version numbers
  4. Banners are always accurate

Which conclusion from the session has the highest confidence?

  1. The web server is nginx
  2. The site runs WordPress
  3. PHP is version 8.1.2 upstream with no patches
  4. The server runs Windows

What is the real fix when a tester reports an outdated, visible web server version?

  1. Hide the Server header
  2. Upgrade or patch the server; hiding the banner is at most a hygiene item
  3. Block the tester's IP
  4. Change the port

Which cookie name points to a Java servlet container?

  1. PHPSESSID
  2. JSESSIONID
  3. csrftoken
  4. ASP.NET_SessionId