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

Accessing the Nmap API


This is the core API that allows scripts to obtain host and port information such as name resolution, state, version detection results, Mac address, and more (if available). It also provides the interface to Nsock, Nmap's socket library, which will be covered in Chapter 8, Working with Network Sockets and Binary Data.

NSE arguments

The arguments passed to the main action function consist of two Lua tables corresponding to host and port information. The amount of information available depends on the options used during the scans. For example, the host.os table will show nothing if the OS detection mode (-O) was not set.

Host table

The host table is a regular Lua table with the following fields:

  • host.os: This is the table containing OS matches (only available with OS detection)

  • host.ip: This is the IP address of the target

  • host.name: This is the reverse DNS name of the target (if available)

  • host.targetname: This is the hostname specified in the command line

  • host.directly_connected...