rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File wp_popular_posts_rce.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  prepend Msf::Exploit::Remote::AutoCheck
  include Msf::Exploit::FileDropper
Severity: Minor
Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 5 hrs to fix

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

      def create_post(cookie)
        vprint_status('Creating new post')
        # get post ID and nonces
        res = send_request_cgi(
          'uri' => normalize_uri(target_uri.path, 'wp-admin', 'post-new.php'),
    Severity: Minor
    Found in modules/exploits/multi/http/wp_popular_posts_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 boost_post has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

      def boost_post(cookie, post_id, wp_nonce, post_count)
        # redirect as needed
        res = send_request_cgi(
          'uri' => normalize_uri(target_uri.path, 'index.php'),
          'keep_cookies' => true,
    Severity: Minor
    Found in modules/exploits/multi/http/wp_popular_posts_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 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def initialize(info = {})
        super(
          update_info(
            info,
            'Name' => 'Wordpress Popular Posts Authenticated RCE',
    Severity: Major
    Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 2 hrs to fix

      Method create_post has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_post(cookie)
          vprint_status('Creating new post')
          # get post ID and nonces
          res = send_request_cgi(
            'uri' => normalize_uri(target_uri.path, 'wp-admin', 'post-new.php'),
      Severity: Major
      Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 2 hrs to fix

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

          def boost_post(cookie, post_id, wp_nonce, post_count)
            # redirect as needed
            res = send_request_cgi(
              'uri' => normalize_uri(target_uri.path, 'index.php'),
              'keep_cookies' => true,
        Severity: Minor
        Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 1 hr to fix

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

            def get_widget
              # load home page to grab the widget ID. At times we seem to hit the widget when it's refreshing and it doesn't respond
              # which then would kill the exploit, so in this case we just keep trying.
              (1..10).each do |_|
                @res = send_request_cgi(
          Severity: Minor
          Found in modules/exploits/multi/http/wp_popular_posts_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 exploit has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def exploit
              fail_with(Failure::BadConfig, 'SRVHOST must be set to an IP address (0.0.0.0 is invalid) for exploitation to be successful') if datastore['SRVHOST'] == '0.0.0.0'
              cookie = wordpress_login(datastore['USERNAME'], datastore['PASSWORD'])
          
              if cookie.nil?
          Severity: Minor
          Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 1 hr to fix

            Method change_settings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def change_settings(cookie, token)
                vprint_status('Updating popular posts settings for images')
                res = send_request_cgi(
                  'uri' => normalize_uri(target_uri.path, 'wp-admin', 'options-general.php'),
                  'method' => 'POST',
            Severity: Minor
            Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 25 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 add_meta has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def add_meta(cookie, post_id, ajax_nonce, payload_name)
                payload_url = "http://#{datastore['SRVHOSTNAME']}:#{datastore['SRVPORT']}/#{payload_name}"
                vprint_status("Adding malicious metadata for redirect to #{payload_url}")
                res = send_request_cgi(
                  'uri' => normalize_uri(target_uri.path, 'wp-admin', 'admin-ajax.php'),
            Severity: Minor
            Found in modules/exploits/multi/http/wp_popular_posts_rce.rb - About 25 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