Skip to content

Instantly share code, notes, and snippets.

@takscape
Created March 4, 2013 16:36
Show Gist options
  • Select an option

  • Save takscape/5083554 to your computer and use it in GitHub Desktop.

Select an option

Save takscape/5083554 to your computer and use it in GitHub Desktop.
Bro script for extracting all TCP stream contents.
@load base/utils/files
global conn_files: table[string] of file &synchronized;
redef tcp_content_deliver_all_orig = T;
redef tcp_content_deliver_all_resp = T;
event tcp_contents(c: connection, is_orig: bool, seq: count, contents: string)
{
local fname: string;
local f: file;
if (is_orig) {
fname = generate_extraction_filename("contents", c, fmt("%s_%s", c$uid, "orig.dat"));
} else {
fname = generate_extraction_filename("contents", c, fmt("%s_%s", c$uid, "resp.dat"));
}
if (fname in conn_files) {
f = conn_files[fname];
} else {
f = open(fname);
conn_files[fname] = f;
}
write_file(f, contents);
#print fmt("%f bytes total.", my_counter);
}
event bro_done()
{
flush_all();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment