mirror of
https://github.com/valitydev/Cortex-Analyzers.git
synced 2024-11-06 17:15:21 +00:00
malwarebazaar hash search
This commit is contained in:
parent
379acf2624
commit
10a8bd4edb
19
analyzers/MalwareBazaar/MalwareBazaar.json
Normal file
19
analyzers/MalwareBazaar/MalwareBazaar.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "MalwareBazaar",
|
||||
"author": "Andrea Garavaglia, Davide Arcuri - LDO-CERT",
|
||||
"license": "AGPL-V3",
|
||||
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
|
||||
"version": "1.0",
|
||||
"baseConfig": "MalwareBazaar",
|
||||
"description": "Search hashes on MalwareBazaar.",
|
||||
"dataTypeList": ["domain", "fqdn", "url", "hash", "ip"],
|
||||
"command": "MalwareBazaar/MalwareBazaar_analyzer.py",
|
||||
"configurationItems": [ {
|
||||
"name": "api_key",
|
||||
"description": "MalwareBazaar api key",
|
||||
"multi": false,
|
||||
"required": true,
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
}
|
62
analyzers/MalwareBazaar/MalwareBazaar_analyzer.py
Executable file
62
analyzers/MalwareBazaar/MalwareBazaar_analyzer.py
Executable file
@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
from cortexutils.analyzer import Analyzer
|
||||
|
||||
BASEURL = 'https://mb-api.abuse.ch/api/v1/'
|
||||
|
||||
class MalwareBazaarnalyzer(Analyzer):
|
||||
def __init__(self):
|
||||
Analyzer.__init__(self)
|
||||
self.api_key = self.get_param("config.api_key", None)
|
||||
|
||||
def run(self):
|
||||
data = self.get_data()
|
||||
if not data:
|
||||
self.error('No observable or file given.')
|
||||
|
||||
results = {}
|
||||
if self.data_type == 'hash':
|
||||
if len(data) in [32, 40, 64]:
|
||||
headers = { 'API-KEY': self.api_key }
|
||||
data = {
|
||||
'query': 'get_info',
|
||||
'hash': data,
|
||||
}
|
||||
results = requests.post(BASEURL, data=data, timeout=15, headers=headers)
|
||||
|
||||
if results.status_code == 200:
|
||||
results = results.json()
|
||||
if results['query_status'] in ['http_post_expected', 'illegal_hash', 'no_hash_provided']:
|
||||
self.error('MalwareBazaar returned error: %s' % results['query_status'])
|
||||
else:
|
||||
results['data'] = results['data'][0]
|
||||
else:
|
||||
self.error('Only sha256, sha1 and md5 supported by MalwareBazaar.')
|
||||
else:
|
||||
self.error('Datatype not supported.')
|
||||
|
||||
self.report(results)
|
||||
|
||||
def summary(self, raw):
|
||||
taxonomies = []
|
||||
namespace = "MalwareBazaar"
|
||||
|
||||
if raw['query_status'] == 'hash_not_found':
|
||||
taxonomies.append(self.build_taxonomy(
|
||||
'info',
|
||||
namespace,
|
||||
'Search',
|
||||
'No results'
|
||||
))
|
||||
else:
|
||||
taxonomies.append(self.build_taxonomy(
|
||||
'malicious',
|
||||
namespace,
|
||||
'Signature',
|
||||
raw['data'].get('signature', 'Unknown')
|
||||
))
|
||||
return {"taxonomies": taxonomies}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
MalwareBazaarnalyzer().run()
|
2
analyzers/MalwareBazaar/requirements.txt
Normal file
2
analyzers/MalwareBazaar/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
cortexutils
|
||||
requests
|
64
thehive-templates/MalwareBazaar_1_0/long.html
Normal file
64
thehive-templates/MalwareBazaar_1_0/long.html
Normal file
@ -0,0 +1,64 @@
|
||||
<div class="panel panel-info" ng-if="success && content.query_status == 'ok'">
|
||||
<div class="panel-heading">
|
||||
MalwareBazaar search results for
|
||||
<strong>{{artifact.data | fang}}</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Hashes</dt>
|
||||
<dd class="wrap">
|
||||
md5: {{content.data.md5_hash}}<br />
|
||||
sha256: {{content.data.sha256_hash}}<br />
|
||||
sha1: {{content.data.sha1_hash}}<br />
|
||||
imphash: {{content.data.imphash}}<br />
|
||||
ssdeep: {{content.data.ssdeep}}
|
||||
</dd>
|
||||
<dt>First seen (UTC)</dt>
|
||||
<dd>{{content.data.first_seen}}</dd>
|
||||
<dt>Last seen (UTC)</dt>
|
||||
<dd>{{content.data.last_seen}}</dd>
|
||||
<dt>Filename</dt>
|
||||
<dd>{{content.data.file_name}}</dd>
|
||||
<dt>Filetype</dt>
|
||||
<dd>{{content.data.file_type}} {{content.data.file_type_mime}}</dd>
|
||||
<dt>Filetype</dt>
|
||||
<dd>{{content.data.file_type}}</dd>
|
||||
<dt>Signature</dt>
|
||||
<dd><span class="label label-primary">{{content.data.signature}}</span></dd>
|
||||
<dt>Tags</dt>
|
||||
<dd><span ng-repeat="tag in content.data.tags" class="label label-info">{{tag}}</span></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- No results -->
|
||||
<div class="panel panel-danger" ng-if="content.query_status == 'hash_not_found'">
|
||||
<div class="panel-heading">
|
||||
<strong>{{artifact.data | fang}}</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>
|
||||
<i class="fa fa-warning"></i> MalwareBazaar:
|
||||
</dt>
|
||||
<dd class="wrap">No results</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- General error -->
|
||||
<div class="panel panel-danger" ng-if="!success">
|
||||
<div class="panel-heading">
|
||||
<strong>{{artifact.data | fang}}</strong>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal" ng-if="content.errorMessage">
|
||||
<dt>
|
||||
<i class="fa fa-warning"></i> MalwareBazaar:
|
||||
</dt>
|
||||
<dd class="wrap">{{content.errorMessage}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
3
thehive-templates/MalwareBazaar_1_0/short.html
Normal file
3
thehive-templates/MalwareBazaar_1_0/short.html
Normal file
@ -0,0 +1,3 @@
|
||||
<span class="label" ng-repeat="t in content.taxonomies" ng-class="{'info': 'label-info', 'safe': 'label-success', 'suspicious': 'label-warning', 'malicious':'label-danger'}[t.level]">
|
||||
{{t.namespace}}:{{t.predicate}}="{{t.value}}"
|
||||
</span>
|
Loading…
Reference in New Issue
Block a user