rapid7/metasploit-framework

View on GitHub
modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb

Summary

Maintainability
F
3 days
Test Coverage

File ldap_esc_vulnerable_cert_finder.rb has 375 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Auxiliary

  include Msf::Exploit::Remote::LDAP

  ADS_GROUP_TYPE_BUILTIN_LOCAL_GROUP = 0x00000001
Severity: Minor
Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 5 hrs to fix

    Method find_esc13_vuln_cert_templates has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def find_esc13_vuln_cert_templates
        esc_raw_filter = <<~FILTER
          (&
            (objectclass=pkicertificatetemplate)
            (!(mspki-enrollment-flag:1.2.840.113556.1.4.804:=2))
    Severity: Minor
    Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method print_vulnerable_cert_info has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      def print_vulnerable_cert_info
        @vuln_certificate_details.each do |key, hash|
          enrollable = true
          if hash[:ca_servers_n_enrollment_sids].blank?
            next unless datastore['REPORT_NONENROLLABLE']
    Severity: Minor
    Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method parse_acl has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def parse_acl(acl)
        allowed_sids = []
        acl.aces.each do |ace|
          ace_header = ace[:header]
          ace_body = ace[:body]
    Severity: Minor
    Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method find_enrollable_vuln_certificate_templates has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      def find_enrollable_vuln_certificate_templates
        # For each of the vulnerable certificate templates, determine which servers
        # allows users to enroll in that certificate template and which users/groups
        # have permissions to enroll in certificates on each server.
    
    
    Severity: Minor
    Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method initialize has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Misconfigured Certificate Template Finder',
    Severity: Minor
    Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

      Method find_esc13_vuln_cert_templates has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def find_esc13_vuln_cert_templates
          esc_raw_filter = <<~FILTER
            (&
              (objectclass=pkicertificatetemplate)
              (!(mspki-enrollment-flag:1.2.840.113556.1.4.804:=2))
      Severity: Minor
      Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

        Method print_vulnerable_cert_info has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def print_vulnerable_cert_info
            @vuln_certificate_details.each do |key, hash|
              enrollable = true
              if hash[:ca_servers_n_enrollment_sids].blank?
                next unless datastore['REPORT_NONENROLLABLE']
        Severity: Minor
        Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

          Method query_ldap_server_certificates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def query_ldap_server_certificates(esc_raw_filter, esc_name)
              attributes = ['cn', 'description', 'ntSecurityDescriptor']
              base_prefix = 'CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration'
              esc_entries = query_ldap_server(esc_raw_filter, attributes, base_prefix: base_prefix)
          
          
          Severity: Minor
          Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method find_esc3_vuln_cert_templates has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def find_esc3_vuln_cert_templates
              # Find the first vulnerable types of ESC3 templates, those that have the OID of the
              # Certificate Request Agent which allows the template to be used for
              # requesting other certificate templates on behalf of other principals.
              esc3_template_1_raw_filter = '(&'\
          Severity: Minor
          Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

            Method run has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                # Define our instance variables real quick.
                @base_dn = nil
                @ldap_mspki_enterprise_oids = []
                @ldap_groups = []
            Severity: Minor
            Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method convert_sids_to_human_readable_name has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def convert_sids_to_human_readable_name(sids_array)
                output = []
                for sid in sids_array
                  raw_filter = "(objectSID=#{sid})"
                  attributes = ['sAMAccountName', 'name']
            Severity: Minor
            Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method run has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def run
                # Define our instance variables real quick.
                @base_dn = nil
                @ldap_mspki_enterprise_oids = []
                @ldap_groups = []
            Severity: Minor
            Found in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb - About 1 hr to fix

              There are no issues that match your filters.

              Category
              Status