Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated VMRay Analyzer #959

Merged
merged 3 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions analyzers/VMRay/VMRay.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"license": "AGPL-V3",
"author": "Nils Kuhnert, CERT-Bund",
"url": "https://github.com/BSI-CERT-Bund/cortex-analyzers",
"version": "3.1",
"description": "VMRay Sandbox file analysis.",
"version": "4.1",
"description": "VMRay Sandbox file and URL analysis.",
"dataTypeList": [
"hash",
"file",
Expand Down Expand Up @@ -42,6 +42,14 @@
"multi": false,
"required": false
},
{
"name": "verdict_only",
"description": "If set to true, only the verdict (or the score for VMRay versions < 4.0) will be added as labels.",
"type": "boolean",
"multi": false,
"required": false,
"defaultValue": false
},
{
"name": "query_retry_wait",
"description": "The amount of seconds to wait before trying to fetch the results.",
Expand Down
74 changes: 45 additions & 29 deletions analyzers/VMRay/vmray.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class VMRayAnalyzer(Analyzer):
_namespace = "VMRay"

_severity_mapping = {
"clean": "safe",
"whitelisted": "safe",
"suspicious": "suspicious",
"malicious": "malicious",
Expand All @@ -33,6 +34,7 @@ class VMRayAnalyzer(Analyzer):
def __init__(self):
Analyzer.__init__(self)
self.reanalyze = self.get_param("config.reanalyze", True)
self.verdict_only = self.get_param("config.verdict_only", False)
self.shareable = self.get_param("config.shareable", False)
self.tags = self.get_param("config.tags", ["TheHive"])
self.user_config = {
Expand Down Expand Up @@ -168,42 +170,56 @@ def run(self):
def _taxonomies_for_samples(self, samples):
taxonomies = []
for sample in samples:
level = self._severity_mapping.get(sample["sample_severity"], "info")
value = "{}".format(sample["sample_score"])
has_verdict = "sample_verdict" in sample
level = (
self._severity_mapping.get(sample["sample_verdict"], "info")
if has_verdict
else self._severity_mapping.get(sample["sample_severity"], "info")
)
value = "{}".format(
sample["sample_verdict"] if has_verdict else sample["sample_score"]
)
if len(samples) > 1:
value += " (from sample {})".format(sample["sample_id"])
taxonomies.append(
self.build_taxonomy(level, self._namespace, "Score", value)
self.build_taxonomy(level, self._namespace, "Verdict", value)
if has_verdict
else self.build_taxonomy(level, self._namespace, "Score", value)
)

for threat_indicator in sample.get("sample_threat_indicators", {}).get(
"threat_indicators", []
):
predicate = threat_indicator.get("category", None)
value = threat_indicator.get("operation", "")
if predicate:
taxonomies.append(
self.build_taxonomy(level, self._namespace, predicate, value)
)
if not self.verdict_only:
for threat_indicator in sample.get("sample_threat_indicators", {}).get(
"threat_indicators", []
):
predicate = threat_indicator.get("category", None)
value = threat_indicator.get("operation", "")
if predicate:
taxonomies.append(
self.build_taxonomy(
level, self._namespace, predicate, value
)
)

for mitre_technique in sample.get("sample_mitre_attack", {}).get(
"mitre_attack_techniques", []
):
predicate = mitre_technique.get("technique_id", None)
value = mitre_technique.get("technique", "Unknown MITRE technique")
if "tactics" in mitre_technique:
value += " using tactics: {}".format(
", ".join(mitre_technique["tactics"])
)
if predicate:
taxonomies.append(
self.build_taxonomy(level, self._namespace, predicate, value)
)
for mitre_technique in sample.get("sample_mitre_attack", {}).get(
"mitre_attack_techniques", []
):
predicate = mitre_technique.get("technique_id", None)
value = mitre_technique.get("technique", "Unknown MITRE technique")
if "tactics" in mitre_technique:
value += " using tactics: {}".format(
", ".join(mitre_technique["tactics"])
)
if predicate:
taxonomies.append(
self.build_taxonomy(
level, self._namespace, predicate, value
)
)

# add child sample taxonomies if they have been added
taxonomies.extend(
self._taxonomies_for_samples(sample.get("sample_child_samples", []))
)
# add child sample taxonomies if they have been added
taxonomies.extend(
self._taxonomies_for_samples(sample.get("sample_child_samples", []))
)
return taxonomies

def _sandbox_reports_for_samples(self, samples):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@
VMRay Report
</div>
<div class="panel-body" ng-repeat="sample in content.samples">
<dl class="dl-horizontal">
<dt>Score</dt>
<dd><a href="{{sample.sample_webif_url}}">{{sample.sample_score}}</a></dd>
</dl>
<dl class="dl-horizontal">
<dt ng-if="sample.sample_severity">Severity</dt>
<dl class="dl-horizontal" ng-if="sample.sample_verdict">
<dt>Verdict</dt>
<dd>
<span class="label" ng-class="{'label-success':sample.sample_severity === 'not_suspicious',
'label-danger': sample.sample_severity==='malicious',
'label-info': sample.sample_severity!='not_suspicious' && sample.sample_severity!='malicious'}">
{{sample.sample_severity}}
<span class="label"
ng-class="{'label-success':sample.sample_verdict === 'clean',
'label-danger': sample.sample_verdict==='malicious',
'label-warning': sample.sample_verdict==='suspicious',
'label-info': sample.sample_verdict!='clean' && sample.sample_verdict!='suspicious' && sample.sample_verdict!='suspicious'}">
{{sample.sample_verdict}}
</span>
</dd>
</dl>
<dl class="dl-horizontal">
<dt>Score</dt>
<dd>{{sample.sample_score}}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Last reputation</dt>
<dd>
<span class="label" ng-class="{'label-info':sample.sample_last_reputation_severity === 'unknown',
'label-danger': sample.sample_last_reputation_severity==='blacklisted',
'label-info': sample.sample_last_reputation_severity!='blacklisted'}">
'label-danger': sample.sample_last_reputation_severity==='malicious',
'label-success':sample.sample_last_reputation_severity === 'clean',
'label-info': sample.sample_last_reputation_severity!='malicious'}">
{{sample.sample_last_reputation_severity}}
</span>
</dd>
Expand Down