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

  def process_propfind(cli, request)
    path = request.uri
    vprint_status("PROPFIND #{path}")

    if path !~ /\/$/
Severity: Major
Found in modules/exploits/windows/http/sap_host_control_cmd_exec.rb and 1 other location - About 5 hrs to fix
modules/exploits/windows/http/cogent_datahub_command.rb on lines 142..254

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

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 build_script_response has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def build_script_response(cli, request)
    response = create_response()
    response['Expires'] = '0'
    response['Cache-Control'] = 'must-revalidate'

Severity: Major
Found in modules/auxiliary/server/browser_autopwn.rb - About 5 hrs to fix

    File moveit_cve_2023_34362.rb has 395 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class MetasploitModule < Msf::Exploit::Remote
      Rank = ExcellentRanking
    
      prepend Msf::Exploit::Remote::AutoCheck
      include Msf::Exploit::Remote::HttpClient
    Severity: Minor
    Found in modules/exploits/windows/http/moveit_cve_2023_34362.rb - About 5 hrs to fix

      File db_export.rb has 395 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Msf
      
      ##
      #
      # This class provides export capabilities
      Severity: Minor
      Found in lib/msf/core/db_export.rb - About 5 hrs to fix

        Method run_host has 136 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def run_host(ip)
        
            ipmi_status("Sending IPMI probes")
        
            usernames = []
        Severity: Major
        Found in modules/auxiliary/scanner/ipmi/ipmi_dumphashes.rb - About 5 hrs to fix

          Method run_host has 136 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def run_host(ip)
              msg = "#{ip}:#{rhost} - DNS -"
              begin
                @lastdata = nil
                @probablyVuln = nil
          Severity: Major
          Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 5 hrs to fix

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

              def generate(_opts = {})
                style = 0x00
                case datastore['ICON'].upcase.strip
                  # default = NO
                when 'ERROR'
            Severity: Major
            Found in modules/payloads/singles/windows/x64/messagebox.rb - About 5 hrs to fix

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

                def exploit
                  if datastore['DefangedMode']
                    warning = <<~EOF
              
              
              
              Severity: Major
              Found in modules/exploits/multi/http/open_web_analytics_rce.rb - About 5 hrs to fix

                Method create_lm_ntlm_responses has 136 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.create_lm_ntlm_responses(user, pass, challenge_key, domain = '', default_name = '', default_domain = '',
                            dns_host_name = '', dns_domain_name = '', chall_MsvAvTimestamp = nil, spnopt = {}, opt = {} )
                
                      usentlm2_session     = opt[:usentlm2_session]    != nil ? opt[:usentlm2_session] : true
                      use_ntlmv2         = opt[:use_ntlmv2]         != nil ? opt[:use_ntlmv2] : false
                Severity: Major
                Found in lib/rex/proto/ntlm/utils.rb - About 5 hrs to fix

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

                    def run
                      if !datastore['SSLServerNameIndication'].nil?
                        sni = datastore['SSLServerNameIndication']
                        print_status("Connecting to #{rhost}:#{rport} SNI:#{sni}")
                      else
                  Severity: Minor
                  Found in modules/auxiliary/gather/impersonate_ssl.rb - About 5 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 crypto_attack has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def crypto_attack(exploit_string)
                      getsin_msg = fetch_getsin
                      if getsin_msg.nil?
                        return nil
                      end
                  Severity: Minor
                  Found in modules/auxiliary/gather/darkcomet_filedownloader.rb - About 5 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 check_request has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def check_request(fingerprint, ip, port, ssl)
                      proto = (ssl ? 'https' : 'http')
                  
                      vprint_status(" * Trying: #{proto}://#{ip}:#{port}/")
                      response = http_get_request_raw(ip, port, ssl, datastore['URIPATH'], datastore['HOSTNAME'])
                  Severity: Minor
                  Found in modules/auxiliary/gather/cloud_lookup.rb - About 5 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 run has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def run
                      @privesc_success = false
                      @computer_created = false
                  
                      opts = {}
                  Severity: Minor
                  Found in modules/auxiliary/admin/dcerpc/cve_2022_26923_certifried.rb - About 5 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 dns_send has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def dns_send(data,method)
                      method = "UDP" if (method == "AUTO" && data.length < 512)
                      method = "TCP" if (method == "AUTO" && data.length >= 512)
                  
                      connect_udp if method == "UDP"
                  Severity: Minor
                  Found in modules/auxiliary/fuzzers/dns/dns_fuzzer.rb - About 5 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 unwanted_modules_table has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def unwanted_modules_table(unwanted_modules)
                      arch_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
                      platform_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
                      session_type_styler = ::Msf::Ui::Console::TablePrint::CustomColorStyler.new
                  
                  
                  Severity: Minor
                  Found in modules/post/multi/recon/local_exploit_suggester.rb - About 5 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 process_backup has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def process_backup(path)
                      print_status("Pulling data from #{path}...")
                  
                      mbdb_data = ''
                      mbdx_data = ''
                  Severity: Minor
                  Found in modules/post/multi/gather/apple_ios_backup.rb - About 5 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 run has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def run
                      hostname = sysinfo.nil? ? cmd_exec('hostname') : sysinfo['Computer']
                      print_status("Running module against #{hostname} (#{session.session_host})")
                  
                      fail_with(Failure::Unknown, "Failed to load incognito on #{session.sid} / #{session.session_host}") unless session.incognito
                  Severity: Minor
                  Found in modules/post/windows/gather/enum_tokens.rb - About 5 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 run has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def run
                      downloadflag = datastore['DOWNLOAD']
                      cleanupflag = datastore['CLEANUP']
                  
                      if is_system?
                  Severity: Minor
                  Found in modules/post/windows/gather/ntds_grabber.rb - About 5 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 run has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def run
                      # Check to ensure that UNIX sockets are supported
                      begin
                        ::UNIXServer
                      rescue NameError
                  Severity: Minor
                  Found in modules/post/windows/manage/forward_pageant.rb - About 5 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 keycap has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def keycap(session, keytime, logfile)
                      rec = 1
                      # Creating DB for captured keystrokes
                      print_status("Keystrokes being saved in to #{logfile}")
                      # Inserting keystrokes every number of seconds specified
                  Severity: Minor
                  Found in modules/post/windows/capture/lockout_keylogger.rb - About 5 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

                  Severity
                  Category
                  Status
                  Source
                  Language