rastating/wordpress-exploit-framework

View on GitHub

Showing 338 of 338 total issues

Assignment Branch Condition size for run is too high. [16.31/15]
Open

  def run
    return false unless super

    res = execute_post_request(
      url: wordpress_url_admin_ajax,

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Perceived complexity for run is too high. [8/7]
Open

  def run
    return false unless super

    emit_info 'Validating SQL...'
    unless valid_query?

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Perceived complexity for run is too high. [8/7]
Open

  def run
    return false unless super

    emit_info 'Preparing payload...'
    payload_name = "#{Utility::Text.rand_alpha(rand(5..10))}.php"

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Perceived complexity for run is too high. [8/7]
Open

  def run
    return false unless super

    emit_info 'Preparing payload...'
    year = Time.new.year.to_s

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Cyclomatic complexity for run is too high. [7/6]
Open

  def run
    return false unless super

    emit_info 'Preparing payload...'
    payload_name = "#{Utility::Text.rand_alpha(10, :lower)}.php"

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for random_browser_and_os is too high. [16.76/15]
Open

      def random_browser_and_os
        frequencies = clients_by_frequency
        target_frequency = rand(1..100)
        sum = 0

Severity: Minor
Found in lib/wpxf/net/user_agent.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Assignment Branch Condition size for extract_name_from_res is too high. [16.79/15]
Open

  def extract_name_from_res(res)
    begin
      json = JSON.parse(res.body)
      if json.nil? || json['files'].nil? || json['files'][0].nil? || json['files'][0]['name'].nil?
        return nil

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for run is too high. [7/6]
Open

  def run
    return false unless super

    @credentials = [{
      username: 'Username', password: 'Password Hash', email: 'E-mail'

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Perceived complexity for run is too high. [8/7]
Open

  def run
    return false unless super

    emit_info 'Extracting table prefix...'
    prefix = table_prefix

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

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

  def run
    return false unless super

    @cookie = authenticate_with_wordpress(datastore['username'], datastore['password'])
    return false unless @cookie

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
    super

    update_info(
      name: 'Content Audit <= 1.9.1 CSRF Stored XSS Shell Upload',

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

      def initialize
        super
    
        update_info(
          name: 'WordPress 4.7.0 - 4.7.1 Unauthenticated Content Injection',
    Severity: Minor
    Found in lib/wpxf/modules/auxiliary/misc/wp_v4.7.1_content_injection.rb - About 1 hr to fix

      Assignment Branch Condition size for run is too high. [15.33/15]
      Open

        def run
          return false unless super
      
          emit_info 'Storing script...'
          res = execute_get_request(

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for check is too high. [15.43/15]
      Open

        def check
          target_version = wordpress_version
          vuln_ranges = [
            [Gem::Version.new('0'), Gem::Version.new('3.7.5')],
            [Gem::Version.new('3.8'), Gem::Version.new('3.8.5')],

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for on_http_request is too high. [15.17/15]
      Open

        def on_http_request(path, params, headers)
          if params['u'] && params['p']
            emit_success "Created a new administrator user, #{params['u']}:#{params['p']}"
            stop_http_server
      
      

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Assignment Branch Condition size for download_file is too high. [15.56/15]
      Open

            def download_file(opts)
              target_file = File.open(opts[:local_filename], 'wb')
              req = create_typhoeus_request(opts)
      
              req.on_headers do |response|
      Severity: Minor
      Found in lib/wpxf/net/http_client.rb by rubocop

      This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

      Method run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def run
          return false unless super
      
          @cookie = authenticate_with_wordpress(datastore['username'], datastore['password'])
          return false unless @cookie

        Method run has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run
            return false unless super
        
            cookie = authenticate_with_wordpress(username, password)
            return false unless cookie
        Severity: Minor
        Found in lib/wpxf/modules/exploit/shell/photo_gallery_shell_upload.rb - About 1 hr to fix

          Method run has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def run
              return false unless super
          
              listing = [{
                name: 'Name', type: 'Type'

            Method page_script has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def page_script
                func1 = Utility::Text.rand_alpha(rand(5..10))
                func2 = Utility::Text.rand_alpha(rand(5..10))
                %|
                  debugger;
              Severity
              Category
              Status
              Source
              Language