mirror of
https://github.com/valitydev/Cortex-Analyzers.git
synced 2024-11-07 17:38:53 +00:00
Allow analyzing file with EmergingThreats_MalwareInfo
This commit is contained in:
parent
380d6eea44
commit
9bf2fcd483
@ -5,7 +5,7 @@
|
|||||||
"url": "https://github.com/dadokkio/Cortex-Analyzers",
|
"url": "https://github.com/dadokkio/Cortex-Analyzers",
|
||||||
"license": "AGPL-V3",
|
"license": "AGPL-V3",
|
||||||
"description": "Retrieve ET details and info related to a malware hash.",
|
"description": "Retrieve ET details and info related to a malware hash.",
|
||||||
"dataTypeList": ["hash"],
|
"dataTypeList": ["file", "hash"],
|
||||||
"command": "EmergingThreats/emergingthreats_analyzer.py",
|
"command": "EmergingThreats/emergingthreats_analyzer.py",
|
||||||
"baseConfig": "EmergingThreats",
|
"baseConfig": "EmergingThreats",
|
||||||
"configurationItems": [
|
"configurationItems": [
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from cortexutils.analyzer import Analyzer
|
from cortexutils.analyzer import Analyzer
|
||||||
|
|
||||||
|
import hashlib
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -59,7 +60,9 @@ class EmergingThreatsAnalyzer(Analyzer):
|
|||||||
Analyzer.run(self)
|
Analyzer.run(self)
|
||||||
info = {}
|
info = {}
|
||||||
try:
|
try:
|
||||||
|
if self.data_type != 'file':
|
||||||
object_name = self.get_data()
|
object_name = self.get_data()
|
||||||
|
|
||||||
if self.data_type in ['domain', 'fqdn']:
|
if self.data_type in ['domain', 'fqdn']:
|
||||||
url = "https://api.emergingthreats.net/v1/domains/"
|
url = "https://api.emergingthreats.net/v1/domains/"
|
||||||
features = {'reputation', 'urls', 'samples', 'ips', 'events', 'nameservers', 'whois', 'geoloc'}
|
features = {'reputation', 'urls', 'samples', 'ips', 'events', 'nameservers', 'whois', 'geoloc'}
|
||||||
@ -71,6 +74,18 @@ class EmergingThreatsAnalyzer(Analyzer):
|
|||||||
elif self.data_type == 'hash':
|
elif self.data_type == 'hash':
|
||||||
url = "https://api.emergingthreats.net/v1/samples/"
|
url = "https://api.emergingthreats.net/v1/samples/"
|
||||||
features = {'', 'connections', 'dns', 'events'}
|
features = {'', 'connections', 'dns', 'events'}
|
||||||
|
|
||||||
|
elif self.data_type == 'file':
|
||||||
|
url = "https://api.emergingthreats.net/v1/samples/"
|
||||||
|
features = {'', 'connections', 'dns', 'events'}
|
||||||
|
hashes = self.get_param('attachment.hashes', None)
|
||||||
|
if hashes is None:
|
||||||
|
filepath = self.get_param('file', None, 'File is missing')
|
||||||
|
object_name = hashlib.md5(open(filepath, 'r').read()).hexdigest()
|
||||||
|
else:
|
||||||
|
# find MD5 hash
|
||||||
|
object_name = next(h for h in hashes if len(h) == 32)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.error('Invalid data type !')
|
self.error('Invalid data type !')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user