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