-
Notifications
You must be signed in to change notification settings - Fork 379
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
Adding Patrowl analyzer #386
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
env | ||
.DS_Store |
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,26 @@ | ||
{ | ||
"name": "Patrowl_GetReport", | ||
"version": "1.0", | ||
"author": "Nicolas Mattiocco", | ||
"url": "https://github.com/TheHive-Project/Cortex-Analyzers", | ||
"license": "AGPL-V3", | ||
"description": "Get the current Patrowl report for a fdqn, a domain or an IP address.", | ||
"dataTypeList": ["fqdn", "domain", "ip"], | ||
"baseConfig": "Patrowl", | ||
"config": { | ||
"url": "http://my.patrowl.io:8000", | ||
"service": "getreport", | ||
"username": "cortex", | ||
"password": "Bonjour1!" | ||
}, | ||
"configurationItems": [ | ||
{ | ||
"name": "url", | ||
"description": "Define the PatrOwl url", | ||
"type": "string", | ||
"multi": false, | ||
"required": true | ||
} | ||
], | ||
"command": "Patrowl/patrowl.py" | ||
} |
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,10 @@ | ||
![](https://github.com/Patrowl/PatrowlDocs/blob/master/images/logos/logo-patrowl-light.png) | ||
|
||
[![Join the chat at https://gitter.im/Patrowl/Support](https://badges.gitter.im/Patrowl/Support.png)](https://gitter.im/Patrowl/Support) | ||
|
||
# **PatrOwl** | ||
[PatrOwl](https://www.patrowl.io/) is a scalable, free and open-source solution for orchestrating Security Operations. | ||
**PatrowlManager** is the Front-end application for managing the assets, reviewing risks on real-time, orchestrating the operations (scans, searches, API calls, ...), aggregating the results, relaying alerts on third parties (ex: Incident Response platform like [TheHive](https://github.com/TheHive-Project/TheHive/), Splunk, ...) and providing the reports and dashboards. Operations are performed by the [PatrowlEngines](https://github.com/Patrowl/PatrowlEngines/) instances. Don't forget to install and deploy them ;) | ||
|
||
# Installation | ||
See [Cortex Installation Guide](https://github.com/TheHive-Project/CortexDocs). |
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,77 @@ | ||
#!/usr/bin/env python | ||
# encoding: utf-8 | ||
"""Patrowl Analyzer for Cortex.""" | ||
|
||
import requests | ||
from cortexutils.analyzer import Analyzer | ||
|
||
|
||
class PatrowlAnalyzer(Analyzer): | ||
"""PatrowlAnalyzer Class definition.""" | ||
|
||
def __init__(self): | ||
"""Initialize the Analyzer.""" | ||
Analyzer.__init__(self) | ||
self.service = self.getParam('config.service', None, 'Patrowl service is missing') | ||
self.url = self.getParam('config.url', None, 'Patrowl URL is missing').rstrip("/") | ||
self.username = self.getParam('config.username', None, 'Patrowl Username is missing') | ||
self.password = self.getParam('config.password', None, 'Patrowl Password is missing') | ||
|
||
def summary(self, raw): | ||
"""Parse, format and return scan summary.""" | ||
taxonomies = [] | ||
level = "info" | ||
namespace = "Patrowl" | ||
|
||
# getreport service | ||
if self.service == 'getreport': | ||
if 'risk_level' in raw and raw['risk_level']: | ||
|
||
# Grade | ||
if raw['risk_level']['grade'] in ["A", "B"]: | ||
level = "safe" | ||
else: | ||
level = "suspicious" | ||
taxonomies.append(self.build_taxonomy( | ||
level, namespace, "Grade", raw['risk_level']['grade'])) | ||
|
||
# Findings | ||
if raw['risk_level']['high'] > 0: | ||
level = "malicious" | ||
elif raw['risk_level']['medium'] > 0 or raw['risk_level']['low'] > 0: | ||
level = "suspicious" | ||
else: | ||
level = "info" | ||
taxonomies.append(self.build_taxonomy( | ||
level, namespace, "Findings", "{}/{}/{}/{}".format( | ||
raw['risk_level']['high'], | ||
raw['risk_level']['medium'], | ||
raw['risk_level']['low'], | ||
raw['risk_level']['info'] | ||
))) | ||
#todo: add_asset service | ||
|
||
return {"taxonomies": taxonomies} | ||
|
||
def run(self): | ||
"""Run the analyzer.""" | ||
Analyzer.run(self) | ||
data = self.getData() | ||
|
||
try: | ||
if self.service == 'getreport': | ||
service_url = self.url+"/assets/api/v1/details/"+data | ||
response = requests.get(service_url, auth=requests.auth.HTTPBasicAuth(self.username, self.password)) | ||
|
||
self.report(response.json()) | ||
|
||
else: | ||
self.error('Unknown Patrowl service') | ||
|
||
except Exception as e: | ||
self.unexpectedError(e) | ||
|
||
|
||
if __name__ == '__main__': | ||
"""Main function.""" | ||
PatrowlAnalyzer().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 @@ | ||
cortexutils | ||
requests |
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,89 @@ | ||
<div class="report-Patrowl" ng-if="success"> | ||
<style> | ||
.report-Patrowl dl { | ||
margin-bottom: 2px; | ||
} | ||
.report-Patrowl .patrowl-info { | ||
background-color: #3B4CA1; | ||
} | ||
.report-Patrowl .patrowl-low { | ||
background-color: #79AB3D; | ||
} | ||
.report-Patrowl .patrowl-medium { | ||
background-color: #D5C920; | ||
} | ||
.report-Patrowl .patrowl-high { | ||
background-color: #D39F27; | ||
} | ||
.report-Patrowl .patrowl-critical { | ||
background-color: #C61010; | ||
} | ||
</style> | ||
|
||
<div class="panel panel-info"> | ||
<div class="panel-heading"> | ||
<strong>Patrowl Report</strong> | ||
</div> | ||
<div class="panel-body"> | ||
<h4>Asset Information for {{content.value}}</h4> | ||
<dl class="dl-horizontal"> | ||
<dt>Name</dt> | ||
<dd>{{content.name}}</dd> | ||
<dt>Criticity</dt> | ||
<dd><label class="label patrowl-{{content.criticity}}">{{content.criticity}}</label></dd> | ||
<dt>DataType</dt> | ||
<dd>{{content.type}}</dd> | ||
<dt>Description</dt> | ||
<dd>{{content.description}}</dd> | ||
<dt>Findings summary</dt> | ||
<dd> | ||
<div class="progress"> | ||
<div class="progress-bar patrowl-info" ng-style="{width:(content.risk_level.info *100)/(content.risk_level.total)+'%'}"> | ||
<span>{{content.risk_level.info}}</span> | ||
</div> | ||
<div class="progress-bar patrowl-low" ng-style="{width:(content.risk_level.low *100)/(content.risk_level.total)+'%'}"> | ||
<span>{{content.risk_level.low}}</span> | ||
</div> | ||
<div class="progress-bar patrowl-medium" ng-style="{width:(content.risk_level.medium *100)/(content.risk_level.total)+'%'}"> | ||
<span>{{content.risk_level.medium}}</span> | ||
</div> | ||
<div class="progress-bar patrowl-high" ng-style="{width:(content.risk_level.high *100)/(content.risk_level.total)+'%'}"> | ||
<span>{{content.risk_level.high}}</span> | ||
</div> | ||
</div> | ||
</dd> | ||
</dl> | ||
<br> | ||
<hr> | ||
<h4>Findings Reports</h4> | ||
<div ng-if="content.findings" ng-repeat="finding in content.findings"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<strong>{{finding.title}}</strong> | ||
</div> | ||
<div class="panel-body"> | ||
<dl class="dl-horizontal" nf-if="finding.severity" > | ||
<dt>Severity</dt> | ||
<dd><label class="label patrowl-{{finding.severity}}">{{finding.severity}}</label></dd> | ||
<dt>Description</dt> | ||
<dd>{{finding.description}}</dd> | ||
<dt>From engine</dt> | ||
<dd>{{finding.engine_type}}</dd> | ||
</dl> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<!-- General error --> | ||
<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> |
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,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> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These conf properties should be made customizable, and declared as ConfigurationItems. Note that the anlyzer should use an API_KEY instead of username/password couple