From bec9cdd4d0231b124c2a92f1e7f4adc63b2521f3 Mon Sep 17 00:00:00 2001 From: Austin Taylor Date: Sat, 30 Dec 2017 20:21:08 -0500 Subject: [PATCH] Addition of VulnWhisperer-Qualys logstash files --- logstash/2000_qualys_web_scans.conf | 147 ++++++++++++++++++++++++++++ setup.py | 2 +- vulnwhisp/vulnwhisp.py | 1 - 3 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 logstash/2000_qualys_web_scans.conf diff --git a/logstash/2000_qualys_web_scans.conf b/logstash/2000_qualys_web_scans.conf new file mode 100644 index 0000000..78cf5da --- /dev/null +++ b/logstash/2000_qualys_web_scans.conf @@ -0,0 +1,147 @@ +# Author: Austin Taylor and Justin Henderson +# Email: austin@hasecuritysolutions.com +# Last Update: 12/30/2017 +# Version 0.3 +# Description: Take in qualys web scan reports from vulnWhisperer and pumps into logstash + +input { + file { + path => "/opt/VulnWhisperer/scans/**/*.json" + type => json + codec => json + start_position => "beginning" + tags => [ "qualys_web", "qualys" ] + } +} + +filter { + if "qualys_web" in [tags] { + mutate { + replace => [ "message", "%{message}" ] + #gsub => [ + # "message", "\|\|\|", " ", + # "message", "\t\t", " ", + # "message", " ", " ", + # "message", " ", " ", + # "message", " ", " ", + # "message", "nan", " ", + # "message",'\n','' + #] + } + + + grok { + match => { "path" => "qualys_web_%{INT:app_id}_%{INT:last_updated}.json$" } + tag_on_failure => [] + } + + mutate { + add_field => { "asset" => "%{web_application_name}" } + add_field => { "risk_score" => "%{cvss}" } + } + + if [risk] == "1" { + mutate { add_field => { "risk_number" => 0 }} + mutate { replace => { "risk" => "info" }} + } + if [risk] == "2" { + mutate { add_field => { "risk_number" => 1 }} + mutate { replace => { "risk" => "low" }} + } + if [risk] == "3" { + mutate { add_field => { "risk_number" => 2 }} + mutate { replace => { "risk" => "medium" }} + } + if [risk] == "4" { + mutate { add_field => { "risk_number" => 3 }} + mutate { replace => { "risk" => "high" }} + } + if [risk] == "5" { + mutate { add_field => { "risk_number" => 4 }} + mutate { replace => { "risk" => "critical" }} + } + + mutate { + remove_field => "message" + } + + if [first_time_detected] { + date { + match => [ "first_time_detected", "dd MMM yyyy HH:mma 'GMT'ZZ", "dd MMM yyyy HH:mma 'GMT'" ] + target => "first_time_detected" + } + } + if [first_time_tested] { + date { + match => [ "first_time_tested", "dd MMM yyyy HH:mma 'GMT'ZZ", "dd MMM yyyy HH:mma 'GMT'" ] + target => "first_time_tested" + } + } + if [last_time_detected] { + date { + match => [ "last_time_detected", "dd MMM yyyy HH:mma 'GMT'ZZ", "dd MMM yyyy HH:mma 'GMT'" ] + target => "last_time_detected" + } + } + if [last_time_tested] { + date { + match => [ "last_time_tested", "dd MMM yyyy HH:mma 'GMT'ZZ", "dd MMM yyyy HH:mma 'GMT'" ] + target => "last_time_tested" + } + } + date { + match => [ "last_updated", "UNIX" ] + target => "@timestamp" + remove_field => "last_updated" + } + mutate { + convert => { "plugin_id" => "integer"} + convert => { "id" => "integer"} + convert => { "risk_number" => "integer"} + convert => { "risk_score" => "float"} + convert => { "total_times_detected" => "integer"} + convert => { "cvss_temporal" => "float"} + convert => { "cvss" => "float"} + } + if [risk_score] == 0 { + mutate { + add_field => { "risk_score_name" => "info" } + } + } + if [risk_score] > 0 and [risk_score] < 3 { + mutate { + add_field => { "risk_score_name" => "low" } + } + } + if [risk_score] >= 3 and [risk_score] < 6 { + mutate { + add_field => { "risk_score_name" => "medium" } + } + } + if [risk_score] >=6 and [risk_score] < 9 { + mutate { + add_field => { "risk_score_name" => "high" } + } + } + if [risk_score] >= 9 { + mutate { + add_field => { "risk_score_name" => "critical" } + } + } + + if [asset] =~ "\.yourdomain\.(com|net)$" { + mutate { + add_tag => [ "critical_asset" ] + } + } + } +} +output { + if "qualys" in [tags] { + stdout { codec => rubydebug } + elasticsearch { + hosts => [ "localhost:9200" ] + index => "logstash-vulnwhisperer-%{+YYYY.MM}" + } + } +} diff --git a/setup.py b/setup.py index fa92ce9..4874128 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup, find_packages setup( name='VulnWhisperer', - version='1.0.1', + version='1.2.0', packages=find_packages(), url='https://github.com/austin-taylor/vulnwhisperer', license="""MIT License diff --git a/vulnwhisp/vulnwhisp.py b/vulnwhisp/vulnwhisp.py index 3249763..5cccf74 100755 --- a/vulnwhisp/vulnwhisp.py +++ b/vulnwhisp/vulnwhisp.py @@ -589,7 +589,6 @@ class vulnWhispererQualys(vulnWhispererBase): for app in self.scans_to_process.iterrows(): counter += 1 r = app[1] - print('Processing %s/%s' % (counter, len(self.scans_to_process))) self.whisper_reports(report_id=r['id'], launched_date=r['launchedDate'],