Most NSE scripts need to communicate to other hosts to read or write data. Lua supports native network I/O operations, but there are several advantages to using the interfaces and libraries provided by the Nmap Scripting Engine (NSE). NSE sockets can be programmed as blocking or non-blocking I/O operations, and they support a connect-style method (when a client opens a connection, sends or receives data, and closes the connection) and low-level raw packet handling via a packet capture interface.
Nsock
(http://sock-raw.org/nmap-ncrack/nsock.html) is an Nmap library designed to help developers handle parallelizable network I/O operations. It is used by the service detection engine, in DNS operations performed by Nmap, and of course by NSE. NSE developers unknowingly use Nsock
when working with NSE sockets through the Nmap API library.
There are other very useful libraries that, when working with network sockets, help NSE developers handle...