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

support both cuckoo versions #100

Merged
merged 6 commits into from
Nov 3, 2017
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
33 changes: 24 additions & 9 deletions analyzers/CuckooSandbox/cuckoosandbox_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def __init__(self):
Analyzer.__init__(self)
self.service = self.getParam('config.service', None, 'CuckooSandbox service is missing')
self.url = self.getParam('config.url', None, 'CuckooSandbox url is missing')
self.url = self.url + "/" if not self.url.endswith("/") else self.url
#self.analysistimeout = self.getParam('config.analysistimeout', 30*60, None)
#self.networktimeout = self.getParam('config.networktimeout', 30, None)

Expand Down Expand Up @@ -54,7 +55,7 @@ def run(self):
with open(filepath, "rb") as sample:
files = {"file": (filename, sample)}
response = requests.post(self.url + 'tasks/create/file', files=files)
task_id = response.json()['task_ids'][0]
task_id = response.json()['task_ids'][0] if 'task_ids' in response.json().keys() else response.json()['task_id']

# url analysis
elif self.service == 'url_analysis':
Expand Down Expand Up @@ -82,30 +83,45 @@ def run(self):
resp_json = response.json()
list_description = [x['description'] for x in resp_json['signatures']]
if 'suricata' in resp_json.keys() and 'alerts' in resp_json['suricata'].keys():
suri_alerts = [(x['signature'],x['dstip'],x['dstport'],x['severity']) for x in resp_json['suricata']['alerts']]
if 'dstport' in resp_json['suricata']['alerts'].keys():
suri_alerts = [(x['signature'],x['dstip'],x['dstport'],x['severity']) for x in resp_json['suricata']['alerts']]
elif 'dst_port' in resp_json['suricata']['alerts'].keys():
suri_alerts = [(x['signature'],x['dst_ip'],x['dst_port'],x['severity']) for x in resp_json['suricata']['alerts']]
else:
suri_alerts = []
hosts = [(x['ip'],x['hostname'],x['country_name']) for x in resp_json['network']['hosts']]
uri = [(x['uri']) for x in resp_json['network']['http']]
if 'snort' in resp_json.keys() and 'alerts' in resp_json['snort'].keys():
if 'dstport' in resp_json['snort']['alerts'].keys():
snort_alerts = [(x['message'],x['dstip'],x['dstport'],x['priority']) for x in resp_json['snort']['alerts']]
elif 'dst_port' in resp_json['snort']['alerts'].keys():
snort_alerts = [(x['message'],x['dst_ip'],x['dst_port'],x['priority']) for x in resp_json['snort']['alerts']]
else:
snort_alerts = []
try:
hosts = [(x['ip'],x['hostname'],x['country_name']) for x in resp_json['network']['hosts']] if 'hosts' in resp_json['network'].keys() else None
except TypeError as e:
hosts = [x for x in resp_json['network']['hosts']] if 'hosts' in resp_json['network'].keys() else []
uri = [(x['uri']) for x in resp_json['network']['http']] if 'http' in resp_json['network'].keys() else []
if self.service == 'url_analysis':
self.report({
'signatures': list_description,
'suricata_alerts': suri_alerts,
'snort_alerts': snort_alerts,
'hosts': hosts,
'uri': uri,
'malscore': resp_json['malscore'],
'malfamily': resp_json['malfamily'],
'malscore': resp_json['malscore'] if 'malscore' in resp_json.keys() else resp_json['info'].get('score', None),
'malfamily': resp_json.get('malfamily', None),
'file_type': 'url',
'yara': resp_json['target']['url'] if 'target' in resp_json.keys() and 'url' in resp_json['target'].keys() else '-'
})
else:
self.report({
'signatures': list_description,
'suricata_alerts': suri_alerts,
'snort_alerts': snort_alerts,
'hosts': hosts,
'uri': uri,
'malscore': resp_json['malscore'],
'malfamily': resp_json['malfamily'],
'malscore': resp_json['malscore'] if 'malscore' in resp_json.keys() else resp_json['info'].get('score', None),
'malfamily': resp_json.get('malfamily', None),
'file_type': "".join([x for x in resp_json['target']['file']['type']]),
'yara': [ x['name'] + " - " + x['meta']['description'] if 'description' in x['meta'].keys() else x['name'] for x in resp_json['target']['file']['yara'] ]
})
Expand All @@ -118,4 +134,3 @@ def run(self):

if __name__ == '__main__':
CuckooSandboxAnalyzer().run()

25 changes: 19 additions & 6 deletions thehive-templates/CuckooSandbox_File_Analysis_Inet_1_0/long.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,37 @@ <h4>Yara</h4>
</div>
</div>

<div class="panel panel-info">
<div class="panel panel-info" ng-if="content.suricata_alerts">
<div class="panel-heading">
<strong>Suricata</strong>
</div>
<div class="panel-body">

<div ng-if="content.suricata_alerts">
<div>
<h4>Suricata Alerts</h4>
<br>
<dl class="dl-horizontal" ng-repeat="suri in content.suricata_alerts track by $index">
<dd>{{ suri }}<dd>
</dl>
</div>
<div ng-if="!content.suricata_alerts">
No suspicious suricata alerts reported
</div>
</div>
</div>

<div class="panel panel-info" ng-if="content.snort_alerts">
<div class="panel-heading">
<strong>Snort</strong>
</div>
<div class="panel-body">

<div>
<h4>Snort Alerts</h4>
<br>
<dl class="dl-horizontal" ng-repeat="snort in content.snort_alerts track by $index">
<dd>{{ snort }}<dd>
</dl>
</div>

</div>
</div>
</div>


Expand Down
25 changes: 19 additions & 6 deletions thehive-templates/CuckooSandbox_Url_Analysis_1_0/long.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,37 @@ <h4>Yara</h4>
</div>
</div>

<div class="panel panel-info">
<div class="panel panel-info" ng-if="content.suricata_alerts">
<div class="panel-heading">
<strong>Suricata</strong>
</div>
<div class="panel-body">

<div ng-if="content.suricata_alerts">
<div>
<h4>Suricata Alerts</h4>
<br>
<dl class="dl-horizontal" ng-repeat="suri in content.suricata_alerts track by $index">
<dd>{{ suri }}<dd>
</dl>
</div>
<div ng-if="!content.suricata_alerts">
No suspicious suricata alerts reported
</div>
</div>
</div>

<div class="panel panel-info" ng-if="content.snort_alerts">
<div class="panel-heading">
<strong>Snort</strong>
</div>
<div class="panel-body">

<div>
<h4>Snort Alerts</h4>
<br>
<dl class="dl-horizontal" ng-repeat="snort in content.snort_alerts track by $index">
<dd>{{ snort }}<dd>
</dl>
</div>

</div>
</div>
</div>


Expand Down