mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38: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.6 KiB
Text
56 lines
1.6 KiB
Text
##! Extracts the items from HTTP traffic, one per file. At this time only
|
|
##! the message body from the server can be extracted with this script.
|
|
|
|
module HTTP;
|
|
|
|
export {
|
|
## Pattern of file mime types to extract from HTTP entity bodies.
|
|
const extract_file_types = /NO_DEFAULT/ &redef;
|
|
|
|
## The on-disk prefix for files to be extracted from HTTP entity bodies.
|
|
const extraction_prefix = "http-item" &redef;
|
|
|
|
redef record Info += {
|
|
## This field can be set per-connection to determine if the entity body
|
|
## will be extracted. It must be set to T on or before the first
|
|
## entity_body_data event.
|
|
extracting_file: bool &default=F;
|
|
|
|
## This is the holder for the file handle as the file is being written
|
|
## to disk.
|
|
extraction_file: file &log &optional;
|
|
};
|
|
|
|
redef record State += {
|
|
entity_bodies: count &default=0;
|
|
};
|
|
}
|
|
|
|
event http_entity_data(c: connection, is_orig: bool, length: count, data: string) &priority=5
|
|
{
|
|
# Client body extraction is not currently supported in this script.
|
|
if ( is_orig || ! c$http$first_chunk ) return;
|
|
|
|
if ( c$http$first_chunk )
|
|
{
|
|
if ( c$http?$mime_type &&
|
|
extract_file_types in c$http$mime_type )
|
|
{
|
|
c$http$extracting_file = T;
|
|
local suffix = fmt("%s_%d.dat", is_orig ? "orig" : "resp", ++c$http_state$entity_bodies);
|
|
local fname = generate_extraction_filename(extraction_prefix, c, suffix);
|
|
|
|
c$http$extraction_file = open(fname);
|
|
enable_raw_output(c$http$extraction_file);
|
|
}
|
|
}
|
|
|
|
if ( c$http$extracting_file )
|
|
print c$http$extraction_file, data;
|
|
}
|
|
|
|
event http_end_entity(c: connection, is_orig: bool)
|
|
{
|
|
if ( c$http$extracting_file )
|
|
close(c$http$extraction_file);
|
|
}
|