Module: Risu::Templates::TemplateHelper

Instance Method Summary collapse

Methods included from ScanHelper

#authenticated_count, #scan_info_to_hash

Methods included from SharesTemplateHelper

#anon_ftp_count, #anon_ftp_section, #anon_smb_count, #anon_smb_query, #anon_smb_section, #shares_appendix_section, #shares_section, #shares_section_has_findings?

Methods included from GraphTemplateHelper

#other_os_graph_page, #risks_by_service_graph_page, #risks_by_severity_graph_page, #root_cause_graph_page, #windows_os_graph_page

Methods included from MalwareTemplateHelper

#conficker_appendix_section, #conficker_count, #conficker_section, #known_malicious_process_appendix_section, #known_malicious_process_count, #known_malicious_process_section, #malware_appendix_section, #malware_section

Methods included from HostTemplateHelper

#unsupported_os, #unsupported_os_appendix_section

Instance Method Details

#default_credential_pluginsObject



151
152
153
154
155
156
157
# File 'lib/risu/base/template_helper.rb', line 151

def default_credential_plugins
  [
    10862, 25927, 32315, 65950, 39364, 33852, 11454, 51369,
    26918, 76073, 24745, 11245, 23938, 46786, 46789, 10483,
    81375
  ].uniq
end

#default_credentials_appendix_sectionObject



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/risu/base/template_helper.rb', line 182

def default_credentials_appendix_section
  if !has_default_credentials?
    return
  end

  heading1 "Default Credentials"

  headers = ["Plugin Name", "IP"]
  header_widths = {0 => (@output.bounds.width - 80), 1 => 80}
  data = Array.new

  default_credential_plugins.each do |plugin_id|
    if item_count_by_plugin_id(plugin_id) > 0
      items = Item.where(:plugin_id => plugin_id)

      plugin_name = items.first.plugin_name

      items.each do |item|
        hosts = Host.where(:id => item.host_id)

        hosts.each do |host|
          row = Array.new
          row.push plugin_name
          row.push host.ip

          data.push row
        end
      end
    end
  end

  table headers, header_widths, data

  text "\n"
end

#default_credentials_sectionObject



174
175
176
177
178
179
# File 'lib/risu/base/template_helper.rb', line 174

def default_credentials_section
  heading1 "Default Credentials"

  text "Default credentials were discovered on the network. This can cause issues because the credentials can be found all over the Internet giving anyone with network access full access to the systems in question."
  text "\n"
end

#definition(term, text, options = {}) ⇒ Object



81
82
83
84
85
86
# File 'lib/risu/base/template_helper.rb', line 81

def definition term, text, options = {}
  if text != nil
    @output.text "\n#{term}", :style => :bold
    @output.text text, options
  end
end

#has_default_credentials?Boolean



160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/risu/base/template_helper.rb', line 160

def has_default_credentials?
  plugins = default_credential_plugins
  default_cred = false

  plugins.each do |plugin_id|
    if item_count_by_plugin_id(plugin_id) > 0
      default_cred = true
    end
  end

  return default_cred
end

#heading1(title_text) ⇒ Object



89
90
91
# File 'lib/risu/base/template_helper.rb', line 89

def heading1 title_text
  title title_text, 24
end

#heading2(title_text) ⇒ Object



94
95
96
# File 'lib/risu/base/template_helper.rb', line 94

def heading2 title_text
  title title_text, 18
end

#heading3(title_text) ⇒ Object



99
100
101
# File 'lib/risu/base/template_helper.rb', line 99

def heading3 title_text
  title title_text, 14
end

#heading4(title_text) ⇒ Object



104
105
106
# File 'lib/risu/base/template_helper.rb', line 104

def heading4 title_text
  title title_text, 12
end

#heading5(title_text) ⇒ Object



109
110
111
# File 'lib/risu/base/template_helper.rb', line 109

def heading5 title_text
  title title_text, 10
end

#heading6(title_text) ⇒ Object



114
115
116
117
118
# File 'lib/risu/base/template_helper.rb', line 114

def heading6 title_text
  @output.font_size(8) do
    @output.text title_text, :style => :bold
  end
end

#item_count_by_plugin_id(plugin_id) ⇒ Object



142
143
144
145
146
147
148
# File 'lib/risu/base/template_helper.rb', line 142

def item_count_by_plugin_id plugin_id
  begin
    return Item.where(:plugin_id => plugin_id).count
  rescue
    return 0
  end
end

#item_count_by_plugin_name(plugin_name) ⇒ Object



134
135
136
137
138
139
140
# File 'lib/risu/base/template_helper.rb', line 134

def item_count_by_plugin_name plugin_name
  begin
    return Item.where(:plugin_id => Plugin.where(:plugin_name => plugin_name).first.id).count
  rescue
    return 0
  end
end

#new_pageObject



129
130
131
# File 'lib/risu/base/template_helper.rb', line 129

def new_page
  @output.start_new_page
end

#report_author(author, newline = false) ⇒ Object



55
56
57
58
59
60
# File 'lib/risu/base/template_helper.rb', line 55

def report_author author, newline=false
  @output.font_size(14) do
    @output.text author, :align => :center
    @output.text "\n" if newline
  end
end

#report_classification(classification = Report.classification.upcase, newline = true) ⇒ Object



31
32
33
34
35
36
# File 'lib/risu/base/template_helper.rb', line 31

def report_classification classification=Report.classification.upcase, newline=true
  @output.font_size(12) do
    @output.text classification, :align => :center
    @output.text "\n" if newline
  end
end

#report_subtitle(title, newline = false) ⇒ Object



47
48
49
50
51
52
# File 'lib/risu/base/template_helper.rb', line 47

def report_subtitle title, newline=false
  @output.font_size(18) do
    @output.text title, :align => :center
    @output.text "\n" if newline
  end
end

#report_title(title, newline = false) ⇒ Object



39
40
41
42
43
44
# File 'lib/risu/base/template_helper.rb', line 39

def report_title title, newline=false
  @output.font_size(24) do
    @output.text title, :align => :center
    @output.text "\n" if newline
  end
end

#table(headers, header_widths, data) ⇒ Object



121
122
123
124
125
126
# File 'lib/risu/base/template_helper.rb', line 121

def table headers, header_widths, data
  @output.table([headers] + data, :header => true, :column_widths => header_widths, :row_colors => ['ffffff', 'E5E5E5']) do
    row(0).style(:font_style => :bold, :background_color => 'D0D0D0')
    cells.borders = [:top, :bottom, :left, :right]
  end
end

#text(text, options = {}) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/risu/base/template_helper.rb', line 63

def text(text, options = {})
  if text == nil
    text = ""
  end

  @output.text text, options
end

#title(text, size = 18, color = '#000000') ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/risu/base/template_helper.rb', line 71

def title(text, size=18, color='#000000')
  @output.font_size(size) do
    @output.fill_color color.gsub('#', '')
    @output.text text, :style => :bold
    @output.fill_color "000000"
  end

  @output.text "\n"
end