-
Notifications
You must be signed in to change notification settings - Fork 375
/
default.yml
331 lines (320 loc) · 8.23 KB
/
default.yml
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
---
description: Pipeline for parsing Microsoft Defender for Endpoint logs
processors:
- set:
field: ecs.version
value: '8.10.0'
- rename:
field: message
target_field: event.original
ignore_missing: true
- json:
field: event.original
target_field: json
- drop:
if: ctx.json?.value != null && ctx.json.value.isEmpty()
- remove:
field:
- json.comments
- host
- cloud
ignore_missing: true
#########################
## ECS General Mapping ##
#########################
- script:
lang: painless
if: ctx?.json != null
params:
values:
- null
- ""
- "-"
- "N/A"
source: |
if (!ctx['json'].empty) {
ctx.json.entrySet().removeIf(entry -> params.values.contains(entry.getValue()));
}
- script:
lang: painless
if: ctx?.json?.evidence != null
params:
values:
- null
- ""
- "-"
- "N/A"
source: |
if (!ctx.json['evidence'].empty) {
ctx.json.evidence.entrySet().removeIf(entry -> params.values.contains(entry.getValue()));
}
- set:
field: cloud.provider
value: azure
- set:
field: '@timestamp'
value: '{{json.alertUpdateTime}}'
if: ctx.json?.alertUpdateTime != null
- rename:
field: json.aadTenantId
target_field: cloud.account.id
ignore_missing: true
- rename:
field: json.machineId
target_field: cloud.instance.id
ignore_missing: true
- rename:
field: json.title
target_field: message
ignore_missing: true
#######################
## ECS Event Mapping ##
#######################
- set:
field: event.kind
value: alert
# Events returned from the API is always in UTC, so should never use anything else
- set:
field: event.timezone
value: UTC
- set:
field: event.action
value: '{{json.category}}'
if: ctx.json?.category != null
- set:
field: event.provider
value: defender_endpoint
- set:
field: event.created
value: '{{json.alertCreationTime}}'
if: ctx.json?.alertCreationTime != null
- append:
field: event.category
value: host
- append:
field: event.category
value: malware
if: ctx.json?.category == 'Malware'
- append:
field: event.category
value: process
if: ctx.json?.evidence?.entityType == 'Process'
- append:
field: event.type
value: access
if: ctx.json?.evidence?.entityType == 'User'
- append:
field: event.type
value:
- start
if: ctx.json?.status == 'New'
- append:
field: event.type
value: end
if: ctx.json?.status == 'Resolved'
- rename:
field: json.id
target_field: event.id
ignore_missing: true
- rename:
field: json.firstEventTime
target_field: event.start
ignore_missing: true
- rename:
field: json.lastEventTime
target_field: event.end
ignore_missing: true
- set:
field: event.severity
value: 0
if: ctx.json?.severity == 'Unspecified'
- set:
field: event.severity
value: 1
if: ctx.json?.severity == 'Informational'
- set:
field: event.severity
value: 2
if: ctx.json?.severity == 'Low'
- set:
field: event.severity
value: 3
if: ctx.json?.severity == 'Medium'
- set:
field: event.severity
value: 4
if: ctx.json?.severity == 'High'
- script:
lang: painless
if: "ctx?.event?.start != null && ctx?.event?.end != null"
source: >
Instant eventstart = ZonedDateTime.parse(ctx?.event?.start).toInstant();
Instant eventend = ZonedDateTime.parse(ctx?.event?.end).toInstant();
ctx.event['duration'] = ChronoUnit.NANOS.between(eventstart, eventend);
########################
## ECS Threat Mapping ##
########################
- set:
field: threat.framework
value: MITRE ATT&CK
if: ctx.json?.category != null
- append:
field: threat.technique.name
value: '{{{json.category}}}'
if: ctx.json?.category != null
- rename:
field: json.description
target_field: rule.description
ignore_missing: true
if: (ctx.json?.description).length() < 1020
######################
## ECS File Mapping ##
######################
- rename:
field: json.evidence.fileName
target_field: file.name
ignore_missing: true
- rename:
field: json.evidence.sha256
target_field: file.hash.sha256
ignore_missing: true
- rename:
field: json.evidence.sha1
target_field: file.hash.sha1
ignore_missing: true
- rename:
field: json.evidence.filePath
target_field: file.path
ignore_missing: true
######################
## ECS Process Mapping ##
######################
- rename:
field: json.evidence.processId
target_field: process.pid
ignore_missing: true
- rename:
field: json.evidence.processCommandLine
target_field: process.command_line
ignore_missing: true
- rename:
field: json.evidence.processCreationTime
target_field: process.start
ignore_missing: true
- rename:
field: json.evidence.parentProcessId
target_field: process.parent.pid
ignore_missing: true
- rename:
field: json.evidence.parentProcessCreationTime
target_field: process.parent.start
ignore_missing: true
##########################
## ECS Observer Mapping ##
##########################
- set:
field: observer.product
value: Defender for Endpoint
- set:
field: observer.vendor
value: Microsoft
- rename:
field: json.detectionSource
target_field: observer.name
ignore_missing: true
#####################
## ECS URL Mapping ##
#####################
- rename:
field: json.evidence.url
target_field: url.full
ignore_missing: true
if: ctx?.json?.evidence?.url != null
- uri_parts:
field: url.full
ignore_failure: true
if: ctx?.url?.full != null
######################
## ECS Host Mapping ##
######################
- rename:
field: json.computerDnsName
target_field: host.hostname
ignore_missing: true
- lowercase:
target_field: host.name
field: host.hostname
if: ctx.host?.hostname != null
######################
## ECS User Mapping ##
######################
- rename:
field: json.relatedUser.userName
target_field: user.name
ignore_missing: true
- rename:
field: json.relatedUser.domainName
target_field: user.domain
ignore_missing: true
- rename:
field: json.evidence.userSid
target_field: user.id
ignore_missing: true
#########################
## ECS Related Mapping ##
#########################
- append:
field: related.ip
value: '{{json.evidence.ipAddress}}'
if: ctx.json?.evidence?.ipAddress != null
- append:
field: related.user
value: '{{user.name}}'
if: ctx.user?.name != null
- append:
field: related.hash
value: '{{file.hash.sha1}}'
if: ctx.file?.hash?.sha1 != null
- append:
field: related.hash
value: '{{file.hash.sha256}}'
if: ctx.file?.hash?.sha256 != null
- append:
field: related.hosts
value: '{{host.name}}'
if: ctx.host?.name != null && ctx.host.name != ''
allow_duplicates: false
#############
## Cleanup ##
#############
- remove:
field:
- json.alertCreationTime
- json.severity
- json.relatedUser
- json.category
ignore_missing: true
- rename:
field: json
target_field: microsoft.defender_endpoint
ignore_missing: true
- convert:
field: microsoft.defender_endpoint.incidentId
type: string
ignore_missing: true
- convert:
field: microsoft.defender_endpoint.investigationId
type: string
ignore_missing: true
- remove:
field: event.original
if: "ctx?.tags == null || !(ctx.tags.contains('preserve_original_event'))"
ignore_failure: true
ignore_missing: true
on_failure:
- set:
field: event.kind
value: pipeline_error
- append:
field: error.message
value: '{{{ _ingest.on_failure_message }}}'