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

Including debugging information

Debugging messages can be included in NSE scripts using the debug() function from the stdnse library. These messages are shown only when the debugging level has been set to a value higher than 0:

Debug(level, fmt, …) where
level: Debugging level.
fmt: Format string.
…: Format arguments.

To print a debug message when the debugging level is 1 or higher, we use the following code:

stdnse.debug(1, "Task #%d completed.", id)

The idea behind supporting this function is that we can do things such as printing different levels of information without having to write nested code:

stdnse.debug(1, "Response #%d received.", i)
stdnse.debug(2, "Response status code: %d", req.status)
stdnse.debug(3, "Response body:", req.body)

It is ...

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