module Risu::Templates::SharesTemplateHelper

Public Instance Methods

anon_ftp_count() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 26
def anon_ftp_count
        begin
                return Item.where(:plugin_id => Plugin.where(:plugin_name => "Anonymous FTP Enabled").first.id).count
        rescue
                return 0
        end
end
anon_ftp_section() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 35
def anon_ftp_section

        if anon_ftp_count() <= 0
                return
        end

        heading2 "Anonymous FTP Detection"

        findings =  Item.where(:plugin_id => Plugin.where(:plugin_name => "Anonymous FTP Enabled").first.id)

        findings.each do |finding|
                host = Host.find_by_id(finding.host_id)

                host_string = "#{host.name}"
                host_string << " (#{host.fqdn})" if host.fqdn != nil

                text "Host", :style => :bold
                text host_string

                text "\n"

                text "Plugin Output", :style => :bold
                text finding.plugin_output

                text "\n"
        end
end
anon_smb_count() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 69
def anon_smb_count
        count = 0
        begin
                anon_smb_query().each do |finding|
                        host = Host.find_by_id(finding.host_id)

                        login = host.host_properties.where(:name => 'smb-login-used').first.value
                        login = login.split("\\")[1] if login.include?("\\")

                        if finding.plugin_output.include?("The following shares can be accessed as #{login}")
                                # If the output was collect via the username that is authenitcated skip it.
                                next
                        end

                        count = count + 1
                end
        rescue
                return 0
        end

        return count
end
anon_smb_query() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 64
def anon_smb_query
        return Item.where(:plugin_id => Plugin.where(:plugin_name => "Microsoft Windows SMB Shares Unprivileged Access").first.id)
end
anon_smb_section() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 93
def anon_smb_section
        if anon_smb_count() <= 0
                return
        end

        heading2 "Anonymous SMB Share Detection"

        anon_smb_query().each do |finding|
                host = Host.find_by_id(finding.host_id)

                login = host.host_properties.where(:name => 'smb-login-used').first.value
                login = login.split("\\")[1] if login.include?("\\")

                if finding.plugin_output.include?("The following shares can be accessed as #{login}")
                        # If the output was collect via the username that is authenitcated skip it.
                        next
                end

                host_string = "#{host.name}"
                host_string << " (#{host.fqdn})" if host.fqdn != nil

                text "Host", :style => :bold
                text host_string

                text "\n"

                text "Plugin Output", :style => :bold
                text finding.plugin_output

                text "\n"
        end
end
shares_appendix_section() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 171
def shares_appendix_section
        anon_ftp_section
        anon_smb_section
end
shares_section() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 126
def shares_section
        poor_count = 0

        anon_ftp_text = ""
        anon_smb_text = ""

        v_anon_smb_count = 0
        v_anon_ftp_count = 0

        begin
                v_anon_ftp_count = anon_ftp_count()
        rescue Exception => e
        end

        begin
                v_anon_smb_count = anon_smb_count()
        rescue Exception => e
        end

        if v_anon_ftp_count > 1
                anon_ftp_text = "Anonymous FTP was detected as being enabled on #{anon_ftp_count} network nodes. Anonymous FTP allows anyone to access files stored on the FTP server, depending on the server's configuration also write files. "
                poor_count = poor_count + 1
        elsif v_anon_ftp_count == 1
                anon_ftp_text = "Anonymous FTP was detected as being enabled on #{anon_ftp_count} network node. Anonymous FTP allows anyone to access files stored on the FTP server, depending on the server's configuration also write files. "
                poor_count = poor_count + 1
        end

        if v_anon_smb_count > 1
                anon_smb_text = "Anonymous SMB shares were detected on #{anon_smb_count} network nodes. These shares also were found to have read and write access enabled. "
                poor_count = poor_count + 1
        elsif v_anon_smb_count == 1
                anon_smb_text = "Anonymous SMB shares were detected on #{anon_smb_count} network node. These shares also were found to have read and write access enabled. "
                poor_count = poor_count + 1
        end

        anonymous_access_text = "Allowing anonymous access to a file server can lead to information disclosures and other security violations. Each instance should be evaluated and removed or noted in the network's security policy.\n"

        heading1 "Other Findings of Interest" if poor_count > 0

        #Anon ftp/smb + clear text
        @output.text anon_ftp_text + anon_smb_text + anonymous_access_text if v_anon_ftp_count > 0 || v_anon_smb_count > 0
        @output.text "\n"
        @output.text "\n"
end
shares_section_has_findings?() click to toggle source
# File lib/risu/base/shares_template_helper.rb, line 177
def shares_section_has_findings?
        poor_count = 0

        anon_ftp_text = ""
        anon_smb_text = ""

        v_anon_smb_count = 0
        v_anon_ftp_count = 0

        begin
                v_anon_ftp_count = anon_ftp_count()
        rescue Exception => e
        end

        begin
                v_anon_smb_count = anon_smb_count()
        rescue Exception => e
        end

        if v_anon_ftp_count >= 1
                poor_count = poor_count + 1
        end

        if v_anon_smb_count >= 1
                poor_count = poor_count + 1
        end

        if poor_count >= 1
                return true
        else
                return false
        end
end