-
Notifications
You must be signed in to change notification settings - Fork 15
/
Process_Email_-_Core_v2.yml
1248 lines (1248 loc) · 29.2 KB
/
Process_Email_-_Core_v2.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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
id: Process Email - Core v2
version: 1
contentitemexportablefields:
contentitemfields:
packID: Phishing
packName: Phishing
itemVersion: 3.2.0
fromServerVersion: 6.0.0
toServerVersion: ""
definitionid: ""
vcShouldKeepItemLegacyProdMachine: false
name: Process Email - Core v2
description: This playbook adds email details to the relevant context entities and
handles the case where original emails are attached.
starttaskid: "0"
tasks:
"0":
id: "0"
taskid: ccd00127-175c-4a93-8edb-14e71f7d47ea
type: start
task:
id: ccd00127-175c-4a93-8edb-14e71f7d47ea
version: -1
name: ""
iscommand: false
brand: ""
nexttasks:
'#none#':
- "23"
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 265,
"y": 50
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"1":
id: "1"
taskid: 10265394-5988-44a4-88ec-27fa386e87c5
type: condition
task:
id: 10265394-5988-44a4-88ec-27fa386e87c5
version: -1
name: Is there an email file attached?
description: Identifies whether the incident includes an email message attached
as an EML or MSG file, and returns the answer to the playbook. Also saves
the identified entry ID to context for later use. Commonly used in automated
playbooks that handle phishing reports sent to a special phishing mailbox
set up by the security team.
scriptName: IdentifyAttachedEmail
type: condition
iscommand: false
brand: ""
nexttasks:
"no":
- "2"
"yes":
- "32"
scriptarguments:
entryid:
complex:
root: inputs.File
accessor: EntryID
transformers:
- operator: uniq
reputationcalc: 1
results:
- reportedemailentryid
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 265,
"y": 515
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"2":
id: "2"
taskid: 427170df-d844-44c5-8c7b-e45826113cec
type: regular
task:
id: 427170df-d844-44c5-8c7b-e45826113cec
version: -1
name: Save email details
description: Saves the email data extracted by the configured email listener
integration to the context. Also extracts indicators from the email message.
Also saves the HTML or email text to the email body section in the layout.
scriptName: Set
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "6"
scriptarguments:
key:
simple: Email
value:
simple: '${inputs={To: val[''Email''], CC: val[''EmailCC''], From: val[''EmailFrom''],
Subject: val[''EmailSubject''], Text: val[''EmailText''], HTML: val[''EmailHtml''],
Headers: val[''EmailHeaders''], Format: val[''EmailFormat'']}}'
reputationcalc: 2
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 50,
"y": 690
}
}
note: false
timertriggers: []
ignoreworker: false
fieldMapping:
- incidentfield: Rendered HTML
output:
complex:
root: inputs.EmailHtml
transformers:
- operator: SetIfEmpty
args:
applyIfEmpty: {}
defaultValue:
value:
simple: inputs.EmailText
iscontext: true
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"3":
id: "3"
taskid: b8e367d0-8147-4369-8216-acb86b53c088
type: regular
task:
id: b8e367d0-8147-4369-8216-acb86b53c088
version: -1
name: Extract and save email details
description: Parse an email from an eml or msg file and populate all relevant
context data to investigate the email. Also extracts inner attachments and
returns them to the war room. The incident labels themselves are preserved
and not modified - only the "Label/x" context items that originated from the
labels, and the best practice is to rely on these for the remainder of the
playbook.
scriptName: ParseEmailFiles
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "22"
scriptarguments:
entryid:
complex:
root: reportedemailentryid
transformers:
- operator: uniq
nesting_level_to_return:
simple: Inner file
reputationcalc: 2
results:
- AttachmentName
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 970,
"y": 860
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"6":
id: "6"
taskid: dd0d5106-965e-4a81-8e67-79392ea47d7f
type: title
task:
id: dd0d5106-965e-4a81-8e67-79392ea47d7f
version: -1
name: Done
type: title
iscommand: false
brand: ""
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 265,
"y": 1860
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"19":
id: "19"
taskid: d28fffd8-1d5b-4927-803b-f3589df019fd
type: regular
task:
id: d28fffd8-1d5b-4927-803b-f3589df019fd
version: -1
name: Display email information in layout
description: Updates Demisto incident fields using data from the email object.
script: Builtin|||setIncident
type: regular
iscommand: true
brand: Builtin
nexttasks:
'#none#':
- "6"
scriptarguments:
attachmentcount:
complex:
root: Email
accessor: |
Attachment.Count
attachmentextension:
complex:
root: Email
accessor: Attachment.Extension
attachmenthash:
complex:
root: Email
accessor: Attachment.Hash
attachmentid:
complex:
root: Email
accessor: Attachment.ID
attachmentitem:
complex:
root: Email
accessor: Attachment.Item
attachmentname:
complex:
root: Email
accessor: Attachment.Name
attachmentsize:
complex:
root: Email
accessor: Attachment.Size
attachmenttype:
complex:
root: Email
accessor: Attachment.Type
deleteEmptyField:
simple: "True"
emailbcc:
complex:
root: Email
accessor: HeadersMap.BCC
transformers:
- operator: uniq
- operator: Stringify
emailbody:
complex:
root: Email
accessor: Text
transformers:
- operator: Stringify
emailbodyformat:
complex:
root: Email
accessor: BodyFormat
emailbodyhtml:
complex:
root: Email
accessor: HTML
transformers:
- operator: Stringify
emailcc:
complex:
root: Email
accessor: CC
transformers:
- operator: uniq
- operator: Stringify
emailclientname:
complex:
root: Email
accessor: ClientName
emailfrom:
complex:
root: Email
accessor: From
transformers:
- operator: uniq
- operator: Stringify
emailhtml:
complex:
root: Email
accessor: HTML
transformers:
- operator: uniq
emailimage:
complex:
root: Email
accessor: Image
emailinreplyto:
complex:
root: Email
accessor: InReplyTo
emailkeywords:
complex:
root: Email
accessor: Keywords
emailmessageid:
complex:
root: Email
accessor: HeadersMap.Message-ID
transformers:
- operator: uniq
emailrecipientscount:
complex:
root: Email
accessor: To
transformers:
- operator: uniq
- operator: split
args:
delimiter:
value:
simple: ','
- operator: count
emailreplyto:
complex:
root: Email
accessor: HeadersMap.Reply-To
transformers:
- operator: uniq
emailreturnpath:
complex:
root: Email
accessor: HeadersMap.Return-Path
transformers:
- operator: uniq
emailsenderip:
complex:
root: Email
accessor: SenderIP
transformers:
- operator: uniq
emailsize:
complex:
root: Email
accessor: Size
transformers:
- operator: uniq
emailsource:
complex:
root: Email
accessor: Source
transformers:
- operator: uniq
emailsubject:
complex:
root: Email
accessor: Subject
transformers:
- operator: uniq
- operator: Stringify
emailto:
complex:
root: Email
accessor: To
transformers:
- operator: uniq
- operator: join
args:
separator:
value:
simple: ','
emailtocount:
complex:
root: Email
accessor: To
transformers:
- operator: uniq
- operator: split
args:
delimiter:
value:
simple: ','
- operator: count
emailurlclicked:
complex:
root: EmailUrlClicked
renderedhtml:
complex:
root: Email
accessor: HTML
transformers:
- operator: SetIfEmpty
args:
applyIfEmpty: {}
defaultValue:
value:
simple: Email.Text
iscontext: true
reportedemailcc:
complex:
root: Email
accessor: CC
transformers:
- operator: uniq
- operator: Stringify
reportedemailfrom:
complex:
root: Email
accessor: From
transformers:
- operator: uniq
- operator: Stringify
reportedemailmessageid:
complex:
root: Email.HeadersMap
accessor: Message-ID
transformers:
- operator: uniq
reportedemailorigin:
complex:
root: ReportedEmailOrigin
reportedemailsubject:
complex:
root: Email
accessor: Subject
transformers:
- operator: uniq
- operator: Stringify
reportedemailto:
complex:
root: Email
accessor: To
transformers:
- operator: uniq
- operator: join
args:
separator:
value:
simple: ','
reputationcalc: 1
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 1250,
"y": 1480
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"20":
id: "20"
taskid: c5bbf8a9-443c-4f8c-8956-536f0db06c6f
type: condition
task:
id: c5bbf8a9-443c-4f8c-8956-536f0db06c6f
version: -1
name: Were email headers extracted successfully?
description: Checks whether the email headers were extracted from the original
email that was either attached or retrieved using available email integrations.
type: condition
iscommand: false
brand: ""
nexttasks:
'#default#':
- "6"
"yes":
- "21"
separatecontext: false
conditions:
- label: "yes"
condition:
- - operator: isNotEmpty
left:
value:
complex:
root: Email
accessor: HeadersMap
iscontext: true
continueonerrortype: ""
view: |-
{
"position": {
"x": 645,
"y": 1480
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"21":
id: "21"
taskid: 7d54a7f8-9ca8-41d2-85f1-7ac15a293e3f
type: regular
task:
id: 7d54a7f8-9ca8-41d2-85f1-7ac15a293e3f
version: -1
name: Display email headers in layout
description: Fills the "Email Headers" grid field in the incident layout with
the email attachment's headers.
scriptName: SetGridField
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "6"
scriptarguments:
columns:
simple: headername,headervalue
context_path:
simple: Email.HeadersMap
grid_id:
simple: emailheaders
overwrite:
simple: "true"
sort_by:
simple: headername
unpack_nested_elements:
simple: "true"
separatecontext: false
continueonerror: true
continueonerrortype: ""
view: |-
{
"position": {
"x": 840,
"y": 1670
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"22":
id: "22"
taskid: 392db71e-012e-4790-8e1e-b17400e369aa
type: title
task:
id: 392db71e-012e-4790-8e1e-b17400e369aa
version: -1
name: incident Layout Display
type: title
iscommand: false
brand: ""
nexttasks:
'#none#':
- "20"
- "25"
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 970,
"y": 1030
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"23":
id: "23"
taskid: dc362223-2006-4006-8fe1-b1e6fbf45d89
type: condition
task:
id: dc362223-2006-4006-8fe1-b1e6fbf45d89
version: -1
name: Are there any files in the incident?
description: Checks whether the incident contains any kind of file.
type: condition
iscommand: false
brand: ""
nexttasks:
'#default#':
- "2"
"yes":
- "24"
separatecontext: false
conditions:
- label: "yes"
condition:
- - operator: isNotEmpty
left:
value:
complex:
root: inputs.File
accessor: EntryID
iscontext: true
continueonerrortype: ""
view: |-
{
"position": {
"x": 265,
"y": 180
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"24":
id: "24"
taskid: c69b6103-8a77-457c-8205-42e8e3e8a4bb
type: regular
task:
id: c69b6103-8a77-457c-8205-42e8e3e8a4bb
version: -1
name: Save incident files separately from email attachments
description: Saves the files that were initially involved with the incident
in a separate context key so they are available separate from email attachment
files.
scriptName: SetAndHandleEmpty
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "1"
scriptarguments:
key:
simple: IncidentFiles
value:
complex:
root: inputs.File
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 265,
"y": 350
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"25":
id: "25"
taskid: 2da109d4-c6b6-48f8-8fe2-72c9128e2cbd
type: title
task:
id: 2da109d4-c6b6-48f8-8fe2-72c9128e2cbd
version: -1
name: Attachment Info
type: title
iscommand: false
brand: ""
nexttasks:
'#none#':
- "34"
- "33"
- "35"
- "36"
- "38"
- "37"
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 1800,
"y": 1170
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"32":
id: "32"
taskid: e5c43ca9-cacd-4b3d-847d-2fb32a3cd1b4
type: regular
task:
id: e5c43ca9-cacd-4b3d-847d-2fb32a3cd1b4
version: -1
name: Set reported email origin (attached)
description: Sets the value of "ReportedEmailOrigin" to "Attached". This value
is set later in the "reportedemailorigin" incident field.
scriptName: Set
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "3"
scriptarguments:
key:
simple: ReportedEmailOrigin
value:
simple: Attached
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 600,
"y": 690
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"33":
id: "33"
taskid: 31bb2716-906b-48fe-8bdb-2839f6fddb3c
type: regular
task:
id: 31bb2716-906b-48fe-8bdb-2839f6fddb3c
version: -1
name: Save number of attachments
description: Saves the number of attachments in the email.
scriptName: SetAndHandleEmpty
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "19"
scriptarguments:
key:
simple: Email.Attachment.Count
value:
complex:
root: File
filters:
- - operator: notIn
left:
value:
simple: File.EntryID
iscontext: true
right:
value:
simple: IncidentFiles.EntryID
iscontext: true
- - operator: isNotEmpty
left:
value:
simple: File.EntryID
iscontext: true
transformers:
- operator: count
reputationcalc: 1
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 2200,
"y": 1310
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"34":
id: "34"
taskid: 4e51eee8-a78d-4b81-8f9b-497694b3baa9
type: regular
task:
id: 4e51eee8-a78d-4b81-8f9b-497694b3baa9
version: -1
name: Save attachment extensions
description: Saves the email attachment extensions.
scriptName: SetAndHandleEmpty
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "19"
scriptarguments:
key:
simple: Email.Attachment.Extension
value:
complex:
root: File
filters:
- - operator: notIn
left:
value:
simple: File.EntryID
iscontext: true
right:
value:
simple: IncidentFiles.EntryID
iscontext: true
- - operator: isNotEmpty
left:
value:
simple: File.EntryID
iscontext: true
accessor: Extension
transformers:
- operator: join
args:
separator:
value:
simple: ', '
reputationcalc: 1
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 1800,
"y": 1310
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"35":
id: "35"
taskid: e2a6e654-7d0d-4100-8f44-3249d8f70424
type: regular
task:
id: e2a6e654-7d0d-4100-8f44-3249d8f70424
version: -1
name: Save attachment MD5 hashes
description: Saves the email attachment MD5 hashes.
scriptName: SetAndHandleEmpty
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "19"
scriptarguments:
key:
simple: Email.Attachment.Hash
value:
complex:
root: File
filters:
- - operator: notIn
left:
value:
simple: File.EntryID
iscontext: true
right:
value:
simple: IncidentFiles.EntryID
iscontext: true
- - operator: isNotEmpty
left:
value:
simple: File.EntryID
iscontext: true
accessor: MD5
transformers:
- operator: join
args:
separator:
value:
simple: ', '
reputationcalc: 1
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 2607.5,
"y": 1310
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0
isoversize: false
isautoswitchedtoquietmode: false
"36":
id: "36"
taskid: 96f60056-52cb-4b5c-8b4c-7b2ad79dbd75
type: regular
task:
id: 96f60056-52cb-4b5c-8b4c-7b2ad79dbd75
version: -1
name: Save attachment names
description: Saves the email attachment names.
scriptName: SetAndHandleEmpty
type: regular
iscommand: false
brand: ""
nexttasks:
'#none#':
- "19"
scriptarguments:
key:
simple: Email.Attachment.Name
value:
complex:
root: File
filters:
- - operator: notIn
left:
value:
simple: File.EntryID
iscontext: true
right:
value:
simple: IncidentFiles.EntryID
iscontext: true
- - operator: isNotEmpty
left:
value:
simple: File.EntryID
iscontext: true
accessor: Name
transformers:
- operator: join
args:
separator:
value:
simple: ', '
reputationcalc: 1
separatecontext: false
continueonerrortype: ""
view: |-
{
"position": {
"x": 3420,
"y": 1310
}
}
note: false
timertriggers: []
ignoreworker: false
skipunavailable: false
quietmode: 0