Skip to the content.

Tutorial — cve-lookup

cve-lookup turns recon results into CVEs. It queries the official NVD CVE API 2.0 — no third-party client, just urllib — and understands three kinds of input: a service banner (the thing port-scanner grabs), a free-text keyword, and explicit CVE ids. This tutorial chains it with port-scanner exactly as captured in examples/cve-lookup/.

Step 1 — look up a single CVE

$ python3 cve-lookup/cve_lookup.py --cve CVE-2021-44228

Log4Shell, with its CVSS v3.1 score, vector, CWE and the CISA KEV flag (the vulnerability is on the Known Exploited list, meaning real intrusions are documented):

== CVE-2021-44228
   CVE-2021-44228    10.0  CRITICAL  (CWE-20)  [CISA KEV]
       Apache Log4j2 2.0-beta9 through 2.15.0 (excluding security releases 2.12.2, 2.12.3, and 2.3.1...

Summary: 1 CVE(s) shown, 1 on the CISA KEV list, 1 critical, 0 high

Multiple ids work comma-separated; invalid ones are rejected with exit code 2 before any request is made.

Step 2 — chain a port scan into CVEs

This is the flagship path. Scan a target and feed the JSON report straight in:

$ python3 port-scanner/port_scanner.py scanme.nmap.org --ports 22,80 --format json --output scan.json
[*] done: 2 open of 2 scanned in 1.3s

$ python3 cve-lookup/cve_lookup.py --from-scan scan.json --max-results 5
[*] banner maps to CPE cpe:2.3:a:openbsd:openssh:6.6.1:*:*:*:*:*:*:*
[*] 1 NVD query(ies) to run, pacing at 6.0s intervals
[*] done: 5 CVE(s) shown, 1 CISA KEV, 0 error(s)

The output:

== SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13  [cpe:2.3:a:openbsd:openssh:6.6.1:*:*:*:*:*:*:*]
   CVE-2023-38408    9.8   CRITICAL  (CWE-428)
       The PKCS#11 feature in ssh-agent in OpenSSH before 9.3p2 has an insufficiently trustworthy se...
   ...

Summary: 5 CVE(s) shown, 1 on the CISA KEV list, 2 critical, 3 high

What happened under the hood: the banner SSH-2.0-OpenSSH_6.6.1p1 was matched to the openbsd:openssh CPE (OpenSSH is published under the openbsd vendor in the NVD dictionary), the version 6.6.1p1 was normalised to 6.6.1 because CPE versions carry no distro suffixes, and the NVD virtualMatchString filter returned every CVE for that product and version. Banners that no product can be recognised in are reported honestly instead of silently dropped — and identical banners are deduplicated, so one lookup per service, not per port.

Step 3 — query a banner directly

$ python3 cve-lookup/cve_lookup.py --banner "Apache/2.4.49"
[*] banner maps to CPE cpe:2.3:a:apache:http_server:2.4.49:*:*:*:*:*:*:*

The vendor map covers the products that actually greet you on a connect: OpenSSH, Dropbear, Apache httpd and Tomcat, nginx, IIS, MySQL, PostgreSQL, Redis, MongoDB, Elasticsearch, Kibana, Memcached, OpenSSL, PHP, vsftpd, ProFTPD, Dovecot, Exim, HAProxy, Squid and a few more — every entry verified against the official CPE dictionary. A token followed by a version always wins over a bare mention, which is why Apache Tomcat/9.0.1 resolves to Tomcat, not to httpd.

$ python3 cve-lookup/cve_lookup.py --keyword "log4j remote code execution"

Keywords search CVE descriptions across NVD — useful when you only know a product name, not a version. Results arrive KEV-first, then highest CVSS.

Step 5 — filter noise

$ python3 cve-lookup/cve_lookup.py --from-scan scan.json --severity critical,high --min-cvss 7
$ python3 cve-lookup/cve_lookup.py --cve CVE-2021-44228 --format json -o report.json

--severity takes a comma-separated list, --min-cvss a floor (default 0.0 = everything), and --max-results (default 10, cap 100) bounds what is shown — the JSON report keeps the count of everything NVD matched. Exit codes: 0 for a clean run (even with zero matches), 1 when every query failed, 2 for usage errors.

Step 6 — the rate limit and API keys

Without a key the tool paces requests at 6 s intervals — the public NVD limit of 5 requests per 30 seconds — which is why the log line says pacing at 6.0s intervals. With NVD_API_KEY in the environment (or --api-key), pacing drops to 0.7 s for the 50-requests-per-30-seconds tier; keys are free. HTTP 403/429 answers produce a message that says exactly this instead of a raw traceback.

Ground rules

The tool only reads a public API — nothing is scanned and nothing is exploited. Use it to triage systems you own or are authorized to assess, and treat banner-derived results as leads: version banners lie, distro backports patch without bumping the version, and a CVE list is not a finding until someone verified exploitability on the real system.