This repository has been archived by the owner on Jan 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfind-multiple-indicators.bro
64 lines (58 loc) · 2.64 KB
/
find-multiple-indicators.bro
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
@load base/frameworks/sumstats
@load base/frameworks/notice
@load base/frameworks/intel
module Intel;
export {
redef enum Notice::Type += {
Indv_Indicators,
Mult_Indicators,
};
# Threshold for processing unique indicators
const intel_uniq_threshold: double = 1 &redef;
# Threshold to meet before sending notice for multiple instances of unique indicators
const intel_mult_threshold: double = 5 &redef;
# The amount of time to watch a connection for indicators
# This interval will affect whether or not indicators are missed in a connection
# 3mins is probably enough to catch indicators in most connections
const intel_interval = 3mins &redef;
}
event log_intel(rec: Info)
{
SumStats::observe("intel.stats", [$str=cat(rec$uid,"`",rec$id$orig_h,"`",rec$id$resp_h)], [$str=rec$seen$indicator]);
}
event bro_init()
{
local r1: SumStats::Reducer = [$stream="intel.stats", $apply=set(SumStats::UNIQUE)];
SumStats::create([$name="collect-intel",
$epoch=intel_interval,
$reducers=set(r1),
$epoch_result(ts: time, key: SumStats::Key, result: SumStats::Result) =
{
local r = result["intel.stats"];
local parts = split_all(key$str,/`/);
local sub_msg = fmt("Indicator(s):");
local vals = r$unique_vals;
for ( i in vals )
sub_msg = fmt("%s%s", sub_msg, " " + i$str);
if ( r$unique > intel_uniq_threshold )
{
local mult_message = fmt("Seen %d uniq indicators in connection %s", r$unique, parts[1]);
NOTICE([$note=Mult_Indicators,
$src=to_addr(parts[3]),
$dst=to_addr(parts[5]),
$msg=mult_message,
$sub=sub_msg,
$identifier=key$str]);
}
if ( r$unique == intel_uniq_threshold && r$num >= intel_mult_threshold )
{
local indv_message = fmt("Seen indicator %d times in connection %s", r$num, parts[1]);
NOTICE([$note=Indv_Indicators,
$src=to_addr(parts[3]),
$dst=to_addr(parts[5]),
$msg=indv_message,
$sub=sub_msg,
$identifier=key$str]);
}
}]);
}