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

Add TeamCymruMHR Analyzer #580

Merged
merged 1 commit into from
Jan 14, 2020
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
15 changes: 15 additions & 0 deletions analyzers/TeamCymruMHR/TeamCymruMHR.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "TeamCymruMHR",
"version": "1.0",
"author": "Wes Lambert",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Submit hash to Team Cymru's Malware Hash Registry",
"dataTypeList": ["hash"],
"baseConfig": "TeamCymruMHR",
"config": {
"service": "HashLookup"
},
"command": "TeamCymruMHR/TeamCymruMHR.py",
"configurationItems": []
}
39 changes: 39 additions & 0 deletions analyzers/TeamCymruMHR/TeamCymruMHR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
# encoding: utf-8

from cortexutils.analyzer import Analyzer
import dns.resolver
import time

class TeamCymruMHRAnalyzer(Analyzer):
def __init__(self):
Analyzer.__init__(self)
self.observable = self.get_param('data', None, 'Data missing!')

def summary(self, raw):
taxonomies = []
level = 'info'
namespace = 'TeamCymruMHR'

# Set predicate for last_seen
predicate = 'last_seen'
taxonomies.append(self.build_taxonomy(level, namespace, predicate, raw['last_seen']))

# Set predicate for detection percentage
predicate = 'detection_pct'
taxonomies.append(self.build_taxonomy(level, namespace, predicate, raw['detection_pct']))

return {"taxonomies": taxonomies}

def run(self):
lookup = dns.resolver.query(self.observable + '.malware.hash.cymru.com', 'TXT')
for rdata in lookup:
for txt_string in rdata.strings:
last_seen_epoch = str(txt_string).split("\'")[1].split(" ")[0]
# Make timestamp mor readable for humans, but maintain UTC
last_seen = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(last_seen_epoch)))
detection_pct = str(txt_string).split("\'")[1].split(" ")[1]
self.report({ 'last_seen': last_seen, 'detection_pct': detection_pct })

if __name__ == '__main__':
TeamCymruMHRAnalyzer().run()
1 change: 1 addition & 0 deletions analyzers/TeamCymruMHR/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dnspython
16 changes: 16 additions & 0 deletions thehive-templates/TeamCymruMHR_1_0/long.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="panel panel-info">
<div class="panel-heading">
TeamCymru Search Results
</div>
<div class="panel-body">
<table class="table table-hover">
<tr>
<th>Last Seen</th>
<th>Detection Percentage</th>
</tr>
<td>{{content.last_seen | ellipsis:40}}</td>
<td>{{content.detection_pct}}</a></td>
</tr>
</table>
</div>
</div>
3 changes: 3 additions & 0 deletions thehive-templates/TeamCymruMHR_1_0/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>