rapid7/metasploit-framework

View on GitHub
modules/exploits/multi/misc/java_jmx_server.rb

Summary

Maintainability
D
1 day
Test Coverage

File java_jmx_server.rb has 298 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::HttpServer
  include Msf::Exploit::Remote::Java::Rmi::Client
Severity: Minor
Found in modules/exploits/multi/misc/java_jmx_server.rb - About 3 hrs to fix

    Method load_payload_from_url has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def load_payload_from_url(conn_stub)
        vprint_status("Creating javax.management.loading.MLet MBean...")
    
        begin
          res = send_jmx_create_mbean(
    Severity: Major
    Found in modules/exploits/multi/misc/java_jmx_server.rb - About 2 hrs to fix

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

        def exploit
          vprint_status("Starting service...")
          start_service
      
          @mlet = "MLet#{rand_text_alpha(8 + rand(4)).capitalize}"
      Severity: Minor
      Found in modules/exploits/multi/misc/java_jmx_server.rb - About 1 hr to fix

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

          def initialize(info = {})
            super(update_info(info,
              'Name'           => 'Java JMX Server Insecure Configuration Java Code Execution',
              'Description'    => %q{
                This module takes advantage a Java JMX interface insecure configuration, which would
        Severity: Minor
        Found in modules/exploits/multi/misc/java_jmx_server.rb - About 1 hr to fix

          Method on_request_uri has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def on_request_uri(cli, request)
              if @jar.nil?
                p = regenerate_payload(cli)
                @jar = p.encoded_jar({random:true})
                paths = [
          Severity: Minor
          Found in modules/exploits/multi/misc/java_jmx_server.rb - About 1 hr to fix

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

              def exploit
                vprint_status("Starting service...")
                start_service
            
                @mlet = "MLet#{rand_text_alpha(8 + rand(4)).capitalize}"
            Severity: Minor
            Found in modules/exploits/multi/misc/java_jmx_server.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 load_payload_from_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def load_payload_from_url(conn_stub)
                vprint_status("Creating javax.management.loading.MLet MBean...")
            
                begin
                  res = send_jmx_create_mbean(
            Severity: Minor
            Found in modules/exploits/multi/misc/java_jmx_server.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

            Avoid too many return statements within this method.
            Open

                  return false
            Severity: Major
            Found in modules/exploits/multi/misc/java_jmx_server.rb - About 30 mins to fix

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

                def check
                  connect
              
                  unless is_rmi?
                    return Exploit::CheckCode::Safe
              Severity: Minor
              Found in modules/exploits/multi/misc/java_jmx_server.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