rapid7/metasploit-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File splunk_xslt_authenticated_rce.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::HttpClient
  prepend Msf::Exploit::Remote::AutoCheck
Severity: Minor
Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 3 hrs to fix

    Method upload_malicious_file has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def upload_malicious_file(file_content, csrf_token, cookie_string)
        unless csrf_token
          print_error('CSRF token not found')
          return nil
        end
    Severity: Minor
    Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 2 hrs to fix

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

        def initialize(info = {})
          super(
            update_info(
              info,
              'Name' => 'Splunk Authenticated XSLT Upload RCE',
      Severity: Minor
      Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 2 hrs to fix

        Method exploit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def exploit
            cookie_string ||= authenticate
            unless cookie_string
              fail_with(Failure::NoAccess, 'Authentication failed')
            end
        Severity: Minor
        Found in modules/exploits/unix/http/splunk_xslt_authenticated_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 upload_malicious_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def upload_malicious_file(file_content, csrf_token, cookie_string)
            unless csrf_token
              print_error('CSRF token not found')
              return nil
            end
        Severity: Minor
        Found in modules/exploits/unix/http/splunk_xslt_authenticated_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 authenticate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def authenticate
            login_url = normalize_uri(target_uri.path, 'en-US', 'account', 'login')
        
            res = send_request_cgi({
              'method' => 'GET',
        Severity: Minor
        Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 1 hr to fix

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

            def exploit
              cookie_string ||= authenticate
              unless cookie_string
                fail_with(Failure::NoAccess, 'Authentication failed')
              end
          Severity: Minor
          Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 1 hr to fix

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

              def trigger_xslt_transform(jsid, text_value, cookie_string)
                return nil unless jsid && text_value
            
                exploit_endpoint = normalize_uri(target_uri.path, 'en-US', 'api', 'search', 'jobs', jsid, 'results')
                exploit_endpoint << "?xsl=/opt/splunk/var/run/splunk/dispatch/#{text_value}/#{datastore['RANDOM_FILENAME']}.xsl"
            Severity: Minor
            Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 1 hr to fix

              Method trigger_payload has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def trigger_payload(jsid, csrf_token, cookie_string)
                  return nil unless jsid && csrf_token
              
                  runshellscript_url = normalize_uri(target_uri.path, 'en-US', 'splunkd', '__raw', 'servicesNS', datastore['USERNAME'], 'search', 'search', 'jobs')
                  runshellscript_data = {
              Severity: Minor
              Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 1 hr to fix

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

                  def check
                    unless splunk?
                      return CheckCode::Unknown('Target does not appear to be a Splunk instance')
                    end
                
                
                Severity: Minor
                Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 55 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 authenticate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def authenticate
                    login_url = normalize_uri(target_uri.path, 'en-US', 'account', 'login')
                
                    res = send_request_cgi({
                      'method' => 'GET',
                Severity: Minor
                Found in modules/exploits/unix/http/splunk_xslt_authenticated_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

                Avoid too many return statements within this method.
                Open

                    return nil
                Severity: Major
                Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return text_value
                  Severity: Major
                  Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return nil
                    Severity: Major
                    Found in modules/exploits/unix/http/splunk_xslt_authenticated_rce.rb - About 30 mins to fix

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

                        def trigger_payload(jsid, csrf_token, cookie_string)
                          return nil unless jsid && csrf_token
                      
                          runshellscript_url = normalize_uri(target_uri.path, 'en-US', 'splunkd', '__raw', 'servicesNS', datastore['USERNAME'], 'search', 'search', 'jobs')
                          runshellscript_data = {
                      Severity: Minor
                      Found in modules/exploits/unix/http/splunk_xslt_authenticated_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 trigger_xslt_transform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def trigger_xslt_transform(jsid, text_value, cookie_string)
                          return nil unless jsid && text_value
                      
                          exploit_endpoint = normalize_uri(target_uri.path, 'en-US', 'api', 'search', 'jobs', jsid, 'results')
                          exploit_endpoint << "?xsl=/opt/splunk/var/run/splunk/dispatch/#{text_value}/#{datastore['RANDOM_FILENAME']}.xsl"
                      Severity: Minor
                      Found in modules/exploits/unix/http/splunk_xslt_authenticated_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