mirror of
https://github.com/zeek/zeek.git
synced 2025-10-03 23:28:20 +00:00

- policy/ renamed to scripts/ - By default BROPATH now contains: - scripts/ - scripts/policy - scripts/site - *Nearly* all tests pass. - All of scripts/base/ is loaded by main.cc - Can be disabled by setting $BRO_NO_BASE_SCRIPTS - Scripts in scripts/base/ don't use relative path loading to ease use of BRO_NO_BASE_SCRIPTS (to copy and paste that script). - The scripts in scripts/base/protocols/ only (or soon will only) do logging and state building. - The scripts in scripts/base/frameworks/ add functionality without causing any additional overhead. - All "detection" activity happens through scripts in scripts/policy/. - Communications framework modified temporarily to need an environment variable to actually enable (ENABLE_COMMUNICATION=1) - This is so the communications framework can be loaded as part of the base without causing trouble when it's not needed. - This will be removed once a resolution to ticket #540 is reached.
56 lines
1.9 KiB
Text
56 lines
1.9 KiB
Text
##! This script lets Barnyard2 integrate with Bro. It receives alerts from
|
|
##! Barnyard2 and logs them. In the future it will do more correlation
|
|
##! and derive new notices from the alerts.
|
|
|
|
@load integration/barnyard2/types
|
|
|
|
module Barnyard2;
|
|
|
|
export {
|
|
redef enum Log::ID += { BARNYARD2 };
|
|
|
|
type Info: record {
|
|
ts: time &log;
|
|
pid: PacketID &log;
|
|
alert: AlertData &log;
|
|
};
|
|
|
|
## This can convert a Barnyard :bro:type:`PacketID` value to a
|
|
## :bro:type:`conn_id` value in the case that you might need to index
|
|
## into an existing data structure elsewhere within Bro.
|
|
global pid2cid: function(p: PacketID): conn_id;
|
|
}
|
|
|
|
event bro_init()
|
|
{
|
|
Log::create_stream(BARNYARD2, [$columns=Info]);
|
|
}
|
|
|
|
|
|
function pid2cid(p: PacketID): conn_id
|
|
{
|
|
return [$orig_h=p$src_ip, $orig_p=p$src_p, $resp_h=p$dst_ip, $resp_p=p$dst_p];
|
|
}
|
|
|
|
event barnyard_alert(id: PacketID, alert: AlertData, msg: string, data: string)
|
|
{
|
|
Log::write(BARNYARD2, [$ts=network_time(), $pid=id, $alert=alert]);
|
|
|
|
#local proto_connection_string: string;
|
|
#if ( id$src_p == 0/tcp )
|
|
# proto_connection_string = fmt("{PROTO:255} %s -> %s", id$src_ip, id$dst_ip);
|
|
#else
|
|
# proto_connection_string = fmt("{%s} %s:%d -> %s:%d",
|
|
# to_upper(fmt("%s", get_port_transport_proto(id$dst_p))),
|
|
# id$src_ip, id$src_p, id$dst_ip, id$dst_p);
|
|
#
|
|
#local snort_alike_msg = fmt("%.6f [**] [%d:%d:%d] %s [**] [Classification: %s] [Priority: %d] %s",
|
|
# sad$ts,
|
|
# sad$generator_id,
|
|
# sad$signature_id,
|
|
# sad$signature_revision,
|
|
# msg,
|
|
# sad$classification,
|
|
# sad$priority_id,
|
|
# proto_connection_string);
|
|
}
|