-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,527 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
analyzers/DomainToolsIris/DomainToolsIris_Investigate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "DomainToolsIris_Investigate", | ||
"version": "1.0", | ||
"author": "DomainTools", | ||
"url": "https://github.com/TheHive-Project/Cortex-Analyzers", | ||
"license": "AGPL-V3", | ||
"description": "Use DomainTools Iris API to investigate a domain.", | ||
"dataTypeList": ["domain"], | ||
"command": "DomainToolsIris/domaintoolsiris_analyzer.py", | ||
"baseConfig": "DomainToolsIris", | ||
"config": { | ||
"service": "investigate-domain" | ||
}, | ||
"configurationItems": [ | ||
{ | ||
"name": "username", | ||
"description": "DomainTools Iris API credentials", | ||
"type": "string", | ||
"multi": false, | ||
"required": true | ||
}, | ||
{ | ||
"name": "key", | ||
"description": "DomainTools Iris API credentials", | ||
"type": "string", | ||
"multi": false, | ||
"required": true | ||
}, | ||
{ | ||
"name": "pivot_count_threshold", | ||
"description": "Pivot count threshold.", | ||
"type": "number", | ||
"multi": false, | ||
"required": false, | ||
"defaultValue": 500 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "IntezerCommunity", | ||
"version": "1.0", | ||
"author": "Matteo Lodi", | ||
"url": "https://github.com/TheHive-Project/Cortex-Analyzers", | ||
"license": "AGPL-v3", | ||
"description": "Analyze a possible malicious file with Intezer Analyzer", | ||
"dataTypeList": ["file"], | ||
"baseConfig": "IntezerCommunity", | ||
"command": "IntezerCommunity/intezer_community.py", | ||
"configurationItems": [ | ||
{ | ||
"name": "key", | ||
"description": "API key for Intezer", | ||
"type": "string", | ||
"multi": false, | ||
"required": true | ||
} | ||
], | ||
"config": { | ||
"check_tlp": true, | ||
"max_tlp": 2, | ||
"auto_extract": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import requests | ||
import time | ||
import os | ||
|
||
from cortexutils.analyzer import Analyzer | ||
|
||
|
||
class IntezerCommunityAnalyzer(Analyzer): | ||
""" | ||
Intezer Community APIs: https://analyze.intezer.com/api/docs/documentation | ||
""" | ||
|
||
def run(self): | ||
|
||
try: | ||
|
||
if self.data_type == 'file': | ||
api_key = self.get_param('config.key', None, 'Missing Intezer API key') | ||
filepath = self.get_param('file', None, 'File is missing') | ||
filename = self.get_param('filename', os.path.basename(filepath)) | ||
|
||
base_url = 'https://analyze.intezer.com/api/v2-0' | ||
# this should be done just once in a day, but we cannot do that with Cortex Analyzers | ||
response = requests.post(base_url + '/get-access-token', json={'api_key': api_key}) | ||
response.raise_for_status() | ||
session = requests.session() | ||
session.headers['Authorization'] = session.headers['Authorization'] = 'Bearer %s' % response.json()[ | ||
'result'] | ||
|
||
with open(filepath, 'rb') as file_to_upload: | ||
files = {'file': (filename, file_to_upload)} | ||
response = session.post(base_url + '/analyze', files=files) | ||
if response.status_code != 201: | ||
self.error('Error sending file to Intezer Analyzer\n{}'.format(response.text)) | ||
|
||
while response.status_code != 200: | ||
time.sleep(3) | ||
result_url = response.json()['result_url'] | ||
response = session.get(base_url + result_url) | ||
response.raise_for_status() | ||
|
||
report = response.json() | ||
self.report(report) | ||
|
||
else: | ||
self.notSupported() | ||
|
||
except requests.HTTPError as e: | ||
self.error(e) | ||
except Exception as e: | ||
self.unexpectedError(e) | ||
|
||
def summary(self, raw): | ||
taxonomies = [] | ||
namespace = 'IntezerCommunity' | ||
|
||
if 'status' in raw and raw['status'] == 'succeeded': | ||
predicate = 'Analysis succeeded' | ||
else: | ||
predicate = 'Analysis failed' | ||
|
||
level = 'info' | ||
value = 'no family' | ||
if 'result' in raw: | ||
if 'verdict' in raw['result']: | ||
level = raw['result']['verdict'] | ||
if level == 'trusted': | ||
level = 'safe' | ||
if level not in ['info', 'safe', 'suspicious', 'malicious']: | ||
level = 'info' | ||
if 'family_name' in raw['result']: | ||
value = raw['result']['family_name'] | ||
|
||
taxonomies.append(self.build_taxonomy(level, namespace, predicate, value)) | ||
|
||
return {'taxonomies': taxonomies} | ||
|
||
|
||
if __name__ == '__main__': | ||
IntezerCommunityAnalyzer().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
requests | ||
cortexutils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "NSRL", | ||
"author": "Andrea Garavaglia, Davide Arcuri - LDO-CERT", | ||
"license": "AGPL-V3", | ||
"url": "https://github.com/TheHive-Project/Cortex-Analyzers", | ||
"version": "1.0", | ||
"description": "Query NSRL", | ||
"dataTypeList": [ | ||
"hash", | ||
"filename" | ||
], | ||
"baseConfig": "NSRL", | ||
"command": "NSRL/nsrl.py", | ||
"configurationItems": [ | ||
{ | ||
"name": "conn", | ||
"description": "sqlalchemy connection string", | ||
"multi": false, | ||
"required": false, | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "grep_path", | ||
"description": "path of grep", | ||
"type": "string", | ||
"multi": false, | ||
"required": false | ||
}, | ||
{ | ||
"name": "nsrl_folder", | ||
"description": "path of NSRL folder", | ||
"type": "string", | ||
"multi": false, | ||
"required": false | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
import sqlalchemy as db | ||
from glob import glob | ||
|
||
conn_string = "<insert postgres connection string >" | ||
NSRL_folder_path = "/path/to/NSRLFolder/*" | ||
|
||
engine = db.create_engine(conn_string) | ||
metadata = db.MetaData() | ||
|
||
nsrl = db.Table( | ||
"nsrl", | ||
metadata, | ||
db.Column("id", db.Integer, primary_key=True, autoincrement=True), | ||
db.Column("sha1", db.String), | ||
db.Column("md5", db.String), | ||
db.Column("crc32", db.String), | ||
db.Column("filename", db.String), | ||
db.Column("filesize", db.String), | ||
db.Column("productcode", db.String), | ||
db.Column("opsystemcode", db.String), | ||
db.Column("specialcode", db.String), | ||
db.Column("dbname", db.String), | ||
db.Column("release", db.String), | ||
db.Index("idx_sha1", "sha1"), | ||
db.Index("idx_md5", "md5"), | ||
) | ||
metadata.create_all(engine) | ||
|
||
conn = engine.raw_connection() | ||
cursor = conn.cursor() | ||
for NSRL_file_path in glob(NSRL_folder_path): | ||
dbname, release = NSRL_file_path.split("/")[-1].replace(".txt","").split("_") | ||
print(dbname, release) | ||
with open(NSRL_file_path, "r", encoding="latin-1") as f: | ||
cmd = 'COPY nsrl("sha1", "md5", "crc32", "filename", "filesize", "productcode", "opsystemcode", "specialcode") FROM STDIN WITH (FORMAT CSV, DELIMITER ",", HEADER TRUE)' | ||
cursor.copy_expert(cmd, f) | ||
conn.commit() | ||
engine.execute("update nsrl set dbname='%s', release='%s' where dbname is null" % (dbname, release)) | ||
conn.commit() | ||
cursor.close() | ||
conn.close() | ||
engine.dispose() |
Oops, something went wrong.