rapid7/metasploit-framework

View on GitHub

Showing 22,177 of 22,177 total issues

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

        if self.__noOutput is False:
            smbConnection = SMBConnection(addr, addr)
            if self.__doKerberos is False:
                smbConnection.login(self.__username, self.__password, self.__domain, self.__lmhash, self.__nthash)
            else:
Severity: Major
Found in modules/auxiliary/scanner/smb/impacket/dcomexec.py and 1 other location - About 1 day to fix
modules/auxiliary/scanner/smb/impacket/wmiexec.py on lines 78..94

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

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

File oraenum.rb has 621 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MetasploitModule < Msf::Auxiliary
  include Msf::Auxiliary::Report
  include Msf::Exploit::ORACLE

  def initialize(info = {})
Severity: Major
Found in modules/auxiliary/admin/oracle/oraenum.rb - About 1 day to fix

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

      def exploit
        if !datastore['ForceExploit'] && is_root?
          fail_with(Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.')
        end
    
    
    Severity: Major
    Found in modules/exploits/linux/local/sock_sendpage.rb - About 1 day to fix

      Method run has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

        def run
          def check_results(passwords, results, hash_type, method)
            passwords.each do |password_line|
              password_line.chomp!
              next if password_line.blank?
      Severity: Minor
      Found in modules/auxiliary/analyze/crack_databases.rb - About 1 day 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_hosts has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

        def cmd_hosts(*args)
          return unless active?
          onlyup = false
          set_rhosts = false
          mode = []
      Severity: Minor
      Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 day 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 rpc_del_vuln has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

        def rpc_del_vuln(xopts)
        ::ApplicationRecord.connection_pool.with_connection {
          opts, wspace = init_db_opts_workspace(xopts)
          opts[:workspace] = opts[:workspace].name
          hosts  = []
      Severity: Minor
      Found in lib/msf/core/rpc/v10/rpc_db.rb - About 1 day 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

      File whatsupgold_credential_dump.rb has 614 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'metasploit/framework/credential_collection'
      
      class MetasploitModule < Msf::Post
        include Msf::Post::Common
        include Msf::Post::File

        Method apply_prepends has 267 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def apply_prepends(buf)
            pre = ''
            app = ''
        
            test_arch = [ *(self.arch) ]
        Severity: Major
        Found in lib/msf/core/payload/linux.rb - About 1 day to fix

          File dns.rb has 611 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          module Msf
          module Ui
          module Console
          module CommandDispatcher
          
          
          Severity: Major
          Found in lib/msf/ui/console/command_dispatcher/dns.rb - About 1 day to fix

            Method run has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                def check_results(passwords, results, hash_type, method)
                  passwords.each do |password_line|
                    password_line.chomp!
                    next if password_line.blank?
            Severity: Minor
            Found in modules/auxiliary/analyze/crack_linux.rb - About 1 day 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 to_executable_fmt has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.to_executable_fmt(framework, arch, plat, code, fmt, exeopts)
                # For backwards compatibility with the way this gets called when
                # generating from Msf::Simple::Payload.generate_simple
                if arch.kind_of? Array
                  output = nil
            Severity: Minor
            Found in lib/msf/util/exe.rb - About 1 day 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_loot has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
            Open

              def cmd_loot(*args)
                return unless active?
            
                mode = :search
                host_ranges = []
            Severity: Minor
            Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 day 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 rpc_del_service has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
            Open

              def rpc_del_service(xopts)
              ::ApplicationRecord.connection_pool.with_connection {
                opts, wspace = init_db_opts_workspace(xopts)
                hosts  = []
                services = []
            Severity: Minor
            Found in lib/msf/core/rpc/v10/rpc_db.rb - About 1 day 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

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

            
                xref = []
                eol = "\x0d\x0a"
                endobj = "endobj" << eol
            
            
            Severity: Major
            Found in modules/exploits/windows/browser/adobe_jbig2decode.rb and 1 other location - About 1 day to fix
            modules/exploits/windows/fileformat/adobe_jbig2decode.rb on lines 176..225

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

            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

                jobs_to_do.each do |job|
                  format = job['type']
                  hash_file = Rex::Quickfile.new("hashes_#{job['type']}_")
                  hash_file.puts job['formatted_hashlist']
                  hash_file.close
            Severity: Major
            Found in modules/auxiliary/analyze/crack_webapps.rb and 1 other location - About 1 day to fix
            modules/auxiliary/analyze/crack_databases.rb on lines 176..256

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

            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

                jobs_to_do.each do |job|
                  format = job['type']
                  hash_file = Rex::Quickfile.new("hashes_#{job['type']}_")
                  hash_file.puts job['formatted_hashlist']
                  hash_file.close
            Severity: Major
            Found in modules/auxiliary/analyze/crack_databases.rb and 1 other location - About 1 day to fix
            modules/auxiliary/analyze/crack_webapps.rb on lines 129..207

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

            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

            
                xref = []
                eol = "\x0d\x0a"
                endobj = "endobj" << eol
            
            
            Severity: Major
            Found in modules/exploits/windows/fileformat/adobe_jbig2decode.rb and 1 other location - About 1 day to fix
            modules/exploits/windows/browser/adobe_jbig2decode.rb on lines 185..234

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

            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 a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                def check_results(passwords, results, hash_type, method)
                  passwords.each do |password_line|
                    password_line.chomp!
                    next if password_line.blank?
            Severity: Minor
            Found in modules/auxiliary/analyze/crack_webapps.rb - About 1 day 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 crawler_process_page has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
            Open

              def crawler_process_page(t, page, cnt)
                return if page.nil? # Skip over pages that don't contain any info aka page is nil. We can't process these types of pages since there is no data to process.
                msg = "[#{"%.5d" % cnt}/#{"%.5d" % max_page_count}]    #{page ? page.code || "ERR" : "ERR"} - #{t[:vhost]} - #{page.url}"
                if page.error
                  print_error("Error accessing page #{page.error.to_s}")
            Severity: Minor
            Found in modules/auxiliary/scanner/http/crawler.rb - About 1 day 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

            Class Db has 70 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Db
            
              require 'tempfile'
            
              include Msf::Ui::Console::CommandDispatcher
            Severity: Major
            Found in lib/msf/ui/console/command_dispatcher/db.rb - About 1 day to fix
              Severity
              Category
              Status
              Source
              Language