risu 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,101 @@
1
+ # Copyright (c) 2010-2013 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ #OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ #OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ module Risu
28
+ module Parsers
29
+ module Nessus
30
+ module PostProcess
31
+ class RiskScore
32
+
33
+ #
34
+ def initialize
35
+ end
36
+
37
+ # Calculates the RiskScore for a Item which is == to the Plugin's
38
+ # RiskScore
39
+ #
40
+ def calculate_item_risk_score
41
+ Item.all.each do |item|
42
+ plugin = Plugin.where(:id => item.plugin_id).first
43
+
44
+ risk_score = 0.0
45
+ cvss_base_score = plugin.cvss_base_score.to_f || 1.0
46
+ vuln_publication_date = plugin.vuln_publication_date
47
+
48
+ vuln_pub_days = 1
49
+ vuln_pub_days = (DateTime.now.to_date - vuln_publication_date.to_date).to_i if vuln_publication_date != nil
50
+
51
+ exploitable = plugin.exploit_available
52
+ exploitable_factor = 1
53
+
54
+ if exploitable == "true"
55
+ exploitable_factor = 0.6
56
+ end
57
+
58
+ risk_score = (cvss_base_score * vuln_pub_days * 0.8) * exploitable_factor
59
+
60
+ item.risk_score = risk_score
61
+ item.save
62
+ end
63
+ end
64
+
65
+ #
66
+ def calculate_plugin_risk_score
67
+ Plugin.all.each do |plugin|
68
+ items = Item.where(:plugin_id => plugin.id).to_a
69
+
70
+ plugin.risk_score = items.first.risk_score * items.count
71
+ plugin.save
72
+ end
73
+ end
74
+
75
+ #
76
+ def calculate_host_risk_score
77
+ Host.all.each do |host|
78
+ risk_score = 0.0
79
+
80
+ host.items.to_a.each do |item|
81
+ risk_score = risk_score + item.risk_score
82
+ end
83
+
84
+ #weighting goes here
85
+
86
+ host.risk_score = risk_score
87
+ host.save
88
+ end
89
+ end
90
+
91
+ #
92
+ def run
93
+ calculate_item_risk_score()
94
+ calculate_plugin_risk_score()
95
+ calculate_host_risk_score()
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end
@@ -117,11 +117,11 @@ module Risu
117
117
  output.text "There were #{Item.risks.count} risks found during this scan. Of these, #{Item.high_risks.count} were High risk vulnerabilities. High risk vulnerabilities require immediate attention to handle as they are relatively easy for attackers to exploit frequently resulting in full access to affected systems. There were #{Item.medium_risks.count} findings which were Medium risk. High risk vulnerabilities are harder to exploit and may not result in full control of the affected system and should be addressed rapidly and with priority. There were #{Item.low_risks.count} findings which were Low risk vulnerabilities. These risks usually let attackers gain information about your network making it easier for launching more advanced attacks and should be handled in a timely manner. And #{Item.info_risks.count} findings which were information findings.\n"
118
118
  output.text "\n"
119
119
 
120
- crit_host_count = Item.where(:severity => 4).group(:host_id).all.count
121
- high_host_count = Item.where(:severity => 3).group(:host_id).all.count
122
- medium_host_count = Item.where(:severity => 2).group(:host_id).all.count
123
- low_host_count = Item.where(:severity => 1).group(:host_id).all.count
124
- info_host_count = Item.where(:severity => 0).group(:host_id).all.count
120
+ crit_host_count = Item.where(:severity => 4).group(:host_id).count
121
+ high_host_count = Item.where(:severity => 3).group(:host_id).count
122
+ medium_host_count = Item.where(:severity => 2).group(:host_id).count
123
+ low_host_count = Item.where(:severity => 1).group(:host_id).count
124
+ info_host_count = Item.where(:severity => 0).group(:host_id).count
125
125
 
126
126
  output.text "There were #{crit_host_count} hosts with Critical risk vulnerabilities, #{high_host_count} hosts with High risk vulnerabilities, #{medium_host_count} hosts with Medium risk vulnerabilities, #{low_host_count} hosts with Low risk vulnerabilities and #{info_host_count} hosts with information findings."
127
127
  output.text "\n"
@@ -139,7 +139,11 @@ module Risu
139
139
  row = Array.new
140
140
 
141
141
  plugin = Plugin.find_by_id(vuln.plugin_id)
142
- plug = Item.find(:all, :conditions => {:plugin_id => vuln.plugin_id})
142
+ #rails3
143
+ #plug = Item.find(:all, :conditions => {:plugin_id => vuln.plugin_id})
144
+ #rails4
145
+ plug = Item.all.where(:plugin_id => vuln.plugin_id)
146
+
143
147
  #output.text "#{plug.count} - #{plugin.plugin_name}"
144
148
 
145
149
  row.push(plug.count)
@@ -196,7 +200,10 @@ module Risu
196
200
  row = Array.new
197
201
 
198
202
  #plugin = Plugin.find_by_id(service.plugin_id)
199
- svc = Item.find(:all, :conditions => {:svc_name => service.svc_name})
203
+ #rails3
204
+ #svc = Item.find(:all, :conditions => {:svc_name => service.svc_name})
205
+ svc = Item.all.where(:svc_name => service.svc_name)
206
+
200
207
  #output.text "#{svc.count} - #{service.svc_name}"
201
208
 
202
209
  row.push(svc.count)
@@ -58,7 +58,7 @@ module Risu
58
58
  output.text "\n\n\n"
59
59
 
60
60
  Host.sorted.each do |host|
61
- if host.items.high_risks_unique_sorted.all.size > 0 or host.items.medium_risks_unique_sorted.all.size > 0
61
+ if host.items.high_risks_unique_sorted.to_a.count > 0 or host.items.medium_risks_unique_sorted.to_a.count > 0
62
62
  output.font_size(16) do
63
63
 
64
64
  host_string = "#{host.ip}"
@@ -68,7 +68,7 @@ module Risu
68
68
  end
69
69
  end
70
70
 
71
- if host.items.critical_risks_unique_sorted.all.size > 0
71
+ if host.items.critical_risks_unique_sorted.to_a.count > 0
72
72
  output.font_size(12) do
73
73
  output.fill_color "551A8B"
74
74
  output.text "Critical Findings", :style => :bold
@@ -81,7 +81,7 @@ module Risu
81
81
  end
82
82
  end
83
83
 
84
- if host.items.high_risks_unique_sorted.all.size > 0
84
+ if host.items.high_risks_unique_sorted.to_a.count > 0
85
85
  output.font_size(12) {
86
86
  output.fill_color "FF0000"
87
87
  output.text "High Findings", :style => :bold
@@ -94,7 +94,7 @@ module Risu
94
94
  end
95
95
  end
96
96
 
97
- if host.items.medium_risks_unique_sorted.all.size > 0
97
+ if host.items.medium_risks_unique_sorted.to_a.count > 0
98
98
  output.font_size(12) {
99
99
  output.fill_color "FF8040"
100
100
  output.text "Medium Findings", :style => :bold
@@ -107,7 +107,7 @@ module Risu
107
107
  end
108
108
  end
109
109
 
110
- if host.items.high_risks_unique_sorted.all.size > 0 or host.items.medium_risks_unique_sorted.all.size > 0
110
+ if host.items.high_risks_unique_sorted.to_a.count > 0 or host.items.medium_risks_unique_sorted.to_a.count > 0
111
111
  output.text "\n"
112
112
  end
113
113
  end
@@ -0,0 +1,137 @@
1
+ # Copyright (c) 2010-2013 Arxopia LLC.
2
+ # All rights reserved.
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above copyright
10
+ # notice, this list of conditions and the following disclaimer in the
11
+ # documentation and/or other materials provided with the distribution.
12
+ # * Neither the name of the Arxopia LLC nor the names of its contributors
13
+ # may be used to endorse or promote products derived from this software
14
+ # without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ # DISCLAIMED. IN NO EVENT SHALL ARXOPIA LLC BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
22
+ # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
23
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25
+ # OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ module Risu
28
+ module Templates
29
+ class MaliciousProcessDetection < Risu::Base::TemplateBase
30
+ include TemplateHelper
31
+
32
+ def initialize ()
33
+ @template_info =
34
+ {
35
+ :name => "malicious_process_detection",
36
+ :author => "hammackj",
37
+ :version => "0.0.1",
38
+ :description => "Generates a Malicious Process Detection Report"
39
+ }
40
+ end
41
+
42
+ def render(output)
43
+ text Report.classification.upcase, :align => :center
44
+ text "\n"
45
+
46
+ report_title Report.title
47
+ report_subtitle "Malicious Process Detection Findings"
48
+ report_author "This report was prepared by\n#{Report.author}"
49
+
50
+ text "\n\n\n"
51
+
52
+ unique_risks = Array.new
53
+ unique_risks << Hash[:title => "Malicious Processes", :color => "9B30FF", :values => Item.where(:plugin_id => 59275)] if Item.where(:plugin_id => 59275).count != 0
54
+
55
+ unique_risks.each_with_index do |h, index|
56
+ if h[:values].length > 0
57
+
58
+ output.font_size(18) do
59
+ output.fill_color h[:color]
60
+ text h[:title], :style => :bold
61
+ output.fill_color "000000"
62
+ end
63
+
64
+ text "\n"
65
+
66
+ h[:values].each do |f|
67
+ plugin = Plugin.find_by_id(f.plugin_id)
68
+
69
+ references = Reference.where(:plugin_id => plugin.id).group(:value).order(:reference_name)
70
+
71
+ output.font_size(16) do
72
+ text "#{plugin.plugin_name}\n"
73
+ end
74
+
75
+ text "Host", :style => :bold
76
+
77
+ ho = Host.find_by_id(f.host_id)
78
+
79
+ host_string = "#{ho.name}"
80
+ host_string << " (#{ho.fqdn})" if ho.fqdn != nil
81
+
82
+ text host_string
83
+
84
+ if f.plugin_output != nil
85
+ text "\nPlugin output", :style => :bold
86
+ text f.plugin_output
87
+ end
88
+
89
+ if plugin.description != nil
90
+ text "\nDescription", :style => :bold
91
+ text plugin.description.gsub(/[ ]{2,}/, " "), :inline_format => true
92
+ end
93
+
94
+ if plugin.synopsis != nil
95
+ text "\nSynopsis", :style => :bold
96
+ text plugin.synopsis
97
+ end
98
+
99
+ if plugin.cvss_base_score != nil
100
+ text "\nCVSS Base Score", :style => :bold
101
+ text plugin.cvss_base_score
102
+ end
103
+
104
+ if plugin.exploit_available != nil
105
+ text "\nExploit Available", :style => :bold
106
+
107
+ if plugin.exploit_available == "true"
108
+ text "Yes"
109
+ else
110
+ text "No"
111
+ end
112
+ end
113
+
114
+ if plugin.solution != nil
115
+ text "\nSolution", :style => :bold
116
+ text plugin.solution
117
+ end
118
+
119
+ if references.size != 0
120
+ text "\nReferences", :style => :bold
121
+ text plugin.references.reference_string, :inline_format => true
122
+ plugin_url = "http://www.tenablesecurity.com/plugins/index.php?view=single&id=#{plugin.id}"
123
+ text "<b>nessus_plugin</b>: #{plugin_url}", :inline_format => true, :link => plugin_url
124
+ end
125
+
126
+ text "\n"
127
+ end
128
+ end
129
+
130
+ output.start_new_page if unique_risks[index+1] != nil
131
+ end
132
+
133
+ output.number_pages "<page> of <total>", :at => [output.bounds.right - 75, 0], :width => 150, :page_filter => :all
134
+ end
135
+ end
136
+ end
137
+ end
@@ -34,7 +34,7 @@ module Risu
34
34
  {
35
35
  :name => "technical_findings",
36
36
  :author => "hammackj",
37
- :version => "0.0.5",
37
+ :version => "0.0.6",
38
38
  :description => "Generates a Technical Findings Report"
39
39
  }
40
40
  end
@@ -50,11 +50,11 @@ module Risu
50
50
  text "\n\n\n"
51
51
 
52
52
  unique_risks = Array.new
53
- unique_risks << Hash[:title => "Critical Findings", :color => "9B30FF", :values => Item.critical_risks_unique] if Item.critical_risks_unique.all.size != 0
54
- unique_risks << Hash[:title => "High Findings", :color => "FF0000", :values => Item.high_risks_unique] if Item.high_risks_unique.all.size != 0
53
+ unique_risks << Hash[:title => "Critical Findings", :color => "9B30FF", :values => Item.critical_risks_unique] if Item.critical_risks_unique.to_a.size != 0
54
+ unique_risks << Hash[:title => "High Findings", :color => "FF0000", :values => Item.high_risks_unique] if Item.high_risks_unique.to_a.size != 0
55
55
 
56
56
  unique_risks.each_with_index do |h, index|
57
- if h[:values].length > 1
57
+ if h[:values].length > 0
58
58
 
59
59
  output.font_size(18) do
60
60
  output.fill_color h[:color]
data/risu.gemspec CHANGED
@@ -27,7 +27,6 @@
27
27
  base = __FILE__
28
28
  $:.unshift(File.join(File.dirname(base), 'lib'))
29
29
 
30
- require 'rubygems'
31
30
  require 'risu'
32
31
 
33
32
  Gem::Specification.new do |s|
@@ -54,7 +53,7 @@ Gem::Specification.new do |s|
54
53
  s.add_development_dependency("simplecov", [">= 0.7.1"])
55
54
  s.add_development_dependency("yard", [">= 0.8.3"])
56
55
 
57
- s.add_dependency('rails', ['>= 3.2.11'])
56
+ s.add_dependency('rails', ['>= 4.0.0'])
58
57
  s.add_dependency('libxml-ruby', ['>= 2.4.0'])
59
58
  s.add_dependency('prawn', ['>= 0.12.0'])
60
59
  s.add_dependency('gruff', ['>= 0.3.7'])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: risu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Hammack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-14 00:00:00.000000000 Z
11
+ date: 2013-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simplecov
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 3.2.11
47
+ version: 4.0.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 3.2.11
54
+ version: 4.0.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: libxml-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +179,10 @@ files:
179
179
  - lib/risu/renderers/nilrenderer.rb
180
180
  - lib/risu/renderers.rb
181
181
  - lib/risu/exceptions.rb
182
+ - lib/risu/parsers/nessus/postprocess.rb
182
183
  - lib/risu/parsers/nessus/nessus_document.rb
184
+ - lib/risu/parsers/nessus/postprocess/java.rb
185
+ - lib/risu/parsers/nessus/postprocess/risk_score.rb
183
186
  - lib/risu/parsers/nessus/nessus_sax_listener.rb
184
187
  - lib/risu/parsers/nexpose/nexpose_document.rb
185
188
  - lib/risu/parsers/nexpose/simple_nexpose.rb
@@ -198,6 +201,7 @@ files:
198
201
  - lib/risu/templates/executive_summary_detailed.rb
199
202
  - lib/risu/templates/exec_summary.rb
200
203
  - lib/risu/templates/findings_summary_with_pluginid.rb
204
+ - lib/risu/templates/malicious_process_detection.rb
201
205
  - lib/risu/templates/cover_sheet.rb
202
206
  - lib/risu/templates/data/nessuslogo.jpg
203
207
  - lib/risu/templates/notable.rb
@@ -208,6 +212,7 @@ files:
208
212
  - lib/risu/models/host.rb
209
213
  - lib/risu/models/item.rb
210
214
  - lib/risu/models/servicedescription.rb
215
+ - lib/risu/models/attachment.rb
211
216
  - lib/risu/models/pluginspreference.rb
212
217
  - lib/risu/models/familyselection.rb
213
218
  - lib/risu/models/report.rb
@@ -241,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
246
  version: 1.8.24
242
247
  requirements: []
243
248
  rubyforge_project: risu
244
- rubygems_version: 2.0.0
249
+ rubygems_version: 2.0.3
245
250
  signing_key:
246
251
  specification_version: 4
247
252
  summary: risu