NMAP Scripting Example

by Dejan Lukan
Oct. 7, 2017 0 comments INFOSEC Institute Pen Testing & Audits

When writing Nmap NSE scripts, we of course need to have a way to talk to the Nmap API, which provides us with various advanced features so we don’t have to write those features ourselves. We can’t do everything in LUA language that is used for writing NSE scripts, but we also need a way to talk to the Nmap API. For example: we need a way to check the information that was already gathered about the scanning host or network when running a script. This can be achieved by passing certain arguments to the NSE script within the action function. Let’s present an example of the banner.nse action function: