zeek/scripts/base/protocols/modbus/main.bro
Seth Hall 009efbcb27 Major revisions to Modbus analyzer support (not quite done yet).
- Renamed many data structures to align with most recent standard.

- Reworked modbus events to make them more canonically "Bro".

- Converted the Modbus analyzer to a simpler style for easier maintenance.

- Modbus coil related events still don't work (I haven't finished the
  function for converting the data structures).

- Modbus file record events remain incomplete.
2012-09-17 09:19:52 -04:00

26 lines
796 B
Text

##! Base Modbus analysis script.
module Modbus;
export {
}
# Configure DPD and the packet filter.
redef capture_filters += { ["modbus"] = "tcp port 502" };
redef dpd_config += { [ANALYZER_MODBUS] = [$ports = set(502/tcp)] };
redef likely_server_ports += { 502/tcp };
event modbus_exception(c: connection, header: ModbusHeaders, code: count)
{
print fmt("%.6f %s There was an exception: %s", network_time(), c$id, exception_codes[code]);
}
event modbus_message(c: connection, header: ModbusHeaders, is_orig: bool)
{
#if ( function_codes[header$function_code] in set("READ_MULTIPLE_REGISTERS", "READ_WRITE_REGISTERS", "WRITE_MULTIPLE_REGISTERS") )
# return;
print fmt("%.6f %s %s: %s", network_time(), c$id, is_orig ? "request":"response", function_codes[header$function_code]);
}