Formatting our Nmap Scripting Engine (NSE) scripts' output correctly is important because it provides greater flexibility to anyone working with them, specifically when reading or parsing results. This chapter covers the usage of the supported output mode and attempts to outline good practices regarding reporting data back to the users.
In version 6.20BETA1, a new feature was introduced to provide greater flexibility by allowing NSE scripts to return structured data in XML format. Before that, users needed to parse the results from a string stored in the file, while the new system allows users to navigate through a well-organized XML file. We will explore the different ways of producing this structured output.
Besides the new structured output scheme, this chapter will talk about the role of the Nmap API and stdnse
library when formatting our scripts' output and printing debugging calls or verbose messages. In this chapter, we will cover the following...