Skip to content

Commit 8197824

Browse files
weslambertnadouani
authored andcommitted
Add TeamCymruMHR Analyzer (#580)
1 parent eec68ea commit 8197824

5 files changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "TeamCymruMHR",
3+
"version": "1.0",
4+
"author": "Wes Lambert",
5+
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
6+
"license": "AGPL-V3",
7+
"description": "Submit hash to Team Cymru's Malware Hash Registry",
8+
"dataTypeList": ["hash"],
9+
"baseConfig": "TeamCymruMHR",
10+
"config": {
11+
"service": "HashLookup"
12+
},
13+
"command": "TeamCymruMHR/TeamCymruMHR.py",
14+
"configurationItems": []
15+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python3
2+
# encoding: utf-8
3+
4+
from cortexutils.analyzer import Analyzer
5+
import dns.resolver
6+
import time
7+
8+
class TeamCymruMHRAnalyzer(Analyzer):
9+
def __init__(self):
10+
Analyzer.__init__(self)
11+
self.observable = self.get_param('data', None, 'Data missing!')
12+
13+
def summary(self, raw):
14+
taxonomies = []
15+
level = 'info'
16+
namespace = 'TeamCymruMHR'
17+
18+
# Set predicate for last_seen
19+
predicate = 'last_seen'
20+
taxonomies.append(self.build_taxonomy(level, namespace, predicate, raw['last_seen']))
21+
22+
# Set predicate for detection percentage
23+
predicate = 'detection_pct'
24+
taxonomies.append(self.build_taxonomy(level, namespace, predicate, raw['detection_pct']))
25+
26+
return {"taxonomies": taxonomies}
27+
28+
def run(self):
29+
lookup = dns.resolver.query(self.observable + '.malware.hash.cymru.com', 'TXT')
30+
for rdata in lookup:
31+
for txt_string in rdata.strings:
32+
last_seen_epoch = str(txt_string).split("\'")[1].split(" ")[0]
33+
# Make timestamp mor readable for humans, but maintain UTC
34+
last_seen = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(last_seen_epoch)))
35+
detection_pct = str(txt_string).split("\'")[1].split(" ")[1]
36+
self.report({ 'last_seen': last_seen, 'detection_pct': detection_pct })
37+
38+
if __name__ == '__main__':
39+
TeamCymruMHRAnalyzer().run()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dnspython
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="panel panel-info">
2+
<div class="panel-heading">
3+
TeamCymru Search Results
4+
</div>
5+
<div class="panel-body">
6+
<table class="table table-hover">
7+
<tr>
8+
<th>Last Seen</th>
9+
<th>Detection Percentage</th>
10+
</tr>
11+
<td>{{content.last_seen | ellipsis:40}}</td>
12+
<td>{{content.detection_pct}}</a></td>
13+
</tr>
14+
</table>
15+
</div>
16+
</div>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<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]">
2+
{{t.namespace}}:{{t.predicate}}="{{t.value}}"
3+
</span>

0 commit comments

Comments
 (0)