-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscoring.py
More file actions
209 lines (165 loc) · 6.73 KB
/
scoring.py
File metadata and controls
209 lines (165 loc) · 6.73 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def score_by_event_count(event, attributes):
""" Simple event counting score function """
return 1
def score_by_event_threat_level(event, attributes):
""" Score based on exponential of an event's threat level """
score = 0
if event["threat_level_id"] == "1": # High
score += 100
elif event["threat_level_id"] == "2": # Medium
score += 50
elif event["threat_level_id"] == "3": # Low
score += 1
return score
def score_by_source_ips(event, attributes):
""" Score based on number of source IPs implicated """
score = 0
for attribute in attributes:
if attribute["category"] == "Network activity":
ty = attribute["type"]
if ty == "ip-src":
score += 3
return score
def score_by_destination_ips(event, attributes):
""" Score based on number of destination IPs implicated """
score = 0
for attribute in attributes:
if attribute["category"] == "Network activity":
ty = attribute["type"]
if ty == "ip-dst":
score += 1
return score
def score_by_domain_count(event, attributes):
""" Score based on number of network artifacts implicated """
score = 0
for attribute in attributes:
if attribute["category"] == "Network activity":
ty = attribute["type"]
if ty == "domain":
score += 5
return score
def score_by_malware_files(event, attributes):
""" Score based on indicators of malware recorded """
score = 0
for attribute in attributes:
if (attribute["category"] == "Payload installation") or (attribute["category"] == "Payload delivery"):
ty = attribute["type"]
if ty == "filename" or ty == "md5" or ty == "sha256" or ty == "sha1":
score += 10
return score
def score_by_amount_of_external_analysis(event, attributes):
""" Score based on amount of external analysis recorded """
score = 0
for attribute in attributes:
if attribute["category"] == "External analysis":
ty = attribute["type"]
if ty == "link":
score += 1
elif ty == "comment":
score += 1
return score
def score_team_size(event, attributes):
"""
Score based on indicators of team size (WIP)
Key indicators of team size will be numbers of sources and numbers of artefacts
"""
score = 0
for attribute in attributes:
if attribute["category"] == "Network activity":
ty = attribute["type"]
if ty == "domain":
score += 10
elif ty == "hostname" or ty == "url" or ty == "ip-src":
score += 5
elif attribute["category"] == "Payload delivery" or attribute["category"] == "Payload installation" or \
attribute["category"] == "Artifacts dropped":
ty = attribute["type"]
if ty == "vulnerability":
score += 10
elif ty == "malware-sample":
score += 2
elif ty == "filename" or ty == "filename|md5" or ty == "filename|sha1" or ty == "filename|sha256" or ty == "attachment":
score += 1
elif ty == "md5" or ty == "sha1" or ty == "sha256":
score += 1
return score
def score_resource_cost(event, attributes):
"""
Score based on indicators of resource cost (WIP)
Key indicators of resource cost will be numbers of targets and analysis effort
"""
score = 0
for attribute in attributes:
if attribute["category"] == "Network activity":
ty = attribute["type"]
if ty == "domain":
score += 20
elif ty == "hostname" or ty == "url" or ty == "ip-src":
score += 20
elif attribute["category"] == "Payload delivery" or attribute["category"] == "Payload installation" or \
attribute["category"] == "Artifacts dropped":
ty = attribute["type"]
if ty == "vulnerability":
score += 10
elif ty == "malware-sample":
score += 10
elif ty == "filename" or ty == "filename|md5" or ty == "filename|sha1" or ty == "filename|sha256" or ty == "attachment":
score += 10
elif ty == "md5" or ty == "sha1" or ty == "sha256":
score += 10
elif attribute["category"] == "External analysis":
ty = attribute["type"]
if ty == "vulnerability":
score += 10000
elif ty == "filename" or ty == "filename|md5" or ty == "filename|sha1" or ty == "filename|sha256":
score += 10
elif ty == "md5" or ty == "sha1" or ty == "sha256":
score += 10
return score
def score_time_cost(event, attributes):
"""
Score based on indicators of time cost (WIP)
Key indicators of resource cost will be numbers of targets and analysis effort
"""
score = 0
for attribute in attributes:
if attribute["category"] == "Network activity":
ty = attribute["type"]
if ty == "domain":
score += 1000
elif ty == "hostname" or ty == "url" or ty == "ip-src":
score += 500
elif attribute["category"] == "Payload delivery" or attribute["category"] == "Payload installation" or \
attribute["category"] == "Artifacts dropped":
ty = attribute["type"]
if ty == "vulnerability":
score += 10000
elif ty == "malware-sample":
score += 5000
elif ty == "filename" or ty == "filename|md5" or ty == "filename|sha1" or ty == "filename|sha256" or ty == "attachment":
score += 10
elif ty == "md5" or ty == "sha1" or ty == "sha256":
score += 10
elif attribute["category"] == "External analysis":
ty = attribute["type"]
if ty == "vulnerability":
score += 10000
elif ty == "filename" or ty == "filename|md5" or ty == "filename|sha1" or ty == "filename|sha256":
score += 10
elif ty == "md5" or ty == "sha1" or ty == "sha256":
score += 10
elif ty == "comment":
score += 100
elif ty == "link" or ty == "url":
score += 100
return score
def score_logistical_budget(event, attributes):
"""
Score based on indicators of logistical budget (WIP)
This is currently factoring in time and money
"""
resource_cost = score_resource_cost(event, attributes)
time_cost = score_time_cost(event, attributes)
return resource_cost + 400 * time_cost