Skip to content

Instantly share code, notes, and snippets.

@sethhall
Created January 2, 2014 16:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethhall/8221692 to your computer and use it in GitHub Desktop.
Save sethhall/8221692 to your computer and use it in GitHub Desktop.
Example for Bro file extraction with domain name in the filename if the file was grabbed over HTTP.
redef record fa_file += {
is_my_extractor_going: bool &default=F;
};
event file_over_new_connection(f: fa_file, c: connection, is_orig: bool)
{
if ( !f$is_my_extractor_going )
{
f$is_my_extractor_going=T;
if ( f$source == "HTTP" && is_orig == F )
{
local domain = (c?$http && c$http?$host) ? c$http$host : "--";
local filename = cat(f$source, "_", domain, "_", c$id$orig_h, ":", port_to_count(c$id$orig_p), "-", c$id$resp_h, ":", port_to_count(c$id$resp_p), "_", f$id, ".dat");
Files::add_analyzer(f, Files::ANALYZER_EXTRACT, [$extract_filename=filename]);
}
else
{
Files::add_analyzer(f, Files::ANALYZER_EXTRACT);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment