rapid7/metasploit-framework

View on GitHub
modules/exploits/windows/ibm/ibm_was_dmgr_java_deserialization_rce.rb

Summary

Maintainability
D
2 days
Test Coverage

File ibm_was_dmgr_java_deserialization_rce.rb has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Exploit::Remote
  Rank = ExcellentRanking
  include Msf::Exploit::Remote::Tcp
  include Msf::Exploit::Powershell
  include Msf::Exploit::EXE
Severity: Minor
Found in modules/exploits/windows/ibm/ibm_was_dmgr_java_deserialization_rce.rb - About 6 hrs to fix

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

      def build_tcp_node_msg(obj, msg_type, source_ip, source_port, p2p_obj)
        prng = Random.new
        msg_id = prng.rand(4294967295)
    
        # Create the field type for the origCell
    Severity: Minor
    Found in modules/exploits/windows/ibm/ibm_was_dmgr_java_deserialization_rce.rb - About 2 hrs to fix

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

        def initialize(info = {})
          super(update_info(info,
            'Name' => 'IBM Websphere Application Server Network Deployment Untrusted Data Deserialization Remote Code Execution',
            'Description' => %(
              This module exploits untrusted serialized data processed by the WAS DMGR Server and Cells.

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

          def build_upfile_arg_class(filename, bytes, cmd)
            # Create the field ref
            field_ref = Rex::Java::Serialization::Model::Reference.new
            field_ref.handle = Rex::Java::Serialization::BASE_WIRE_HANDLE + 1
        
        

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

            def build_bcast_flood_msg(obj, msg_type, source_ip, source_port)
              prng = Random.new
              msg_id = prng.rand(4294967295)
          
              # Create the field ref

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

              def build_app_node_class(obj)
                # Create the structured gateway field and add the reference
                struct_bool_field = Rex::Java::Serialization::Model::Field.new
                struct_bool_field.type = 'boolean'
                struct_bool_field.name = Rex::Java::Serialization::Model::Utf.new(nil, 'structuredGateway')

              Method build_bcast_run_task_msg has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def build_bcast_run_task_msg(obj, msg_type, source_ip, source_port, upfile_arg_obj)
                  msg_obj = build_bcast_flood_msg(obj, msg_type, source_ip, source_port)
              
                  # Create the integer field and add the reference
                  out_int_field = Rex::Java::Serialization::Model::Field.new

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

                  def build_p2p_node_class(obj)
                    msg_obj = build_app_node_class(obj)
                
                    # Create the field ref
                    field_ref = Rex::Java::Serialization::Model::Reference.new

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

                    def build_properties_class
                      # Create the object
                      object = Rex::Java::Serialization::Model::NewObject.new
                      object.class_desc = Rex::Java::Serialization::Model::ClassDesc.new
                  
                  

                    Method build_message has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def build_message(obj, msg_id, msg_type, orig_cell_field_type)
                        # Create the integer field and add the reference
                        id_field = Rex::Java::Serialization::Model::Field.new
                        id_field.type = 'int'
                        id_field.name = Rex::Java::Serialization::Model::Utf.new(nil, 'ID')

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

                        def exploit
                          command = nil
                      
                          if target.name == 'CMD'
                            fail_with(Failure::BadConfig, "#{rhost}:#{rport} - Only the cmd/generic payload is compatible") unless datastore['CMD']

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

                          def build_tcp_node_msg(obj, msg_type, source_ip, source_port, p2p_obj)
                        Severity: Minor
                        Found in modules/exploits/windows/ibm/ibm_was_dmgr_java_deserialization_rce.rb - About 35 mins to fix

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

                            def build_bcast_run_task_msg(obj, msg_type, source_ip, source_port, upfile_arg_obj)
                          Severity: Minor
                          Found in modules/exploits/windows/ibm/ibm_was_dmgr_java_deserialization_rce.rb - About 35 mins to fix

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

                              def exploit
                                command = nil
                            
                                if target.name == 'CMD'
                                  fail_with(Failure::BadConfig, "#{rhost}:#{rport} - Only the cmd/generic payload is compatible") unless datastore['CMD']
                            Severity: Minor
                            Found in modules/exploits/windows/ibm/ibm_was_dmgr_java_deserialization_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

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

                                register_options(
                                  [
                                    Opt::RPORT(11006), # 11002,11004,11006,etc
                                    OptBool.new('SSL', [true, 'Negotiate SSL/TLS', true]),
                                    OptRaw.new('SSLVersion', [true, 'Default Version for WASND ', 'SSLv3']),
                            modules/auxiliary/admin/http/manageengine_pmp_privesc.rb on lines 41..48
                            modules/auxiliary/gather/mcafee_epo_xxe.rb on lines 46..53
                            modules/exploits/linux/http/f5_icall_cmd.rb on lines 52..59
                            modules/exploits/linux/http/f5_icontrol_exec.rb on lines 39..46
                            modules/exploits/linux/http/lifesize_uvc_ping_rce.rb on lines 47..54
                            modules/exploits/multi/http/cisco_dcnm_upload_2019.rb on lines 63..70

                            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 33.

                            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