rapid7/metasploit-framework

View on GitHub
modules/exploits/multi/http/cacti_pollers_sqli_rce.rb

Summary

Maintainability
D
2 days
Test Coverage

File cacti_pollers_sqli_rce.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking

  include Msf::Exploit::Remote::HttpClient
  include Msf::Exploit::SQLi
Severity: Minor
Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 3 hrs to fix

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

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Cacti RCE via SQLi in pollers.php',
    Severity: Major
    Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 2 hrs to fix

      Method do_login has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        def do_login
          if @csrf_token.blank? || @cacti_version.blank?
            res = send_request_cgi(
              'uri' => normalize_uri(target_uri.path, 'index.php'),
              'method' => 'GET',
      Severity: Minor
      Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.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 exploit has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def exploit
          # `#do_login` will take care of populating `@csrf_token` and `@cacti_version`
          unless @logged_in
            begin
              do_login
      Severity: Major
      Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 2 hrs to fix

        Method do_login has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def do_login
            if @csrf_token.blank? || @cacti_version.blank?
              res = send_request_cgi(
                'uri' => normalize_uri(target_uri.path, 'index.php'),
                'method' => 'GET',
        Severity: Minor
        Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 1 hr to fix

          Method check has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def check
              # Step 1 - Check if the target is Cacti and get the version
              print_status('Checking Cacti version')
              res = send_request_cgi(
                'uri' => normalize_uri(target_uri.path, 'index.php'),
          Severity: Minor
          Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 1 hr to fix

            Method check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def check
                # Step 1 - Check if the target is Cacti and get the version
                print_status('Checking Cacti version')
                res = send_request_cgi(
                  'uri' => normalize_uri(target_uri.path, 'index.php'),
            Severity: Minor
            Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.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 sqli has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def sqli
                @sqli ||= create_sqli(dbms: SQLi::MySQLi::TimeBasedBlind) do |sqli_payload|
                  sqli_final_payload = '"'
                  sqli_final_payload << ';select ' unless sqli_payload.start_with?(';') || sqli_payload.start_with?(' and')
                  sqli_final_payload << "#{sqli_payload};select * from poller where 1=1 and '%'=\""
            Severity: Minor
            Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 1 hr to fix

              Method exploit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def exploit
                  # `#do_login` will take care of populating `@csrf_token` and `@cacti_version`
                  unless @logged_in
                    begin
                      do_login
              Severity: Minor
              Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 55 mins 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

              Avoid too many return statements within this method.
              Open

                  return CheckCode::Unknown('Could not get the CSRF token from `index.php`') if @csrf_token.empty?
              Severity: Major
              Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return CheckCode::Safe('Blind SQL injection test failed') unless sqli.test_vulnerable
                Severity: Major
                Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                      return CheckCode::Safe('Could not access `pollers.php` - insufficient permissions') if res.code == 401
                  Severity: Major
                  Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return CheckCode::Unknown("Could not access `pollers.php` - unexpected HTTP response code: #{res.code}") unless res.code == 200
                    Severity: Major
                    Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                          return CheckCode::Unknown('Could not access `pollers.php` - no response') if res.nil?
                      Severity: Major
                      Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                              return CheckCode::Unknown("Login failed: #{e}")
                        Severity: Major
                        Found in modules/exploits/multi/http/cacti_pollers_sqli_rce.rb - About 30 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status