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

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 are the operator characters supported by the library:

  • H: H represents a hex string

  • B: B represents a bit string

  • x: x represents a null byte

  • z: z represents a zero-terminated string

  • p: p represents a string preceded by a 1-byte integer length

  • P: P represents...