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