O'Reilly logo

Mastering the Nmap Scripting Engine by Paulino Calderón Pale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Raw packet handling and NSE sockets

You are now familiar with NSE sockets and raw packet handling. Now we will review an example of everything we have seen in this chapter working together in one script. The following script, broadcast-dhcp-discover.nse, illustrates the usage of connection-oriented sockets, raw packet reception, manipulation, and frame building. Pay close attention to the bin.pack(), pcap_receive(), and sendto() method calls, and the helper functions that perform error checking during script execution.

The script starts by declaring its library dependencies and required script fields such as description, author, and categories:

local bin = require "bin" local coroutine = require "coroutine" local dhcp = require "dhcp" local ipOps ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required