mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00

Other misc: - Remove HTTP::MD5 notice. - Add "last_active" field to FileAnalysis::Info record. - Replace "conn_uids", "conn_ids" fields in FileAnalysis::Info record with just a "conns" fields containing full connection records. - The http-methods unit test is failing now, but I think it will be fixed once I change the file handle callback mechanism to use events instead.
69 lines
1.7 KiB
Text
69 lines
1.7 KiB
Text
# @TEST-EXEC: bro -r $TRACES/irc-dcc-send.trace %INPUT >out
|
|
# @TEST-EXEC: btest-diff out
|
|
# @TEST-EXEC: btest-diff thefile
|
|
|
|
global actions: set[FileAnalysis::ActionArgs];
|
|
|
|
hook FileAnalysis::policy(trig: FileAnalysis::Trigger, info: FileAnalysis::Info)
|
|
{
|
|
print trig;
|
|
|
|
switch ( trig ) {
|
|
case FileAnalysis::TRIGGER_NEW:
|
|
print info$file_id, info$seen_bytes, info$missing_bytes;
|
|
|
|
if ( info$source == "IRC_DATA" )
|
|
{
|
|
for ( act in actions )
|
|
FileAnalysis::add_action(info$file_id, act);
|
|
}
|
|
break;
|
|
|
|
case FileAnalysis::TRIGGER_BOF_BUFFER:
|
|
if ( info?$bof_buffer )
|
|
print info$bof_buffer[0:10];
|
|
break;
|
|
|
|
case FileAnalysis::TRIGGER_TYPE:
|
|
# not actually printing the values due to libmagic variances
|
|
if ( info?$file_type )
|
|
print "file type is set";
|
|
if ( info?$mime_type )
|
|
print "mime type is set";
|
|
break;
|
|
|
|
case FileAnalysis::TRIGGER_EOF:
|
|
print info$file_id, info$seen_bytes, info$missing_bytes;
|
|
if ( info?$conns )
|
|
for ( cid in info$conns )
|
|
print cid;
|
|
|
|
if ( info?$total_bytes )
|
|
print "total bytes: " + fmt("%s", info$total_bytes);
|
|
if ( info?$source )
|
|
print "source: " + info$source;
|
|
|
|
for ( act in info$actions )
|
|
switch ( act$act ) {
|
|
case FileAnalysis::ACTION_MD5:
|
|
print fmt("MD5: %s", info$actions[act]$md5);
|
|
break;
|
|
case FileAnalysis::ACTION_SHA1:
|
|
print fmt("SHA1: %s", info$actions[act]$sha1);
|
|
break;
|
|
case FileAnalysis::ACTION_SHA256:
|
|
print fmt("SHA256: %s", info$actions[act]$sha256);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
event bro_init()
|
|
{
|
|
add actions[[$act=FileAnalysis::ACTION_EXTRACT,
|
|
$extract_filename="thefile"]];
|
|
add actions[[$act=FileAnalysis::ACTION_MD5]];
|
|
add actions[[$act=FileAnalysis::ACTION_SHA1]];
|
|
add actions[[$act=FileAnalysis::ACTION_SHA256]];
|
|
}
|