rapid7/metasploit-framework

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

Summary

Maintainability
F
3 days
Test Coverage

File manageengine_auth_upload.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::HttpClient

Severity: Minor
Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 4 hrs to fix

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

      def get_version
        res = send_request_cgi({
          'uri'    => '/',
          'method' => 'GET'
        })
    Severity: Minor
    Found in modules/exploits/multi/http/manageengine_auth_upload.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 initialize has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(update_info(info,
          'Name'          => 'ManageEngine Multiple Products Authenticated File Upload',
          'Description'   => %q{
            This module exploits a directory traversal vulnerability in ManageEngine ServiceDesk,
    Severity: Major
    Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 2 hrs to fix

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

        def exploit
          if check == Exploit::CheckCode::Safe
            fail_with(Failure::NotVulnerable, "#{peer} - Target not vulnerable")
          end
      
      
      Severity: Minor
      Found in modules/exploits/multi/http/manageengine_auth_upload.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 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def exploit
          if check == Exploit::CheckCode::Safe
            fail_with(Failure::NotVulnerable, "#{peer} - Target not vulnerable")
          end
      
      
      Severity: Minor
      Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 2 hrs to fix

        Method login has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

          def login
            # Do we already have a valid cookie? If yes, just return that.
            if datastore['JSESSIONID'] != nil
              cookie = 'JSESSIONID=' + datastore['JSESSIONID'].to_s + ';'
              return cookie
        Severity: Minor
        Found in modules/exploits/multi/http/manageengine_auth_upload.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

        Consider simplifying this complex logical expression.
        Open

            if (version[0] <= 9 && version[0] > 4 && version[2] < 9031 && version[3] == 'sd') ||
            (version[0] <= 6 && version[2] < 99999 && version[3] == 'ae') ||
            (version[3] == 'sc' && version[2] < 99999)
              return Exploit::CheckCode::Appears
            end
        Severity: Critical
        Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 1 hr to fix

          Method get_version has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def get_version
              res = send_request_cgi({
                'uri'    => '/',
                'method' => 'GET'
              })
          Severity: Minor
          Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 1 hr to fix

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

              def check
                version = get_version
                # TODO: put fixed version on the two ifs below once (if...) products are fixed
                # sd was fixed on build 9031
                # ae and sc still not fixed
            Severity: Minor
            Found in modules/exploits/multi/http/manageengine_auth_upload.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 login_it360 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

              def login_it360
                # Do we already have a valid cookie? If yes, just return that.
                if datastore['IAMAGENTTICKET']
                  cookie_name = get_it360_cookie_name
                  cookie = 'IAMAGENTTICKET' + cookie_name + '=' + datastore['IAMAGENTTICKET'] + ';'
            Severity: Minor
            Found in modules/exploits/multi/http/manageengine_auth_upload.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 authenticate_it360 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def authenticate_it360(port, path, username, password)
                if datastore['DOMAIN_NAME'] == nil
                  vars_post = {
                    'LOGIN_ID' => username,
                    'PASSWORD' => password,
            Severity: Minor
            Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 1 hr to fix

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

                def login_it360
                  # Do we already have a valid cookie? If yes, just return that.
                  if datastore['IAMAGENTTICKET']
                    cookie_name = get_it360_cookie_name
                    cookie = 'IAMAGENTTICKET' + cookie_name + '=' + datastore['IAMAGENTTICKET'] + ';'
              Severity: Minor
              Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 1 hr to fix

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

                  def send_multipart_request(cookie, payload_name, payload_str)
                    if payload_name =~ /\.ear/
                      upload_path = '../../server/default/deploy'
                    else
                      upload_path = rand_text_alpha(4+rand(4))
                Severity: Minor
                Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 1 hr to fix

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

                    def login
                      # Do we already have a valid cookie? If yes, just return that.
                      if datastore['JSESSIONID'] != nil
                        cookie = 'JSESSIONID=' + datastore['JSESSIONID'].to_s + ';'
                        return cookie
                  Severity: Minor
                  Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 1 hr to fix

                    Avoid deeply nested control flow statements.
                    Open

                            if res.body.to_s =~ /'\/style\/style\.css', '([0-9]+)'\);<\/script>/
                              # ... but get the build number if we can find it
                              version[2] = $1.to_i
                            end
                    Severity: Major
                    Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                            elsif res.body.to_s =~ /\/console\/ConsoleMain\.cc/
                              # IT360 newer versions
                              version[3] = 'it'
                      Severity: Major
                      Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 45 mins to fix

                        Method pick_target has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def pick_target
                            return target if target.name != 'Automatic'
                        
                            version = get_version
                            if (version[0] <= 7 && version[2] < 7016 && version[3] == 'sd') ||
                        Severity: Minor
                        Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 45 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

                        Consider simplifying this complex logical expression.
                        Open

                            if (version[2] > 9030 && version[3] == 'sd') ||
                                (version[2] > 99999 && version[3] == 'ae') ||
                                (version[2] > 99999 && version[3] == 'sc')
                              return Exploit::CheckCode::Safe
                            else
                        Severity: Major
                        Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 40 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                              if (version[0] <= 7 && version[2] < 7016 && version[3] == 'sd') ||
                              (version[0] == 4 && version[3] == 'ae') ||
                              (version[3] == 'sc')
                                # These are all "old style" versions (sc is always old style)
                                return targets[1]
                          Severity: Major
                          Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 40 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                      return cookie
                            Severity: Major
                            Found in modules/exploits/multi/http/manageengine_auth_upload.rb - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status