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

New analyzer: Hunter.io #294

Merged
merged 3 commits into from
Sep 3, 2018
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
22 changes: 22 additions & 0 deletions analyzers/Hunterio/Hunterio_domainsearch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Hunterio_DomainSearch",
"author": "Rémi Allain, Cyberprotect",
"license": "AGPL-V3",
"url": "https://github.com/Cyberprotect/Cortex-Analyzers",
"version": "1.0",
"description": "hunter.io is a service to find email addresses from a domain.",
"dataTypeList": ["domain", "fqdn"],
"command": "Hunterio/hunterio_analyzer.py",
"baseConfig": "Hunterio",
"config": {
"service": "domainsearch",
"check_tlp": false
},
"configurationItems": [{
"name": "key",
"description": "api key of hunter.io",
"type": "string",
"multi": false,
"required": true
}]
}
58 changes: 58 additions & 0 deletions analyzers/Hunterio/hunterio_analyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
# encoding: utf-8

import requests
from cortexutils.analyzer import Analyzer


class Hunterio(Analyzer):
URI = "https://api.hunter.io/v2/"


def __init__(self):
Analyzer.__init__(self)
self.service = self.get_param('config.service', None, 'Service parameter is missing')
self.key = self.get_param('config.key', None, 'Missing hunter.io API key')

def summary(self, raw):

taxonomies = []
namespace = "Hunter.io"
if self.service == 'domainsearch':
found = 0
if(raw.get('meta') and raw['meta'].get('results')):
found = raw['meta'].get('results')
taxonomies.append(self.build_taxonomy('info', namespace, "Emails found", found))

return {"taxonomies": taxonomies}


def run(self):
Analyzer.run(self)

if self.service == 'domainsearch' and (self.data_type == 'domain' or self.data_type == 'fqdn'):
try:
offset = 0
firstResponse = requests.get("{}domain-search?domain={}&api_key={}&limit=100&offset={}".format(self.URI, self.get_data(), self.key, offset))
firstResponse = firstResponse.json()

if firstResponse.get('meta'):
meta = firstResponse.get('meta')

while meta.get('results') > offset:
offset = meta.get('limit') + meta.get('offset')
additionalResponse = requests.get("{}domain-search?domain={}&api_key={}&limit=100&offset={}".format(
self.URI, self.get_data(), self.key, offset))
additionalResponse = additionalResponse.json()
meta = additionalResponse.get('meta')
firstResponse['data']['emails'] += additionalResponse['data']['emails']

self.report(firstResponse)
except Exception as e:
self.unexpectedError(e)
else:
self.notSupported()


if __name__ == '__main__':
Hunterio().run()
2 changes: 2 additions & 0 deletions analyzers/Hunterio/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cortexutils
requests
66 changes: 66 additions & 0 deletions thehive-templates/Hunterio_DomainSearch_1_0/long.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<div class="panel panel-info" ng-if="success">
<div class="panel-heading">
<a href="https://hunter.io" target="_blank">hunter.io</a> domain search to find email addresses
<br/> Report for
<strong>{{artifact.data}}</strong>
</div>
<div class="panel-body" ng-if="content.meta">

<h4 class="dl-horizontal">{{content.meta.results}} addresses found.</h4>


<div ng-if="content.data">

<h5>
Pattern : {{content.data.pattern}}
</h5>

<h5>
Organization: {{content.data.organization}}
</h5>

<table class="table table-bordered">
<tr>
<th>Email</th>
<th>Name</th>
<th>Position</th>
<th>Type</th>
<th>Twitter</th>
<th>LinkedIn</th>
<th>Phone</th>
<th>Confidence</th>
<th>Sources</th>
</tr>
<tr ng-repeat="email in ::content.data.emails">
<td class="text-info">{{email.value}}</td>
<td>{{email.fisrtname}} {{email.lastname}}</td>
<td>{{email.position}}</td>
<td>{{email.type}}</td>
<td><a ng-if="email.twitter" href="https://twitter.com/{{email.twitter}}" target="_blank">{{email.twitter}}</a></td>
<td><a ng-if="email.linkedin" href="{{email.linkedin}}" target="_blank">{{email.linkedin}}</a></td>
<td>{{email.phone_number}}</td>
<td>
<span class="label label-default">{{email.confidence}}</span>
</td>
<td>
<ul>
<li ng-repeat="src in ::email.sources">{{src.domain}}</li>
</ul>
</td>
</tr>
</table>
</div>

<div class="panel-body" ng-if="!content.meta">
No results found
</div>
</div>

<div class="panel panel-danger" ng-if="!success">
<div class="panel-heading">
<strong>{{(artifact.data || artifact.attachment.name) | fang}}</strong>
</div>
<div class="panel-body">
{{content.errorMessage}}
</div>
</div>
3 changes: 3 additions & 0 deletions thehive-templates/Hunterio_DomainSearch_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>