Manipulating raw packets

The bin and packet NSE libraries must be mentioned now because they support methods that are useful when manipulating raw packets and generally when working with network I/O operations. In this section, we will learn about binary data strings, handy conversions supported by the libraries, and raw packet and frame generation.

Packing and unpacking binary data

Once you start working with network I/O operations, you'll quickly realize the need to encode binary data strings correctly. NSE has the bin library (http://nmap.org/nsedoc/lib/bin.html) that helps us pack and unpack formatted binary data strings. This library contains only the pack() and unpack() methods. We will learn how flexible and useful they are.

The following ...

Get Mastering the Nmap Scripting Engine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.