Book Image

Mastering the Nmap Scripting Engine

By : Paulino Calderon
Book Image

Mastering the Nmap Scripting Engine

By: Paulino Calderon

Overview of this book

Table of Contents (23 chapters)
Mastering the Nmap Scripting Engine
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Scan Phases
Script Categories
Nmap Options Mind Map
References
Index

XML structured output


The objective of the XML structured output is to return data to users in structures that are easier to parse than the blob of text returned by the older scripts. The best part is that we can take advantage of this feature transparently in our scripts using the standard functions provided by the Nmap API and the stdnse library. If you are considering sending your NSE script to get it included with official Nmap releases, I highly recommend making your scripts support the structured output.

Note

The official documentation of the stdnse and nmap libraries can be found here:

Implementing structured output in your scripts

Lua tables are perfect data structures to represent output, so they were the obvious choice to be used as return values by NSE. NSE scripts can implement structured output by returning one of the following values:

  • A Lua table

  • A Lua table and a string

  • A Lua table with a __tostring() metamethod...