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

Chapter 8. Working with Network Sockets and Binary Data

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...