rapid7/metasploit-framework

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

Summary

Maintainability
C
1 day
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Intelliants Subrion CMS 4.2.1 - Authenticated File Upload Bypass to RCE',
Severity: Major
Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.rb - About 2 hrs to fix

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

      def login_and_get_csrf_token(username, password)
        print_status('Connecting to Subrion Admin Panel login page to obtain CSRF token...')
    
        # Session cookies need to be kept to preserve the CSRF token across multiple requests
        uri = normalize_uri(target_uri.path, 'panel/')
    Severity: Minor
    Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.rb - About 1 hr to fix

      Method upload_and_execute_payload has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def upload_and_execute_payload(csrf_token)
          print_status('Preparing payload...')
      
          # set `unlink_self: true` to delete the file after execution
          payload_name = "#{Rex::Text.rand_text_alpha_lower(10)}.phar"
      Severity: Minor
      Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.rb - About 1 hr to fix

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

          def check
            uri = normalize_uri(target_uri.path, 'panel/') # requires a trailing forward slash
            print_status("Checking target web server for a response at: #{full_uri(uri)}")
            res = send_request_cgi({
              'method' => 'GET',
        Severity: Minor
        Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.rb - About 1 hr to fix

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

            def check
              uri = normalize_uri(target_uri.path, 'panel/') # requires a trailing forward slash
              print_status("Checking target web server for a response at: #{full_uri(uri)}")
              res = send_request_cgi({
                'method' => 'GET',
          Severity: Minor
          Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.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

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

            def login_and_get_csrf_token(username, password)
              print_status('Connecting to Subrion Admin Panel login page to obtain CSRF token...')
          
              # Session cookies need to be kept to preserve the CSRF token across multiple requests
              uri = normalize_uri(target_uri.path, 'panel/')
          Severity: Minor
          Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.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

          Avoid too many return statements within this method.
          Open

              return CheckCode::Safe
          Severity: Major
          Found in modules/exploits/multi/http/subrion_cms_file_upload_rce.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status