forked from shaniacht1/content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomation-CheckFilesWildfirePy.yml
More file actions
62 lines (62 loc) · 1.96 KB
/
automation-CheckFilesWildfirePy.yml
File metadata and controls
62 lines (62 loc) · 1.96 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
args:
- default: true
description: If provided, checks only files whose names are in the list. The names
should be comma-separated.
name: fileNames
comment: Deprecated, use "WildFire - Detonate File" playbook instead
commonfields:
id: CheckFilesWildfirePy
version: -1
dependson:
must:
- wildfire-upload
- wildfire-report
deprecated: true
name: CheckFilesWildfirePy
runonce: false
script: |-
import time
fileNames = []
if 'fileNames' in demisto.args():
fileNames = demisto.args()['fileNames'].split(',')
res = []
uploaded = []
viewed = {}
entries = demisto.executeCommand('getEntries', {})
for entry in entries:
if entry['File'] and demisto.get(entry, 'FileMetadata.md5') and (len(fileNames) == 0 or entry['File'] in fileNames):
md5 = demisto.get(entry, 'FileMetadata.md5')
if viewed.get(md5):
continue
demisto.log('[*] Checking - ' + demisto.get(entry, 'FileMetadata.md5'))
viewed[md5] = True
rep = demisto.executeCommand('wildfire-report', {'md5': md5})
for r in rep:
if positiveFile(r):
res.append(shortFile(r))
elif r['Type'] == entryTypes['error'] and '404' in r['Contents']:
upReply = demisto.executeCommand('wildfire-upload', {'upload': entry['ID']})
if upReply[0]['Type'] != entryTypes['error']:
uploaded.append(demisto.get(entry, 'FileMetadata.md5'))
# Wait for the uploaded files to be processed - 15 min
if len(uploaded) > 0:
time.sleep(15 * 60)
for u in uploaded:
rep = demisto.executeCommand('wildfire-report', {'md5': u})
notFound = False
for r in rep:
if positiveFile(r):
res.append(shortFile(r))
if len(res) > 0:
res.append('yes')
else:
res.extend(['No suspicious files found', 'no'])
demisto.results(res)
scripttarget: 0
system: true
tags:
- hash
- server
- threat-intel
- wildfire
type: python