rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File wp_crop_rce.rb has 410 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::FileDropper
  include Msf::Exploit::Remote::HTTP::Wordpress
Severity: Minor
Found in modules/exploits/multi/http/wp_crop_rce.rb - About 5 hrs to fix

    Method wp_cleanup has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def wp_cleanup(shell_name, post_id, cookie)
        print_status('Attempting to clean up files...')
        uri = normalize_uri(datastore['TARGETURI'], 'wp-admin', 'admin-ajax.php')
        res = send_request_cgi(
          'method'    => 'POST',
    Severity: Major
    Found in modules/exploits/multi/http/wp_crop_rce.rb - About 2 hrs to fix

      Method upload_file has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def upload_file(img_name, wp_nonce, cookie)
          img_data = %w[
            FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 60 00 60 00 00 FF ED 00 38 50 68 6F
            74 6F 73 68 6F 70 20 33 2E 30 00 38 42 49 4D 04 04 00 00 00 00 00 1C 1C 02 74 00
            10 3C 3F 3D 60 24 5F 47 45 54 5B 30 5D 60 3B 3F 3E 1C 02 00 00 02 00 04 FF FE 00
      Severity: Major
      Found in modules/exploits/multi/http/wp_crop_rce.rb - About 2 hrs to fix

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

          def wp_cleanup(shell_name, post_id, cookie)
            print_status('Attempting to clean up files...')
            uri = normalize_uri(datastore['TARGETURI'], 'wp-admin', 'admin-ajax.php')
            res = send_request_cgi(
              'method'    => 'POST',
        Severity: Minor
        Found in modules/exploits/multi/http/wp_crop_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 initialize has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def initialize(info = {})
            super(update_info(
              info,
              'Name'            => 'WordPress Crop-image Shell Upload',
              'Description'     => %q{
        Severity: Minor
        Found in modules/exploits/multi/http/wp_crop_rce.rb - About 1 hr to fix

          Method check_for_base64 has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def check_for_base64(cookie, post_id)
              uri = normalize_uri(datastore['TARGETURI'])
              # Test if base64 is on target
              test_string = 'YmFzZTY0c3BvdHRlZAo='
              res = send_request_cgi!(
          Severity: Minor
          Found in modules/exploits/multi/http/wp_crop_rce.rb - About 1 hr to fix

            Method include_theme has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def include_theme(shell_name, cookie)
                uri = normalize_uri(datastore['TARGETURI'], 'wp-admin', 'post-new.php')
                res = send_request_cgi(
                  'method'   => 'POST',
                  'uri'      => uri,
            Severity: Minor
            Found in modules/exploits/multi/http/wp_crop_rce.rb - About 1 hr to fix

              Method change_path has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def change_path(wpnonce2, image_id, filename, current_date, path, cookie)
              Severity: Minor
              Found in modules/exploits/multi/http/wp_crop_rce.rb - About 45 mins to fix

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

                  def include_theme(shell_name, cookie)
                    uri = normalize_uri(datastore['TARGETURI'], 'wp-admin', 'post-new.php')
                    res = send_request_cgi(
                      'method'   => 'POST',
                      'uri'      => uri,
                Severity: Minor
                Found in modules/exploits/multi/http/wp_crop_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 check_for_base64 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def check_for_base64(cookie, post_id)
                    uri = normalize_uri(datastore['TARGETURI'])
                    # Test if base64 is on target
                    test_string = 'YmFzZTY0c3BvdHRlZAo='
                    res = send_request_cgi!(
                Severity: Minor
                Found in modules/exploits/multi/http/wp_crop_rce.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

                There are no issues that match your filters.

                Category
                Status