Now we will briefly cover a few examples of different NSE version scripts to familiarize ourselves with the structure and required components.
The modbus-discover
script was written by Alexander Rudakov to retrieve device information through the modbus
protocol. Modbus is very popular among Supervisory Control And Data
Acquisition (SCADA) systems. The script attempts to discover valid Slave IDs (SIDs) and retrieve additional device information:
action = function(host, port) -- If false, stop after first sid. local aggressive = stdnse.get_script_args('modbus-discover.aggressive') local opts = {timeout=2000} local results = {} for sid = 1, 246 do stdnse.print_debug(3, "Sending command with sid = %d", sid) local rsid = form_rsid(sid, 0x11, "") local status, result = comm.exchange(host, port, rsid, opts) if ( status and (#result >= 8) ) then local ret_code =...