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

Analyzer for Sophos Intelix #571

Merged
merged 35 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
16b2c41
Added service config file and requirements.txt
stephen-oleary Nov 11, 2019
42ef58c
added intelix module to requirements.txt
stephen-oleary Nov 11, 2019
2c03d7c
initial commit
stephen-oleary Nov 12, 2019
8323a35
added some logging
stephen-oleary Nov 12, 2019
116ecc7
added try except
stephen-oleary Nov 12, 2019
dd22a7e
added execute permission
stephen-oleary Nov 12, 2019
07183d6
corrected clientID parameter
stephen-oleary Nov 12, 2019
79b3dfd
changing summary function
stephen-oleary Nov 12, 2019
002dd3b
expanded message
stephen-oleary Nov 12, 2019
97b4134
trying to get proper error message
stephen-oleary Nov 12, 2019
2b371f0
moving where client is started
stephen-oleary Nov 12, 2019
c303722
changed again
stephen-oleary Nov 12, 2019
73632de
modifying script name
stephen-oleary Nov 12, 2019
4996acf
Merge branch 'master' of github.com:stephen-oleary/Cortex-Analyzers
stephen-oleary Nov 12, 2019
7ae5362
bump version to 0.2
stephen-oleary Nov 12, 2019
2bf57c2
moving client call to init
stephen-oleary Nov 12, 2019
b4cfc7a
added report attribute to trigger results
stephen-oleary Nov 12, 2019
3f607a3
bump version to 0.3
stephen-oleary Nov 12, 2019
dcbc92f
added risk level to full report for domain data type
stephen-oleary Nov 12, 2019
d21fb97
improved full reports and shortened summary for domain data type
stephen-oleary Nov 12, 2019
fabee58
added service files for static and dynamic file analysis submissions
stephen-oleary Nov 12, 2019
639b31e
added service files for static and dynamic file analysis submissions
stephen-oleary Nov 12, 2019
dc68c68
added code for file submissions
stephen-oleary Nov 12, 2019
65010a3
added code for file submissions and summarisation
stephen-oleary Nov 13, 2019
c86c157
adding templates
stephen-oleary Nov 13, 2019
c3bff8f
adding long templates for get report and dynamic analysis
stephen-oleary Dec 9, 2019
9cb8cd1
added short templates
stephen-oleary Dec 9, 2019
1c68652
removed un-needed lines relating to dynamic analysis
stephen-oleary Dec 9, 2019
831463b
added summary info and ML analysis sections for static report
stephen-oleary Dec 9, 2019
e810e06
added ML summary results
stephen-oleary Dec 9, 2019
1ba2cf7
added PE analysis section and reordered sections so most useful is ne…
stephen-oleary Dec 10, 2019
9913191
Updated descriptions
Jan 12, 2020
db6b158
Manage error when hash is not found, add fqdn/url type
dadokkio Oct 2, 2020
9dff0b1
add fqdn/url support
dadokkio Oct 2, 2020
ce2b459
add support for fqdn/url also in template
dadokkio Oct 2, 2020
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
38 changes: 38 additions & 0 deletions analyzers/SophosIntelix/SophosIntelix_GetReport.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "SophosIntelix_GetReport",
"version": "0.3",
"author": "SOL",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Fast and easy way to find out if the file is known Good, PUA (Potentially Unwanted Application), or, Malware. For more information or to sign up for SophosLabs Intelix (with a free tier) see https://www.sophos.com/en-us/labs/intelix.aspx",
"dataTypeList": ["hash", "domain", "fqdn", "url"],
"command": "SophosIntelix/intelix_analyzer.py",
"baseConfig": "SophosIntelix",
"config": {
"service": "get"
},
"configurationItems": [
{
"name": "clientID",
"description": "Client ID for Sophos Labs Intelix",
"type": "string",
"multi": false,
"required": true
},
{
"name": "clientSecret",
"description": "Client Secret for Sophos Labs Intelix",
"type": "string",
"multi": false,
"required": true
},
{
"name": "polling_interval",
"description": "Define time interval between two requests attempts for the report",
"type": "number",
"multi": false,
"required": false,
"defaultValue": 60
}
]
}
38 changes: 38 additions & 0 deletions analyzers/SophosIntelix/SophosIntelix_Submit_Dynamic.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "SophosIntelix_Submit_Dynamic",
"version": "0.1",
"author": "SOL",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Detonate your suspicious file in SophosLabs Sandbox and find what behaviours the file has. For more information or to sign up for SophosLabs Intelix (with a free tier) see https://www.sophos.com/en-us/labs/intelix.aspx",
"dataTypeList": ["file"],
"command": "SophosIntelix/intelix_analyzer.py",
"baseConfig": "SophosIntelix",
"config": {
"service": "submit_dynamic"
},
"configurationItems": [
{
"name": "clientID",
"description": "Client ID for Sophos Labs Intelix",
"type": "string",
"multi": false,
"required": true
},
{
"name": "clientSecret",
"description": "Client Secret for Sophos Labs Intelix",
"type": "string",
"multi": false,
"required": true
},
{
"name": "polling_interval",
"description": "Define time interval between two requests attempts for the report",
"type": "number",
"multi": false,
"required": false,
"defaultValue": 60
}
]
}
38 changes: 38 additions & 0 deletions analyzers/SophosIntelix/SophosIntelix_Submit_Static.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "SophosIntelix_Submit_Static",
"version": "0.1",
"author": "SOL",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use SophosLabs machine learning to understand the characteristics of your suspicious file allowing you to see if the file is similar to known malware. For more information or to sign up for SophosLabs Intelix (with a free tier) see https://www.sophos.com/en-us/labs/intelix.aspx",
"dataTypeList": ["file"],
"command": "SophosIntelix/intelix_analyzer.py",
"baseConfig": "SophosIntelix",
"config": {
"service": "submit_static"
},
"configurationItems": [
{
"name": "clientID",
"description": "Client ID for Sophos Labs Intelix",
"type": "string",
"multi": false,
"required": true
},
{
"name": "clientSecret",
"description": "Client Secret for Sophos Labs Intelix",
"type": "string",
"multi": false,
"required": true
},
{
"name": "polling_interval",
"description": "Define time interval between two requests attempts for the report",
"type": "number",
"multi": false,
"required": false,
"defaultValue": 60
}
]
}
159 changes: 159 additions & 0 deletions analyzers/SophosIntelix/intelix_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#!/usr/bin/env python3
# encoding: utf-8

import intelix
import time
from cortexutils.analyzer import Analyzer


class SophosIntelixAnalyzer(Analyzer):

def __init__(self):
Analyzer.__init__(self)
self.service = self.get_param('config.service', None, 'Service parameter is missing')
self.clientId = self.get_param('config.clientID', None, 'ClientId is Missing')
self.clientSecret = self.get_param('config.clientSecret', None, 'Client Secret is Missing')
self.polling_interval = self.get_param('config.polling_interval', 60)
try:
self.ic = intelix.client(self.clientId, self.clientSecret)
except Exception as e:
error = str(e)
self.error('Error: {}'.format(error))

def run(self):
if self.service == 'get':
if self.data_type == 'hash':
try:
data = self.get_data()
try:
self.ic.file_lookup(data)
self.report({
"file_hash": data,
"reputation_score": self.ic.reputationScore,
"classification": self.ic.classification
})
except TypeError:
self.report({
"file_hash": data,
"reputation_score": "None",
"classification": "Unknown"
})
except Exception as e:
error = str(e)
self.error('Error: {}'.format(error))

elif self.data_type in ('domain', 'fqdn', 'url'):
try:
data = self.get_data()
self.ic.url_lookup(data)
self.report({
"prod_category": self.ic.productivityCategory,
"sec_category": self.ic.securityCategory,
"risk_level": self.ic.riskLevel
})
except:
self.error('Error running URL lookup on {}'.format(data))
else:
self.error('Unsupported Data Type')
elif self.service == "submit_static":
filepath = self.get_param('file', None, 'File is missing')
self.ic.submit_file(filepath, "static")
self.ic.file_report_by_jobid(self.ic.jobId, "static")

while self.ic.report is None:
time.sleep(self.polling_interval)
self.ic.file_report_by_jobid(self.ic.jobId, "static")
else:
self.report(self.ic.report)

elif self.service == "submit_dynamic":
filepath = self.get_param('file', None, 'File is missing')
self.ic.submit_file(filepath, "dynamic")
self.ic.file_report_by_jobid(self.ic.jobId, "dynamic")

while self.ic.report is None:
time.sleep(self.polling_interval)
self.ic.file_report_by_jobid(self.ic.jobId, "dynamic")
else:
self.report(self.ic.report)
else:
self.error('Invalid Service Type')

def summary(self, raw):

taxonomies = []
namespace = "Intelix"

if self.service == 'get':
if self.data_type in ('domain', 'fqdn', 'url'):
if self.ic.riskLevel == "UNCLASSIFIED":
level = "info"
elif self.ic.riskLevel == "TRUSTED":
level = "safe"
elif self.ic.riskLevel == "LOW":
level = "info"
elif self.ic.riskLevel == "MEDIUM":
level = "suspicious"
elif self.ic.riskLevel == "HIGH":
level = "malicious"
else:
level = "info"

result = {
"has_result": True
}

predicate = "RiskLevel"
value = "{}".format(self.ic.riskLevel)

taxonomies.append(self.build_taxonomy(level, namespace, predicate, value))
return {"taxonomies": taxonomies}

elif self.data_type == 'hash':
if (self.ic.reputationScore <= 19):
level = "malicious"
elif (self.ic.reputationScore > 19 and self.ic.reputationScore <= 29):
level = "suspicious"
elif (self.ic.reputationScore > 29 and self.ic.reputationScore <= 69):
level = "suspicious"
elif (self.ic.reputationScore > 69 and self.ic.reputationScore <= 100):
level = "safe"
else:
level = "info"

result = {
"has_result": True
}

predicate = "Score"
value = "{} - {}".format(self.ic.reputationScore, self.ic.classification)

taxonomies.append(self.build_taxonomy(level, namespace, predicate, value))
return {"taxonomies": taxonomies}

elif (self.service == "submit_static") or (self.service == "submit_dynamic"):

result = {
"has_result": True
}

predicate = "Score"
value = "{}".format(self.ic.report.get("score"))

if (self.ic.report.get("score") <= 19):
level = "malicious"
elif (self.ic.report.get("score") > 19 and self.ic.report.get("score") <= 29):
level = "suspicious"
elif (self.ic.report.get("score") > 29 and self.ic.report.get("score") <= 69):
level = "suspicious"
elif (self.ic.report.get("score") > 69 and self.ic.report.get("score") <= 100):
level = "safe"
else:
level = "info"

taxonomies.append(self.build_taxonomy(level, namespace, predicate, value))
return {"taxonomies": taxonomies}


if __name__ == '__main__':
SophosIntelixAnalyzer().run()
3 changes: 3 additions & 0 deletions analyzers/SophosIntelix/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cortexutils
requests
intelix
31 changes: 31 additions & 0 deletions thehive-templates/SophosIntelix_GetReport_0_3/long.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="panel panel-danger" ng-if="!success">
<div class="panel-heading">
<strong>{{artifact.data | fang}}</strong>
</div>
<div class="panel-body">
{{content.errorMessage}}
</div>
</div>
<div class="panel panel-primary" ng-if="success">
<div class="panel-info">
<div class="panel-heading">
<strong>Report for {{artifact.data | fang}} </strong>
</div>
<div class="panel-body">
<dl ng-if="::['domain', 'fqdn', 'url'].indexOf(artifact.dataType) != -1">
<dt>Productivity Category</dt>
<dd>{{content.prod_category || "No Data"}}</dd>
<dt>Security Category</dt>
<dd>{{content.sec_category || "No Data"}}</dd>
<dt>Risk Level</dt>
<dd>{{content.risk_level || "No Data"}}</dd>
</dl>
</div>
<div class="panel-body">
<dl ng-if="::artifact.dataType === 'hash'">
<dt>File Classification</dt>
<dd>{{content.classification || "No Data"}}</dd>
</dl>
</div>
</div>
</div>
3 changes: 3 additions & 0 deletions thehive-templates/SophosIntelix_GetReport_0_3/short.html
Original file line number Diff line number Diff line change
@@ -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