module Risu::Templates::TemplateHelper

Public Instance Methods

default_credential_plugins() click to toggle source

@TODO comment

# 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_section() click to toggle source

@TODO comment

# 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_section() click to toggle source

@TODO comment

# 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 = {}) click to toggle source
# 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?() click to toggle source

@TODO comment

# 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) click to toggle source
# File lib/risu/base/template_helper.rb, line 89
def heading1 title_text
        title title_text, 24
end
heading2(title_text) click to toggle source
# File lib/risu/base/template_helper.rb, line 94
def heading2 title_text
        title title_text, 18
end
heading3(title_text) click to toggle source
# File lib/risu/base/template_helper.rb, line 99
def heading3 title_text
        title title_text, 14
end
heading4(title_text) click to toggle source
# File lib/risu/base/template_helper.rb, line 104
def heading4 title_text
        title title_text, 12
end
heading5(title_text) click to toggle source
# File lib/risu/base/template_helper.rb, line 109
def heading5 title_text
        title title_text, 10
end
heading6(title_text) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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_page() click to toggle source
# File lib/risu/base/template_helper.rb, line 129
def new_page
        @output.start_new_page
end
report_author(author, newline=false) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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 = {}) click to toggle source
# 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=' click to toggle source
# 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