rapid7/metasploit-framework

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

Summary

Maintainability
C
1 day
Test Coverage

Method grab_csrftoken has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

  def grab_csrftoken(auth_res)
    uri = "#{target_uri.path}admin/?_dc=#{auth_res.headers['Location'].scan(/\/admin\/\?_dc=([0-9]+)/).flatten.first}"

    res = send_request_cgi(
      'method' => 'GET',
Severity: Minor
Found in modules/exploits/multi/http/pimcore_unserialize_rce.rb - About 3 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 exploit has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def exploit
    # Try to log in, grab csrfToken and select target
    my_target = login
    if my_target.nil?
      fail_with(Failure::NotVulnerable, 'Target is not vulnerable.')
Severity: Minor
Found in modules/exploits/multi/http/pimcore_unserialize_rce.rb - About 1 hr to fix

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

      def initialize(info = {})
        super(update_info(info,
          'Name' => "Pimcore Unserialize RCE",
          'Description' => %q(
            This module exploits a PHP unserialize() in Pimcore before 5.7.1 to
    Severity: Minor
    Found in modules/exploits/multi/http/pimcore_unserialize_rce.rb - About 1 hr to fix

      Method grab_csrftoken has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def grab_csrftoken(auth_res)
          uri = "#{target_uri.path}admin/?_dc=#{auth_res.headers['Location'].scan(/\/admin\/\?_dc=([0-9]+)/).flatten.first}"
      
          res = send_request_cgi(
            'method' => 'GET',
      Severity: Minor
      Found in modules/exploits/multi/http/pimcore_unserialize_rce.rb - About 1 hr to fix

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

          def login
            # Try to login
            res = send_request_cgi(
              'method' => 'POST',
              'uri' => normalize_uri(target_uri.path, 'admin', 'login', 'login'),
        Severity: Minor
        Found in modules/exploits/multi/http/pimcore_unserialize_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 upload has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def upload
            # JSON file payload
            fpayload = "{\"customlayout\":[{\"creationDate\": \"#{rand(1..9)}\", \"modificationDate\": \"#{rand(1..9)}\", \"userOwner\": \"#{rand(1..9)}\", \"userModification\": \"#{rand(1..9)}\"}]}"
            # construct POST data
            data = Rex::MIME::Message.new
        Severity: Minor
        Found in modules/exploits/multi/http/pimcore_unserialize_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