O'Reilly logo

Mastering the Nmap Scripting Engine by Paulino Calderón Pale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing your own version detection scripts

When writing our own NSE scripts, we will use the API provided by Nmap to interact with the host and port database. To write a version script, we simply need to do the following:

  1. Add your script to the category version.
  2. Write the corresponding portrule.
  3. Set the port version in our script after successful detection.

Defining the category of a version detection script

The first step is very straightforward. In your NSE script, add the category field as follows:

category = {"version"}

The category field is actually a regular Lua table, so feel free to add more categories to your script if necessary.

Defining the portrule of a version detection script

The next important thing is to have a portrule matching the desired ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required