I was able to register the goose spicy parser , following are my files and I am getting one error I am not sure what the issue is
main.zeek
@load base/misc/version
module spicy_GOOSE;
global goose_topic = "/topic/goose";
global begin_time: time;
global total_time: interval;
export {
## Log stream identifier.
redef enum Log::ID += { spicy_GOOSE_LOG };
## Record type containing the column fields of the goose log.
type Info: record {
## Timestamp for when the activity happened.
ts: time &log &default=network_time();
appid: count &log &optional;
pkt_len: count &log &optional;
};
#global GOOSE::message: event(pkt: raw_pkt_hdr, appid: count, pkt_len: count);
#global analyzer_confirmation: event(atype: AllAnalyzers::Tag, info: AnalyzerConfirmationInfo);
global spicy_GOOSE::log_goose: event(rec: spicy_GOOSE::Info);
global log_GOOSE: event(rec: Info);
}
redef record raw_pkt_hdr += {
spicy_GOOSE: Info &optional;
};
event zeek_init() &priority=20
{
suspend_processing();
# TODO: Our example here models a custom protocol sitting between
# Ethernet and IP. The following sets that up, using a custom ether
# type 0x88b5. Adapt as suitable, some suggestions in comments.
local analyzer = PacketAnalyzer::ANALYZER_SPICY_GOOSE;
# Activate our analyzer on top of Ethernet.
#PacketAnalyzer::register_packet_analyzer(PacketAnalyzer::ANALYZER_ETHERNET, 0x88b8, analyzer);
if ( ! PacketAnalyzer::try_register_packet_analyzer_by_name("Ethernet", 0x88b8,"spicy_GOOSE") )
print "cannot register GOOSE Spicy analyzer";
# Activate IP on top of our analyzer. 0x4950 is our own protocol's
# magic number indicating that IP comes next.
#PacketAnalyzer::register_packet_analyzer(analyzer, 0x4950, PacketAnalyzer::ANALYZER_IP);
# Alternative: Use this if your analyzer parses a link layer protocol directly.
# const DLT_spicy_GOOSE : count = 12345;
# PacketAnalyzer::register_packet_analyzer(PacketAnalyzer::ANALYZER_ROOT, DLT_spicy_GOOSE, analyzer);
# Alternative: Use this if your analyzer parses a protocol running on top of
# IPv4, using the specified IP protocol number.
# PacketAnalyzer::register_packet_analyzer(PacketAnalyzer::ANALYZER_IP, 0xcafe, analyzer);
# Alternative: Use this if you want your analyzer to run on top of UDP, activated on the specified well-known port.
# const ports: set[port] = { 6789/udp } &redef;
# PacketAnalyzer::register_for_ports(PacketAnalyzer::ANALYZER_UDP, analyzer, ports);
#Log::create_stream(spicy_GOOSE::GOOSE_LOG, [$columns=Info, $ev=log_goose, $path="goose"]);
}
#print this event per packet
event spicy_GOOSE::message(packet: raw_pkt_hdr, appid: count, pkt_len: count)
{
local info: Info = [$ts=network_time(), $appid=appid, $pkt_len=pkt_len];
print "Processing pcakets", packet;
# Log::write(spicy_GOOSE::GOOSE_LOG, info);
}
#Example event defined in spicy_goose.evt.
event spicy_GOOSE::packet(packet: raw_pkt_hdr, appid: count, pkt_len: count)
{
# TODO: Consider just deleting this event handler if you don't need it.
# For most packet analyzers, it's best to not do any script-level work
# because the overhead could quickly become overwhelming.
local info: Info = [$ts=network_time(), $appid=appid, $pkt_len=pkt_len];
print "Processing pcakets", packet;
#Log::write(spicy_GOOSE::GOOSE_LOG, info);
}
spicy_goose.evt
import spicy_GOOSE;
import Zeek_spicy_GOOSE;
packet analyzer spicy_GOOSE:
parse with spicy_GOOSE::GOOSEPacket;
#TODO: Connect Spicy-side events with Zeek-side events. The example just
#defines a simple example event that forwards the raw data (which in practice you
#don't want to do!). In fact, you should consider just deleting this event if
#you don't need it: For most packet analyzers, it's best to not do any
#script-level work because the overhead could quickly become overwhelming.
on spicy_GOOSE::GOOSEPacket -> event spicy_GOOSE::packet($packet, self.appid, self.pkt_len);
spicy_goose.spicy
#TODO: Define your analyzer here.
module spicy_GOOSE;
import zeek;
#TODO: Our example here models a simple example packet format of static size:
#19 payload bytes, followed by the protocol number for the next layer, for
#which the data then follows subsequently. (This is just what our test trace
#happens to contain). Adapt as suitable.
public type GOOSEPacket = unit {
appid: uint8;
pkt_len: uint16;
payload: bytes &eod;
on %done {
# Feed into Zeek's next-layer packet analysis.
zeek::forward_packet(self.protocol);
}
};
zeek_spicy_goose.spicy
#Zeek-specific Spicy logic.
module Zeek_spicy_GOOSE;
import spicy_GOOSE;
import zeek;
#TODO: Add anything you need here.
whats wrong in here I am getting following error
$ /usr/local/zeek/bin/zeek -C main.zeek /home/ubuntu/Desktop/GOOSE.pcap
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\xd4'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\xc3'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\xb2'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\xa1'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\x02'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\x04'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\xff'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\xff'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: '\x01'
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unrecognized character: ''
error in /home/ubuntu/Desktop/GOOSE.pcap, line 1: unknown identifier K, at or near "K"