Skip to content

Instantly share code, notes, and snippets.

@grigorescu
Last active December 22, 2015 20:39
Show Gist options
  • Save grigorescu/6527829 to your computer and use it in GitHub Desktop.
Save grigorescu/6527829 to your computer and use it in GitHub Desktop.
Add ASN to Bro's conn.log
##! Add ASNs for the originator and responder of a connection
##! to the connection logs.
module Conn;
export {
redef record Conn::Info += {
## ASN for the originator of the connection based
## on a GeoIP lookup.
orig_asn: string &optional &log;
## ASN for the responser of the connection based
## on a GeoIP lookup.
resp_asn: string &optional &log;
};
}
event connection_state_remove(c: connection)
{
local orig_asn = lookup_asn(c$id$orig_h);
if ( orig_asn != 0 )
c$conn$orig_cc = orig_asn;
local resp_asn = lookup_asn(c$id$resp_h);
if ( resp_asn != 0 )
c$conn$resp_cc = resp_asn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment