rapid7/metasploit-framework

View on GitHub

Showing 22,177 of 22,177 total issues

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

module Payload::Windows::MeterpreterLoader

  include Msf::ReflectiveDLLLoader
  include Msf::Payload::Windows

Severity: Major
Found in lib/msf/core/payload/windows/meterpreter_loader.rb and 1 other location - About 7 hrs to fix
lib/msf/core/payload/windows/x64/meterpreter_loader_x64.rb on lines 13..122

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

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

Method run has 187 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    check_pcaprub_loaded # Check first
    target  = rhost()
    source  = Rex::Socket.source_address(target)
    saddr   = datastore['SRCADDR']
Severity: Major
Found in modules/auxiliary/spoof/dns/bailiwicked_domain.rb - About 7 hrs to fix

    Method generate has 187 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def generate(_opts = {})
    
        strTitle = datastore['TITLE'] + "X"
        if (strTitle.length < 1)
          raise ArgumentError, "You must specify a title"
    Severity: Major
    Found in modules/payloads/singles/windows/messagebox.rb - About 7 hrs to fix

      File safari_in_operator_side_effect.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class MetasploitModule < Msf::Exploit::Remote
        Rank = ManualRanking
      
        include Msf::Post::File
        include Msf::Exploit::Remote::HttpServer::BrowserExploit
      Severity: Minor
      Found in modules/exploits/osx/browser/safari_in_operator_side_effect.rb - About 7 hrs to fix

        File exim_gethostbyname_bof.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class MetasploitModule < Msf::Exploit::Remote
          Rank = GreatRanking
        
          include Msf::Exploit::Remote::Tcp
        
        
        Severity: Minor
        Found in modules/exploits/linux/smtp/exim_gethostbyname_bof.rb - About 7 hrs to fix

          File registry.rb has 478 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Msf
          class Post
          module Windows
          
          module Registry
          Severity: Minor
          Found in lib/msf/core/post/windows/registry.rb - About 7 hrs to fix

            File client.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'metasploit/framework/tcp/client'
            require 'metasploit/framework/mssql/tdssslproxy'
            require 'rex/proto/mssql/client_mixin'
            require 'rex/text'
            require 'msf/core/exploit'
            Severity: Minor
            Found in lib/rex/proto/mssql/client.rb - About 7 hrs to fix

              File browser_exploit_server.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'erb'
              require 'cgi'
              require 'date'
              require 'set'
              require 'rex/exploitation/js'
              Severity: Minor
              Found in lib/msf/core/exploit/remote/browser_exploit_server.rb - About 7 hrs to fix

                Method run has 186 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def run
                    check_pcaprub_loaded # Check first.
                
                    target   = rhost()
                    source   = Rex::Socket.source_address(target)
                Severity: Major
                Found in modules/auxiliary/spoof/dns/bailiwicked_host.rb - About 7 hrs to fix

                  Method unifi_config_eater has 186 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def unifi_config_eater(thost, tport, config)
                        # This is for the Ubiquiti Unifi files.  These are typically in the backup download zip file
                        # then in the db.gz file as db.  It is a MongoDB BSON file, which can be difficult to read.
                        # https://stackoverflow.com/questions/51242412/undefined-method-read-bson-document-for-bsonmodule
                        # The BSON file is a bunch of BSON Documents chained together.  There doesn't seem to be a good
                  Severity: Major
                  Found in lib/msf/core/auxiliary/ubiquiti.rb - About 7 hrs to fix

                    Method asm_bind_named_pipe has 186 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def asm_bind_named_pipe(opts={})
                    
                        reliable       = opts[:reliable]
                        timeout        = opts[:timeout] * 1000 # convert to millisecs
                        retry_wait     = 500
                    Severity: Major
                    Found in lib/msf/core/payload/windows/x64/bind_named_pipe_x64.rb - About 7 hrs to fix

                      File build.rb has 476 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'fileutils'
                      require 'uri'
                      require 'open3'
                      require 'optparse'
                      require 'did_you_mean'
                      Severity: Minor
                      Found in docs/build.rb - About 7 hrs to fix

                        Method output_endpoint_data has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def output_endpoint_data(r)
                            ssl_protocols = [
                              { id: 771, name: "TLS", version: "1.2", secure: true, active: false },
                              { id: 770, name: "TLS", version: "1.1", secure: true, active: false },
                              { id: 769, name: "TLS", version: "1.0", secure: true, active: false },
                        Severity: Minor
                        Found in modules/auxiliary/gather/ssllabs_scan.rb - About 7 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 cmd_migrate has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def cmd_migrate(*args)
                            if args.length == 0 || args.any? { |arg| %w(-h --pid --name).include? arg }
                              cmd_migrate_help
                              return true
                            end
                        Severity: Minor
                        Found in lib/rex/post/meterpreter/ui/console/command_dispatcher/core.rb - About 7 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 backdoor_apk has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def backdoor_apk(apkfile, raw_payload, signature = true, manifest = true, apk_data = nil, service = true)
                            unless apk_data || apkfile && File.readable?(apkfile)
                              usage
                              raise RuntimeError, "Invalid template: #{apkfile}"
                            end
                        Severity: Minor
                        Found in lib/msf/core/payload/apk.rb - About 7 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 validate has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def validate(datastore)
                              # First mutate the datastore and normalize all valid values before validating permutations of RHOST/etc.
                              each_pair do |name, option|
                                if option.valid?(datastore[name]) && (val = option.normalize(datastore[name])) != nil
                                  # This *will* result in a module that previously used the
                        Severity: Minor
                        Found in lib/msf/core/option_container.rb - About 7 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 get_current_data_pids has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def get_current_data_pids(bus, src_id, dst_id, opt={})
                            pids = []
                            opt['MAXPKTS'] = 1
                            packets = get_current_data(bus, src_id, dst_id, 0, opt)
                            return pids if packets.nil?
                        Severity: Minor
                        Found in lib/msf/core/post/hardware/automotive/uds.rb - About 7 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 each_unfiltered_password_first has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def each_unfiltered_password_first
                              if user_file.present?
                                user_fd = File.open(user_file, 'r:binary')
                              end
                        
                        
                        Severity: Minor
                        Found in lib/metasploit/framework/credential_collection.rb - About 7 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

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

                            elif args['VERSION'] == "2-4":
                                try:
                                    username = args['USERNAME']
                                    cookie = encrypt_version4(args['USERNAME'])
                                    module.log("Encrypted remember cookie: "+cookie, "good")
                        Severity: Major
                        Found in modules/auxiliary/admin/http/grafana_auth_bypass.py and 1 other location - About 7 hrs to fix
                        modules/auxiliary/admin/http/grafana_auth_bypass.py on lines 114..128

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

                        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

                            if args['VERSION'] == "5":
                                try:
                                    username = args['USERNAME']
                                    cookie = encrypt_version5(args['USERNAME'])
                                    module.log("Encrypted remember cookie: "+cookie, "good")
                        Severity: Major
                        Found in modules/auxiliary/admin/http/grafana_auth_bypass.py and 1 other location - About 7 hrs to fix
                        modules/auxiliary/admin/http/grafana_auth_bypass.py on lines 129..143

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language