risu 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. data/KNOWNISSUES.markdown +50 -0
  2. data/LICENSE +25 -0
  3. data/NEWS.markdown +112 -0
  4. data/README.markdown +126 -0
  5. data/Rakefile +37 -0
  6. data/TODO.markdown +69 -0
  7. data/bin/risu +12 -0
  8. data/lib/nessusdb.rb +38 -0
  9. data/lib/nessusdb/cli.rb +9 -0
  10. data/lib/nessusdb/cli/application.rb +402 -0
  11. data/lib/nessusdb/cli/banner.rb +25 -0
  12. data/lib/nessusdb/exceptions.rb +8 -0
  13. data/lib/nessusdb/exceptions/invaliddocument.rb +10 -0
  14. data/lib/nessusdb/listener.rb +274 -0
  15. data/lib/nessusdb/models.rb +18 -0
  16. data/lib/nessusdb/models/familyselection.rb +12 -0
  17. data/lib/nessusdb/models/host.rb +359 -0
  18. data/lib/nessusdb/models/individualpluginselection.rb +14 -0
  19. data/lib/nessusdb/models/item.rb +183 -0
  20. data/lib/nessusdb/models/plugin.rb +98 -0
  21. data/lib/nessusdb/models/pluginspreference.rb +12 -0
  22. data/lib/nessusdb/models/policy.rb +17 -0
  23. data/lib/nessusdb/models/reference.rb +13 -0
  24. data/lib/nessusdb/models/report.rb +26 -0
  25. data/lib/nessusdb/models/serverpreference.rb +13 -0
  26. data/lib/nessusdb/models/version.rb +12 -0
  27. data/lib/nessusdb/nessusdocument.rb +66 -0
  28. data/lib/nessusdb/parsers.rb +8 -0
  29. data/lib/nessusdb/prawn_templater.rb +38 -0
  30. data/lib/nessusdb/schema.rb +145 -0
  31. data/lib/nessusdb/templates/assets.rb +21 -0
  32. data/lib/nessusdb/templates/cover_sheet.rb +42 -0
  33. data/lib/nessusdb/templates/data/nessuslogo.jpg +0 -0
  34. data/lib/nessusdb/templates/exec_summary.rb +56 -0
  35. data/lib/nessusdb/templates/executive_summary.rb +182 -0
  36. data/lib/nessusdb/templates/finding_statistics.rb +23 -0
  37. data/lib/nessusdb/templates/findings_host.rb +49 -0
  38. data/lib/nessusdb/templates/findings_summary.rb +68 -0
  39. data/lib/nessusdb/templates/findings_summary_with_pluginid.rb +68 -0
  40. data/lib/nessusdb/templates/graphs.rb +33 -0
  41. data/lib/nessusdb/templates/host_summary.rb +40 -0
  42. data/lib/nessusdb/templates/ms_patch_summary.rb +37 -0
  43. data/lib/nessusdb/templates/ms_update_summary.rb +43 -0
  44. data/lib/nessusdb/templates/pci_compliance.rb +66 -0
  45. data/lib/nessusdb/templates/technical_findings.rb +116 -0
  46. data/risu.gemspec +44 -0
  47. metadata +247 -0
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ module NessusDB
4
+ module Parsers
5
+ end
6
+ end
7
+
8
+ #require 'nessusdb/parsers/'
@@ -0,0 +1,38 @@
1
+ # encoding: utf-8
2
+
3
+ module NessusDB
4
+
5
+ # Templater class for generating a report from a erb template
6
+ #
7
+ # @author Jacob Hammack
8
+ class PrawnTemplater
9
+ attr_accessor :template, :template_source, :findings, :output_file
10
+
11
+ # Setups of the Templater class initalizing all of the variables
12
+ #
13
+ # @return [PrawnTemplater] New Instance
14
+ def initialize(template, findings, output)
15
+ @template = template
16
+ @findings = findings
17
+ @output_file = output
18
+
19
+ @template_source = File.new(@template).read
20
+ end
21
+
22
+ # Generates a report based on the erb template
23
+ #
24
+ # @return [String] html output of the erb template
25
+ def generate
26
+ begin
27
+ source = @template_source
28
+ template = @template
29
+ Prawn::Document.generate(@output_file, :margin => [75, 50, 75, 50]) do
30
+ font_size 12
31
+ eval source
32
+ end
33
+ rescue => e
34
+ puts "Error: #{e.message} \n #{e.backtrace.join("\n\t")}\n"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,145 @@
1
+ # encoding: utf-8
2
+
3
+ module NessusDB
4
+
5
+ # NessusDB Schema
6
+ #
7
+ # @author Jacob Hammack <jacob.hammack@hammackj.com>
8
+ class Schema < ActiveRecord::Migration
9
+
10
+ # Creates all of the database tables required by the parser
11
+ #
12
+ def self.up
13
+ create_table :policies do |t|
14
+ t.string :name
15
+ t.string :comments
16
+ end
17
+
18
+ create_table :server_preferences do |t|
19
+ t.integer :policy_id
20
+ t.string :name
21
+ t.string :value
22
+ end
23
+
24
+ create_table :plugins_preferences do |t|
25
+ t.integer :policy_id
26
+ t.integer :plugin_id
27
+ t.string :plugin_name
28
+ t.string :fullname
29
+ t.string :preference_name
30
+ t.string :preference_type
31
+ t.string :preference_values
32
+ t.string :selected_values
33
+ end
34
+
35
+ create_table :family_selections do |t|
36
+ t.integer :policy_id
37
+ t.string :family_name
38
+ t.string :status
39
+ end
40
+
41
+ create_table :reports do |t|
42
+ t.integer :policy_id
43
+ t.string :name
44
+ end
45
+
46
+ create_table :hosts do |t|
47
+ t.integer :report_id
48
+ t.string :name
49
+ t.string :os
50
+ t.string :mac
51
+ t.datetime :start
52
+ t.datetime :end
53
+ t.string :ip
54
+ t.string :fqdn
55
+ t.string :netbios
56
+ t.string :local_checks_proto
57
+ t.string :smb_login_used
58
+ t.string :ssh_auth_meth
59
+ t.string :ssh_login_used
60
+ t.string :pci_dss_compliance
61
+ t.string :pci_dss_compliance_
62
+ t.string :pcidss_compliance_failed
63
+ t.string :pcidss_compliance_passed
64
+ t.string :pcidss_deprecated_ssl
65
+ t.string :pcidss_expired_ssl_certificate
66
+ t.string :pcidss_high_risk_flaw
67
+ t.string :pcidss_medium_risk_flaw
68
+ t.string :pcidss_reachable_db
69
+ t.string :pcidss_www_xss
70
+ t.text :notes
71
+ end
72
+
73
+ create_table :items do |t|
74
+ t.integer :host_id
75
+ t.integer :plugin_id
76
+ t.text :plugin_output
77
+ t.integer :port
78
+ t.string :svc_name
79
+ t.string :protocol
80
+ t.integer :severity
81
+ t.boolean :verified
82
+ end
83
+
84
+ create_table :plugins do |t|
85
+ t.string :plugin_name
86
+ t.string :family_name
87
+ t.text :description
88
+ t.string :plugin_version
89
+ t.datetime :plugin_publication_date
90
+ t.datetime :vuln_publication_date
91
+ t.string :cpe
92
+ t.string :cvss_vector
93
+ t.string :cvss_base_score
94
+ t.string :cvss_temporal_score
95
+ t.string :cvss_temporal_vector
96
+ t.string :exploitability_ease
97
+ t.string :exploit_framework_core
98
+ t.string :exploit_framework_metasploit
99
+ t.string :metasploit_name
100
+ t.string :exploit_framework_canvas
101
+ t.string :canvas_package
102
+ t.string :exploit_available
103
+ t.string :risk_factor
104
+ t.text :solution
105
+ t.text :synopsis
106
+ t.string :plugin_type
107
+ end
108
+
109
+ create_table :individual_plugin_selections do |t|
110
+ t.string :policy_id
111
+ t.integer :plugin_id
112
+ t.string :plugin_name
113
+ t.string :family
114
+ t.string :status
115
+ end
116
+
117
+ create_table :references do |t|
118
+ t.integer :plugin_id
119
+ t.string :reference_name
120
+ t.string :value
121
+ end
122
+
123
+ create_table :versions do |t|
124
+ t.string :version
125
+ end
126
+ end
127
+
128
+ # Deletes all of the database tables created
129
+ #
130
+ def self.down
131
+ drop_table :policies
132
+ drop_table :server_preferences
133
+ drop_table :plugins_preferences
134
+ drop_table :family_selections
135
+ drop_table :individual_plugin_selections
136
+ drop_table :reports
137
+ drop_table :hosts
138
+ drop_table :items
139
+ drop_table :plugins
140
+ drop_table :references
141
+ drop_table :versions
142
+ end
143
+
144
+ end
145
+ end
@@ -0,0 +1,21 @@
1
+ text Report.classification, :align => :center
2
+ text "\n"
3
+
4
+ font_size(22) { text Report.title, :align => :center }
5
+ font_size(18) {
6
+ text "Networked Assets", :align => :center
7
+ text "\n"
8
+ text "This report was prepared by\n#{Report.author}", :align => :center
9
+ }
10
+
11
+ text "\n\n"
12
+
13
+ Host.sorted.each do |host|
14
+ text "Name: #{host.name}\n"
15
+ text "FQDN: #{host.fqdn}\n" unless host.fqdn == nil
16
+ text "IP Address: #{host.ip}\n" unless host.ip == nil
17
+ text "NetBios: #{host.netbios}\n" unless host.netbios == nil
18
+ text sprintf "Mac Address: %s\n", host.mac.chomp.gsub("\n", ", ") unless host.mac == nil
19
+ text sprintf "Operation System: %s\n", host.os.chomp.gsub("\n", "/") unless host.os == nil
20
+ text "\n"
21
+ end
@@ -0,0 +1,42 @@
1
+ image File.dirname(template) + "/data/nessuslogo.jpg", :scale => 0.2, :position => :left, :vposition => :top
2
+
3
+ text "\n"
4
+ text "\n"
5
+ text "\n"
6
+ text "\n"
7
+ text "\n"
8
+ text "\n"
9
+ text "\n"
10
+
11
+ font_size(24) { text Report.title, :align => :center }
12
+
13
+ font_size(18) {
14
+ text "Coversheet Example", :align => :center
15
+ text "\n"
16
+ text "This report was prepared by\n#{Report.author}", :align => :center
17
+ }
18
+
19
+ text "\n"
20
+ text "\n"
21
+ text "\n"
22
+ text "\n"
23
+ text "\n"
24
+ text "\n"
25
+ text "\n"
26
+ text "\n"
27
+ text "\n"
28
+ text "\n"
29
+ text "\n"
30
+ text "\n"
31
+ text "\n"
32
+ text "\n"
33
+ text "\n"
34
+ text "\n"
35
+ text "\n"
36
+ text "\n"
37
+ text "\n"
38
+ text "\n"
39
+ text "\n"
40
+ text "\n"
41
+
42
+ text "Nessus is a Registered Trademark of Tenable Network Security, Inc."
@@ -0,0 +1,56 @@
1
+ text Report.classification, :align => :center
2
+ text "\n"
3
+
4
+ font_size(22) { text Report.title, :align => :center }
5
+ font_size(18) {
6
+ text "Executive Summary", :align => :center
7
+ text "\n"
8
+ text "This report was prepared by\n#{Report.author}", :align => :center
9
+ }
10
+
11
+ text "\n\n\n"
12
+
13
+ text "Scan Date:", :style => :bold
14
+ text "#{Report.scan_date}"
15
+ text "\n"
16
+
17
+ text "This report contains the results of a security audit performed on #{Report.scan_date}. It contains confidential information about the state of your network. Access to this information by unauthorized personnel may allow them to compromise your network.\n\n"
18
+
19
+ text "A total of #{Host.count} hosts were found and scanned for vulnerabities.\n\n"
20
+
21
+ text "There were #{Item.risks.count} vulnerabilities found during this scan. Of these, #{Item.high_risks.count} were high vulnerabilities, #{Item.medium_risks.count} were medium vulnerabilities, #{Item.low_risks.count} were low vulnerabilities and #{Item.info_risks.count} were information findings.\n\n"
22
+
23
+ text "Scan Statistics", :style => :bold
24
+ text "\n"
25
+
26
+ table([["Number of hosts","Number of risks","High Risks", "Medium Risks", "Low Risks", "Info Risks"],
27
+ [Host.count, Item.risks.count, Item.high_risks.count, Item.medium_risks.count, Item.low_risks.count, Item.info_risks.count]],
28
+ :cell_style => { :padding =>12 }, :width => bounds.width)
29
+ text "\n\n\n"
30
+
31
+ text "Graphs of key finding statistics", :style => :bold
32
+ text "\n\n\n"
33
+
34
+ cury = y
35
+ image Item.risks_by_severity_graph, :width => 250, :at => [bounds.left, cury]
36
+ image Host.top_vuln_graph(10), :width => 250, :at => [bounds.right - 250, cury]
37
+ move_down 50
38
+ if (y <= 300)
39
+ start_new_page
40
+ move_down 75
41
+ end
42
+ cury = y
43
+ image Item.risks_by_service_graph(10), :width => 250, :at => [bounds.left, cury]
44
+ image Host.other_os_graph, :width => 250, :at => [bounds.right - 250, cury]
45
+ move_down 250
46
+ #if (y <= 300)
47
+ # start_new_page
48
+ # cury = y
49
+ #end
50
+ cury = y
51
+ #move_down 550
52
+ image Host.windows_os_graph, :width => 250, :at => [bounds.left, cury]
53
+
54
+
55
+
56
+
@@ -0,0 +1,182 @@
1
+ #Author: Ed Davison <EDavison@getmns.com>
2
+
3
+ font_size 10
4
+ font "Times-Roman"
5
+
6
+ image File.dirname(template) + "/data/nessuslogo.jpg", :scale => 1.0, :position => :left, :vposition => :top
7
+
8
+ text "\n"
9
+ text "\n"
10
+ text "\n"
11
+ text "\n"
12
+ text "\n"
13
+ text "\n"
14
+ text "\n"
15
+
16
+ font_size(24) { text Report.title, :align => :center }
17
+
18
+ font_size(18) {
19
+ text "Executive Summary Report", :align => :center
20
+ text "\n"
21
+ text "This report was prepared by\n", :align => :center
22
+ text "#{Report.author}", :align => :center
23
+ text "#{Report.company}", :align => :center
24
+ text "\n"
25
+ text "#{Report.scan_date}", :align => :center
26
+ text "\n"
27
+ }
28
+
29
+ text "\n"
30
+
31
+ start_new_page
32
+
33
+ font_size(18) { text "Executive Summary Report", :align => :center }
34
+ text "\n"
35
+
36
+ text "This report contains the results of a security audit performed on #{Report.scan_date}. It contains confidential information about the state of your network. Access to this information by unauthorized personnel may allow them to compromise your network.\n"
37
+ text "\n"
38
+
39
+ text "The periodic assessment of risk to company assets resulting from the operation of an information system is an important activity required by various audit standards. #{Report.company} prepared this Security Assessment Report and it summarizes the risks associated with the vulnerabilities identified during the systems Vulnerability Assessment, audits and any other risk assessment activities. All results were analyzed to provide an assessment of the management, operational and technical controls implemented to protect the confidentiality, integrity and availability of the system.\n"
40
+ text "\n"
41
+
42
+ text "Scan Statistics", :style => :bold
43
+ text "\n"
44
+
45
+ headers = ["Number of hosts","Number of risks","High Risks", "Medium Risks", "Low Risks", "Info Risks"]
46
+ data = [[Host.count, Item.risks.count, Item.high_risks.count, Item.medium_risks.count, Item.low_risks.count, Item.info_risks.count]]
47
+
48
+ table([headers] + data, :header => true, :row_colors => ['ffffff', 'f0f0f0']) do
49
+ row(0).style(:font_style => :bold, :background_color => 'cccccc')
50
+ cells.borders = [:top, :bottom, :left, :right]
51
+ end unless data == nil
52
+
53
+ text "\n\n\n"
54
+
55
+ text "A total of #{Host.count} hosts were found and scanned for vulnerabities.\n"
56
+ text "\n"
57
+
58
+ 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"
59
+ text "\n"
60
+
61
+ high_host_count = Item.where(:severity => 3).group(:host_id).all.count
62
+ medium_host_count = Item.where(:severity => 2).group(:host_id).all.count
63
+ low_host_count = Item.where(:severity => 1).group(:host_id).all.count
64
+ info_host_count = Item.where(:severity => 0).group(:host_id).all.count
65
+
66
+ text "There were #{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."
67
+ text "\n"
68
+
69
+ text "The following table shows the top 5 vulnerabilities that were found. These are the most important vulnerabilities to address as they represent a sizeable footprint for an attacker to exploit in an attempt to compromise.\n"
70
+ text "\n"
71
+
72
+ results = Array.new
73
+ headers = ["Count", "Vulnerability"]
74
+ header_widths = {0 => 75, 1=> 400}
75
+
76
+ top10vulns = Item.risks_by_plugin(5)
77
+
78
+ top10vulns.each do |vuln|
79
+ row = Array.new
80
+
81
+ plugin = Plugin.find_by_id(vuln.plugin_id)
82
+ plug = Item.find(:all, :conditions => {:plugin_id => vuln.plugin_id})
83
+ #text "#{plug.count} - #{plugin.plugin_name}"
84
+
85
+ row.push(plug.count)
86
+ row.push(plugin.plugin_name)
87
+ results.push(row)
88
+ end
89
+
90
+ table([headers] + results, :header => true, :column_widths => header_widths, :row_colors => ['ffffff', 'f0f0f0']) do
91
+ row(0).style(:font_style => :bold, :background_color => 'D0D0D0')
92
+ cells.borders = [:top, :bottom, :left, :right]
93
+ end unless results == nil
94
+
95
+ text "\n"
96
+
97
+ text "The following table shows the top 5 hosts with the most vulnerabilities. These should be addressed first and resolved in order or priority of the vulnerabilities found for a given host.\n"
98
+ text "\n"
99
+
100
+ results = Array.new
101
+ headers = ["Count", "Host"]
102
+ header_widths = {0 => 75, 1=> 400}
103
+
104
+ top10vulns = Item.risks_by_host(5)
105
+
106
+ top10vulns.each do |vuln|
107
+ row = Array.new
108
+
109
+ #plugin = Plugin.find_by_id(vuln.plugin_id)
110
+ ip = Host.find_by_id(vuln.host_id).name
111
+ count = Item.where(:host_id => vuln.host_id).where("severity IN (?)", [0,1,2,3]).count
112
+ #text "#{plugin.plugin_name}"
113
+
114
+ row.push(count)
115
+ row.push(ip)
116
+ results.push(row)
117
+ end
118
+
119
+ table([headers] + results, :header => true, :column_widths => header_widths, :row_colors => ['ffffff', 'f0f0f0']) do
120
+ row(0).style(:font_style => :bold, :background_color => 'D0D0D0')
121
+ cells.borders = [:top, :bottom, :left, :right]
122
+ end unless results == nil
123
+
124
+ text "\n"
125
+
126
+ text "The following table shows the top 5 services with the most vulnerabilities. These services represent the avenues that an attacker would utilize based on scans to try to gain a foothold into your enterprise.\n"
127
+ text "\n"
128
+
129
+ results = Array.new
130
+ headers = ["Count", "Service"]
131
+ header_widths = {0 => 75, 1=> 400}
132
+
133
+ top10vulns = Item.risks_by_service(5)
134
+
135
+ top10vulns.each do |service|
136
+ row = Array.new
137
+
138
+ #plugin = Plugin.find_by_id(service.plugin_id)
139
+ svc = Item.find(:all, :conditions => {:svc_name => service.svc_name})
140
+ #text "#{svc.count} - #{service.svc_name}"
141
+
142
+ row.push(svc.count)
143
+ row.push(service.svc_name)
144
+ results.push(row)
145
+ end
146
+
147
+ table([headers] + results, :header => true, :column_widths => header_widths, :row_colors => ['ffffff', 'f0f0f0']) do
148
+ row(0).style(:font_style => :bold, :background_color => 'D0D0D0')
149
+ cells.borders = [:top, :bottom, :left, :right]
150
+ end unless results == nil
151
+
152
+ text "\n\n\n"
153
+ if (y <= 300)
154
+ start_new_page
155
+ move_down 50
156
+ end
157
+
158
+ text "Summary Graphs of Key Finding Statistics", :style => :bold
159
+ text "\n\n\n"
160
+ text "\n"
161
+ text "\n"
162
+
163
+ cury = y
164
+ image Item.risks_by_severity_graph, :width => 250, :at => [bounds.left, cury]
165
+ image Host.top_vuln_graph(10), :width => 250, :at => [bounds.right - 250, cury]
166
+ move_down 225
167
+ if (y <= 300)
168
+ start_new_page
169
+ move_down 50
170
+ end
171
+ cury = y
172
+ image Item.risks_by_service_graph(10), :width => 250, :at => [bounds.left, cury]
173
+ image Host.other_os_graph, :width => 250, :at => [bounds.right - 250, cury]
174
+ move_down 225
175
+ if (y <= 300)
176
+ start_new_page
177
+ move_down 50
178
+ end
179
+ cury = y
180
+ image Host.windows_os_graph, :width => 250, :at => [bounds.left, cury]
181
+
182
+ number_pages "<page> of <total>", :at => [bounds.right - 50, 0], :width => 150, :page_filter => :all