rapid7/metasploit-framework

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

Summary

Maintainability
F
4 days
Test Coverage

File java_jdwp_debugger.rb has 718 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

  include Msf::Exploit::Remote::Tcp
  include Msf::Exploit::EXE
Severity: Major
Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 1 day to fix

    Class MetasploitModule has 49 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Exploit::Remote
      Rank = GoodRanking
    
      include Msf::Exploit::Remote::Tcp
      include Msf::Exploit::EXE
    Severity: Minor
    Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 6 hrs to fix

      Method parse_entries has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def parse_entries(buf, formats, explicit=true)
          entries = []
          index = 0
      
          if explicit
      Severity: Minor
      Found in modules/exploits/multi/misc/java_jdwp_debugger.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 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def initialize
          super(
            'Name'           => 'Java Debug Wire Protocol Remote Code Execution',
            'Description'    => %q{
              This module abuses exposed Java Debug Wire Protocol services in order
      Severity: Minor
      Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 2 hrs to fix

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

          def parse_entries(buf, formats, explicit=true)
            entries = []
            index = 0
        
            if explicit
        Severity: Minor
        Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 1 hr to fix

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

            def exploit
              @my_id = 0x01
              @vars = {}
              @classes = []
              @methods = {}
          Severity: Minor
          Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 1 hr to fix

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

              def exploit
                @my_id = 0x01
                @vars = {}
                @classes = []
                @methods = {}
            Severity: Minor
            Found in modules/exploits/multi/misc/java_jdwp_debugger.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 read_reply has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def read_reply(timeout = default_timeout)
                length = sock.get_once(4, timeout)
                fail_with(Failure::TimeoutExpired, "#{peer} - Not received response length") unless length
                pkt_len = length.unpack('N')[0]
                if pkt_len < 4
            Severity: Minor
            Found in modules/exploits/multi/misc/java_jdwp_debugger.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 execute_command has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def execute_command(thread_id, cmd)
                size = @vars["objectid_size"]
            
                # 1. Creates a string on target VM with the command to be executed
                cmd_obj_ids = create_string(cmd)
            Severity: Minor
            Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 1 hr to fix

              Method execute_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def execute_command(thread_id, cmd)
                  size = @vars["objectid_size"]
              
                  # 1. Creates a string on target VM with the command to be executed
                  cmd_obj_ids = create_string(cmd)
              Severity: Minor
              Found in modules/exploits/multi/misc/java_jdwp_debugger.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

              Method disable_sec_manager has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                def disable_sec_manager
                  sys_class = get_class_by_name("Ljava/lang/System;")
              
                  fields = get_fields(sys_class["reftype_id"])
              
              
              Severity: Minor
              Found in modules/exploits/multi/misc/java_jdwp_debugger.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

              Method invoke has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def invoke(obj_id, thread_id, class_id, meth_id, args = [])
              Severity: Minor
              Found in modules/exploits/multi/misc/java_jdwp_debugger.rb - About 35 mins to fix

                Method get_method_by_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def get_method_by_name(classname, name, signature = nil)
                    @methods[classname].each do |entry|
                        if signature.nil?
                          return entry if entry["name"].downcase == name.downcase
                        else
                Severity: Minor
                Found in modules/exploits/multi/misc/java_jdwp_debugger.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

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

                  def set_step_event
                    # 1. Select a thread in sleeping status
                    t_id = nil
                    @threads.each_key do |thread|
                      if thread_status(thread) == THREAD_SLEEPING_STATUS
                Severity: Minor
                Found in modules/exploits/multi/misc/java_jdwp_debugger.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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  def create_instance(class_id, thread_id, meth_id, args = [])
                    data = format(@vars["referencetypeid_size"], class_id)
                    data << format(@vars["objectid_size"], thread_id)
                    data << format(@vars["methodid_size"], meth_id)
                    data << [args.length].pack('N')
                Severity: Major
                Found in modules/exploits/multi/misc/java_jdwp_debugger.rb and 1 other location - About 1 hr to fix
                modules/exploits/multi/misc/java_jdwp_debugger.rb on lines 573..586

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 53.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  def invoke_static(class_id, thread_id, meth_id, args = [])
                    data = format(@vars["referencetypeid_size"], class_id)
                    data << format(@vars["objectid_size"], thread_id)
                    data << format(@vars["methodid_size"], meth_id)
                    data << [args.length].pack('N')
                Severity: Major
                Found in modules/exploits/multi/misc/java_jdwp_debugger.rb and 1 other location - About 1 hr to fix
                modules/exploits/multi/misc/java_jdwp_debugger.rb on lines 611..624

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 53.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  def get_sizes
                    formats = [
                        ["I", "fieldid_size"],
                        ["I", "methodid_size"],
                        ["I", "objectid_size"],
                Severity: Minor
                Found in modules/exploits/multi/misc/java_jdwp_debugger.rb and 1 other location - About 40 mins to fix
                modules/exploits/multi/misc/java_jdwp_debugger.rb on lines 307..318

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 37.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                  def get_version
                    formats = [
                        ["S", "descr"],
                        ["I", "jdwp_major"],
                        ["I", "jdwp_minor"],
                Severity: Minor
                Found in modules/exploits/multi/misc/java_jdwp_debugger.rb and 1 other location - About 40 mins to fix
                modules/exploits/multi/misc/java_jdwp_debugger.rb on lines 292..303

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 37.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Identical blocks of code found in 2 locations. Consider refactoring.
                Open

                  def temp_path
                    return nil unless datastore['TMP_PATH']
                    unless datastore['TMP_PATH'].end_with?('/') || datastore['TMP_PATH'].end_with?('\\')
                      fail_with(Failure::BadConfig, 'You need to add a trailing slash/backslash to TMP_PATH')
                    end
                Severity: Minor
                Found in modules/exploits/multi/misc/java_jdwp_debugger.rb and 1 other location - About 20 mins to fix
                modules/exploits/multi/http/struts_code_exec_parameters.rb on lines 80..85

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 27.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status