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

Pull in latest release #1

Merged
merged 31 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b6daade
#384 force usage of msg-extractor v0.19
jeromeleonard Dec 5, 2018
0915f2f
#389 update predicate and adapt it to analyzer's flavor
jeromeleonard Dec 5, 2018
ba52be7
Merge branch 'hotfix/1.14.4'
jeromeleonard Dec 5, 2018
f2c2fc0
Added support for enabling/disabling certificate validation
Nov 2, 2018
040b6b7
Added HIBP Analyzer with templates (#367)
crackytsi Nov 29, 2018
156bc51
HIBP_Query - Option to include Unverified Breaches (#381)
Nov 29, 2018
ab13a60
Improve/mailer (#376)
Nov 29, 2018
a85570b
#190 Update the long report and add more summary taxonomies
nadouani Nov 30, 2018
212c790
feat: add SecurityTrails analyzers (#371)
ninoseki Nov 30, 2018
a3ed5cd
#190 Add missing requirements.txt file
nadouani Nov 30, 2018
235fe1c
#370 Fix template folder names, and log template of PassveDNS analyzer
nadouani Nov 30, 2018
45659e0
New analyzer : Cyberprotect ThreatScore (#374)
Nov 30, 2018
c20e65f
#373 Update templates and fix the analyzer response when no records a…
nadouani Nov 30, 2018
984d23b
#373 Update Cyberprotect threatscore analyzer to handle result if no …
nadouani Dec 3, 2018
4719e26
Feature/domain tools more flavors (#321)
amr-cossi Dec 4, 2018
caf611f
Revamp Shodan analyzer (#328)
amr-cossi Dec 4, 2018
08220f0
#327 Use get_param function instead of getParam, and remove useless s…
nadouani Dec 4, 2018
c3aeb7b
#327 Fix author value of new flavors
nadouani Dec 4, 2018
e4476ae
Responder/umbrella blacklister (#383)
Dec 4, 2018
5caf39c
#327 Fix author value of new flavors
nadouani Dec 4, 2018
4afff2e
adding Patrowl analyzer
MaKyOtOx Dec 5, 2018
8b8eefe
#386 Update the config file
nadouani Dec 6, 2018
61327c5
Fix author for some Onyphe and DomainTools analyzers
nadouani Dec 6, 2018
9dac08b
Fix Fortiguard reclassification request URL (#346)
megan201296 Dec 10, 2018
4dcbf3d
Add DNSDB API parameters (#319)
amr-cossi Dec 10, 2018
6b4c14d
#318 Fix some PEP8 issues
nadouani Dec 10, 2018
0cc1564
Change headers to dict and update long template (#393)
Dec 12, 2018
2978d73
Analyzer/Umbrella & Templates (#392)
Dec 12, 2018
674113c
#368 Update type of verify config
nadouani Dec 14, 2018
cab18d1
#386 Use API key authentication instead of basic auth
nadouani Dec 20, 2018
ff96c19
#190 Rename analyzer folder name
nadouani Dec 20, 2018
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
46 changes: 46 additions & 0 deletions analyzers/Cyberprotect/CyberprotectAnalyzer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python
# encoding: utf-8

import requests
from cortexutils.analyzer import Analyzer

class CyberprotectAnalyzer(Analyzer):

URI = "https://threatscore.cyberprotect.fr/api/score/"

def __init__(self):
Analyzer.__init__(self)
self.service = self.get_param('config.service', None, 'Service parameter is missing')

def summary(self, raw):
taxonomies = []
namespace = "Cyberprotect"
if self.service == 'ThreatScore':
level = 'info'
value = 'not in database'
if raw.get('data') and raw.get('scores') and len(raw.get('scores')) > 0:
value = 'not analyzed yet'
if raw['scores'][0].get('score'):
level = 'safe'
value = raw['scores'][0]['score']
if value >= 0.5:
level = 'malicious'
elif value >= 0.25 and value < 0.5:
level = 'suspicious'
taxonomies.append(self.build_taxonomy(level, namespace, self.service, value))
return {"taxonomies": taxonomies}

def run(self):
Analyzer.run(self)
if self.service == 'ThreatScore' and (self.data_type == 'domain' or self.data_type == 'ip'):
try:
response = requests.get("{}{}".format(self.URI, self.get_data()))
result = response.json()
self.report(result if len(result) > 0 else {})
except Exception as e:
self.unexpectedError(e)
else:
self.notSupported()

if __name__ == '__main__':
CyberprotectAnalyzer().run()
15 changes: 15 additions & 0 deletions analyzers/Cyberprotect/Cyberprotect_ThreatScore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "Cyberprotect_ThreatScore",
"author": "Rémi Allain, Cyberprotect",
"license": "AGPL-V3",
"url": "https://github.com/Cyberprotect/Cortex-Analyzers",
"version": "1.0",
"description": "ThreatScore is a cyber threat scoring system provided by Cyberprotect",
"dataTypeList": ["domain", "ip"],
"command": "Cyberprotect/CyberprotectAnalyzer.py",
"baseConfig": "Cyberprotect",
"config": {
"service": "ThreatScore",
"check_tlp": true
}
}
2 changes: 2 additions & 0 deletions analyzers/Cyberprotect/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cortexutils
requests
10 changes: 7 additions & 3 deletions analyzers/DNSDB/dnsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ def __init__(self):

def execute_dnsdb_service(self, client):
data = self.get_data()
rrtype = self.get_param('parameters.rrtype', None, None)
bailiwick = self.get_param('parameters.bailiwick', None, None)
before = self.get_param('parameters.before', None, None)
after = self.get_param('parameters.after', None, None)

if self.service == 'domain_name' and self.data_type in ['domain', 'fqdn']:
return client.query_rrset(data)
return client.query_rrset(data, rrtype=rrtype, bailiwick=bailiwick, before=before, after=after)
elif self.service == 'ip_history' and self.data_type == 'ip':
return client.query_rdata_ip(data)
return client.query_rdata_ip(data, before=before, after=after)
elif self.service == 'name_history' and self.data_type in ['domain', 'fqdn']:
return client.query_rdata_name(data)
return client.query_rdata_name(data, rrtype=rrtype, before=before, after=after)
else:
self.error('Unknown DNSDB service or invalid data type')

Expand Down
30 changes: 30 additions & 0 deletions analyzers/DomainTools/DomainTools_HostingHistory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "DomainTools_HostingHistory",
"version": "2.0",
"author": "ANSSI",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a list of historical registrant, name servers and IP addresses for a domain name.",
"dataTypeList": ["domain"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "hosting-history"
},
"configurationItems": [
{
"name": "username",
"description": "DomainTools API credentials",
"type": "string",
"multi": false,
"required": true
},
{
"name": "key",
"description": "DomainTools API credentials",
"type": "string",
"multi": false,
"required": true
}
]
}
26 changes: 13 additions & 13 deletions analyzers/DomainTools/DomainTools_Reputation.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "DomainTools_Reputation",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a reputation score on a domain or fqdn",
"dataTypeList": ["domain","fqdn"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "reputation"
},
"configurationItems": [
"name": "DomainTools_Reputation",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a reputation score on a domain or fqdn",
"dataTypeList": ["domain","fqdn"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "reputation"
},
"configurationItems": [
{
"name": "username",
"description": "DomainTools API credentials",
Expand Down
26 changes: 13 additions & 13 deletions analyzers/DomainTools/DomainTools_ReverseIP.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "DomainTools_ReverseIP",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a list of domain names sharing the same IP address.",
"dataTypeList": ["ip", "domain","fqdn"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "reverse-ip"
},
"configurationItems": [
"name": "DomainTools_ReverseIP",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a list of domain names sharing the same IP address.",
"dataTypeList": ["ip", "domain","fqdn"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "reverse-ip"
},
"configurationItems": [
{
"name": "username",
"description": "DomainTools API credentials",
Expand Down
30 changes: 30 additions & 0 deletions analyzers/DomainTools/DomainTools_ReverseIPWhois.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "DomainTools_ReverseIPWhois",
"version": "2.0",
"author": "ANSSI",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a list of IP addresses which share the same registrant information.",
"dataTypeList": ["mail", "ip", "domain", "other"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "reverse-ip-whois"
},
"configurationItems": [
{
"name": "username",
"description": "DomainTools API credentials",
"type": "string",
"multi": false,
"required": true
},
{
"name": "key",
"description": "DomainTools API credentials",
"type": "string",
"multi": false,
"required": true
}
]
}
26 changes: 13 additions & 13 deletions analyzers/DomainTools/DomainTools_Risk.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "DomainTools_Risk",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a risk score and evidence details on a domain or fqdn",
"dataTypeList": ["domain","fqdn"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "risk_evidence"
},
"configurationItems": [
"name": "DomainTools_Risk",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get a risk score and evidence details on a domain or fqdn",
"dataTypeList": ["domain","fqdn"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
"service": "risk_evidence"
},
"configurationItems": [
{
"name": "username",
"description": "DomainTools API credentials",
Expand Down
4 changes: 2 additions & 2 deletions analyzers/DomainTools/DomainTools_WhoisLookup.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get the ownership record for a domain with basic registration details.",
"dataTypeList": ["domain"],
"description": "Use DomainTools to get the ownership record for a domain or an IP address with basic registration details parsed.",
"dataTypeList": ["domain", "ip"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "DomainTools_WhoisLookup_IP",
"name": "DomainTools_WhoisLookupUnparsed",
"version": "2.0",
"author": "CERT-BDF",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Use DomainTools to get the ownership record for an IP address with basic registration details.",
"dataTypeList": ["ip"],
"description": "Use DomainTools to get the ownership record for an IP address or a domain without parsing.",
"dataTypeList": ["ip", "domain"],
"command": "DomainTools/domaintools_analyzer.py",
"baseConfig": "DomainTools",
"config": {
Expand Down
37 changes: 32 additions & 5 deletions analyzers/DomainTools/domaintools_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,38 @@ def domaintools(self, data):
elif self.service == 'whois/history' and self.data_type == 'domain':
response = api.whois_history(data).response()

elif self.service == 'whois/parsed' and self.data_type == 'domain':
elif self.service == 'whois/parsed' and self.data_type in ['domain','ip']:
response = api.parsed_whois(data).response()

elif self.service == 'hosting-history' and self.data_type == 'domain':
response = api.hosting_history(data).response()

elif self.service == 'risk_evidence' and self.data_type in ['domain', 'fqdn']:
response = api.risk_evidence(data).response()

elif self.service == 'reputation' and self.data_type in ['domain', 'fqdn']:
response = api.reputation(data, include_reasons=True).response()

elif self.service == 'reverse-whois':
response = api.reverse_whois(data, mode='purchase').response()
scope = self.getParam('parameters.scope', 'current', None)
response = api.reverse_whois(data, mode='purchase', scope=scope).response()

elif self.service == 'whois' and self.data_type == 'ip':
elif self.service == 'reverse-ip-whois':
response = api.reverse_ip_whois(data).response()

elif self.service == 'whois' and self.data_type in ['domain', 'ip']:
response = api.whois(data).response()

return response


def summary(self, raw):

r = {
"service": self.service,
"dataType": self.data_type
}

if "ip_addresses" in raw:
if type(raw["ip_addresses"]) == dict:
r["ip"] = {
Expand All @@ -87,14 +95,23 @@ def summary(self, raw):
"historic": raw["domain_count"]["historic"]
}

if "registrar_history" in raw:
r["registrar_history"] = len(raw["registrar_history"])
if "ip_history" in raw:
r["ip_history"] = len(raw["ip_history"])
if "nameserver_history" in raw:
r["ns_history"] = len(raw["nameserver_history"])

if "record_count" in raw:
r["record_count"] = raw["record_count"]

if "registrant" in raw:
r["registrant"] = raw["registrant"]
elif "response" in raw and "registrant" in raw["response"]:
r["registrant"] = raw["response"]["registrant"]

if "parsed_whois" in raw:
r["registrar"] = raw["parsed_whois"]["registrar"]["name"]
#

if "name_server" in raw:
r["name_server"] = raw["name_server"]["hostname"]
Expand Down Expand Up @@ -123,6 +140,16 @@ def summary(self, raw):
r["domain_count"][
"historic"])))

if r["service"] == "reverse-ip-whois":
taxonomies.append(self.build_taxonomy("info", "DT", "Reverse_IP_Whois",
"records:{}".format(r["record_count"])))

if r["service"] == "hosting-history":
taxonomies.append(self.build_taxonomy("info", "DT", "Hosting_History",
"registrars:{} / ips:{} / ns:{}".format(r["registrar_history"],
r["ip_history"],
r["ns_history"])))

if r["service"] == "whois/history":
taxonomies.append(self.build_taxonomy("info", "DT", "Whois_History",
"{} {}".format(r["record_count"], "records" if r["record_count"] > 1 else "record")))
Expand Down
2 changes: 1 addition & 1 deletion analyzers/EmlParser/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def parseEml(filepath):
#cause eml_parser does not provide raw headers (as far as I know)
hParser = email.parser.HeaderParser()
h = hParser.parsestr(raw_eml)
result['headers'] = (str(h).split('\n\n')[0])
result['headers'] = dict(h)

parsed_eml = eml_parser.eml_parser.decode_email(filepath, include_raw_body=True, include_attachment_data=True)
#parsed_eml['header'].keys() gives:
Expand Down
2 changes: 1 addition & 1 deletion analyzers/FileInfo/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ pefile
git+https://github.com/AnyMaster/pehashng
git+https://github.com/Rafiot/pdfid.git
oletools>=0.52
git+https://github.com/mattgwwalker/msg-extractor.git
git+https://github.com/mattgwwalker/msg-extractor.git@v0.19
IMAPClient
25 changes: 25 additions & 0 deletions analyzers/HIBP/HIBP_Query.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "HIBP_Query",
"version": "1.0",
"author": "Matt Erasmus",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Query haveibeenpwned.com for a compromised email address",
"dataTypeList": ["mail"],
"baseConfig": "HIBP",
"config": {
"service": "query",
"url": "https://haveibeenpwned.com/api/v2/breachedaccount/"
},
"command": "HIBP_Query/hibpquery_analyzer.py",
"configurationItems": [
{
"name": "unverified",
"description": "Include unverified breaches",
"type": "boolean",
"multi": false,
"required": true,
"defaultValue": true
}
]
}
Loading