forked from madneal/http-custom
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.bro
More file actions
executable file
·46 lines (38 loc) · 1.23 KB
/
main.bro
File metadata and controls
executable file
·46 lines (38 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
##! Add an excerpt of HTTP POST bodies into the HTTP log.
@load base/protocols/http
module Corelight;
export {
## The length of POST bodies to extract.
const http_post_body_length = 200 &redef;
}
redef record HTTP::Info += {
postdata: string &log &optional;
};
event log_post_bodies(f: fa_file, data: string)
{
for ( cid in f$conns )
{
local c: connection = f$conns[cid];
if ( ! c$http?$postdata )
c$http$postdata = "";
# If we are already above the captured size here, just return.
if ( |c$http$postdata| > http_post_body_length )
return;
c$http$postdata = c$http$postdata + data;
if ( |c$http$postdata| > http_post_body_length )
{
c$http$postdata = c$http$postdata[0:http_post_body_length] + "...";
# This is currently failing on Corelight Sensors to due to restrictions so
# we will work around it for now.
#Files::remove_analyzer(f, Files::ANALYZER_DATA_EVENT, [$stream_event=log_post_bodies]);
}
}
}
event file_over_new_connection(f: fa_file, c: connection, is_orig: bool)
{
if ( is_orig && c?$http && c$http?$method && c$http$method == "POST" )
{
#c$http$postdata = encode_base64(c$http$postdata);
Files::add_analyzer(f, Files::ANALYZER_DATA_EVENT, [$stream_event=log_post_bodies]);
}
}