rapid7/metasploit-framework

View on GitHub
modules/exploits/unix/http/pfsense_diag_routes_webshell.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'pfSense Diag Routes Web Shell Upload',
Severity: Major
Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 2 hrs to fix

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

      def check
        # Grab a CSRF token so that we can log in
        res = send_request_cgi('method' => 'GET', 'uri' => normalize_uri(target_uri.path, '/index.php'))
        return CheckCode::Unknown("Didn't receive a response from the target.") unless res
        return CheckCode::Unknown("Unexpected HTTP response from index.php: #{res.code}") unless res.code == 200
    Severity: Minor
    Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.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 check has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def check
        # Grab a CSRF token so that we can log in
        res = send_request_cgi('method' => 'GET', 'uri' => normalize_uri(target_uri.path, '/index.php'))
        return CheckCode::Unknown("Didn't receive a response from the target.") unless res
        return CheckCode::Unknown("Unexpected HTTP response from index.php: #{res.code}") unless res.code == 200
    Severity: Minor
    Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 1 hr to fix

      Method drop_webshell has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def drop_webshell
          webshell_location = normalize_uri(target_uri.path, "#{@webshell_uri}#{@webshell_name}")
          print_status("Uploading webshell to #{webshell_location}")
      
          # php_webshell = '<?php if(isset($_GET["cmd"])) { system($_GET["cmd"]); } ?>'
      Severity: Minor
      Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 35 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::Detected('No response to log in attempt.') unless res
      Severity: Major
      Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

            return CheckCode::Safe('No response to exploit validation check.') unless res
        Severity: Major
        Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

              return CheckCode::Detected('Log in failed. User provided invalid credentials.') unless res.code == 302
          Severity: Major
          Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return CheckCode::Safe('No response to upload attempt.') unless res
            Severity: Major
            Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return CheckCode::Safe("Exploit attempt did not receive 200 OK: #{res.code}") unless res.code == 200
              Severity: Major
              Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                    return CheckCode::Safe("Exploit validation check did not receive 200 OK: #{res.code}") unless res.code == 200
                Severity: Major
                Found in modules/exploits/unix/http/pfsense_diag_routes_webshell.rb - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status