rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def get_ini(file)
    config = client.fs.file.new(file, 'r')
    parse = config.read
    ini = Rex::Parser::Ini.from_s(parse)

Severity: Minor
Found in modules/post/windows/gather/credentials/trillian.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 register_creds has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def register_creds(client_ip, client_port, user, pass, service_name, access_type)
Severity: Minor
Found in modules/post/windows/gather/enum_snmp.rb - About 45 mins to fix

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

      def target_settings(dst_root_key, dst_base_key)
        if datastore['RHOST']
          begin
            dst_key = session.sys.registry.open_remote_key(datastore['RHOST'], dst_root_key)
          rescue ::Rex::Post::Meterpreter::RequestError
    Severity: Minor
    Found in modules/post/windows/manage/clone_proxy_settings.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 get_stuff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_stuff(path, history)
        t = DateTime.new(1601, 1, 1, 0, 0, 0)
        tmpout = ''
        if history
          re = /\x55\x52\x4C\x20.{4}(.{8})(.{8}).*?\x56\x69\x73\x69\x74\x65\x64\x3A.*?\x40(.*?)\x00/m
    Severity: Minor
    Found in modules/post/windows/gather/enum_ie.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def run
        unless session.platform == 'windows' && [ARCH_X64, ARCH_X86].include?(session.arch)
          print_error('This module requires native Windows meterpreter functions not compatible with the selected session')
          return
        end
    Severity: Minor
    Found in modules/post/windows/manage/multi_meterpreter_inject.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 read_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def read_output(process)
        print_status('Start reading output')
        old_timeout = client.response_timeout
        client.response_timeout = 5
    
    
    Severity: Minor
    Found in modules/post/windows/manage/reflective_dll_inject.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

    Avoid deeply nested control flow statements.
    Open

                if (rx = /^Comment:\s(?<comment>.+?)[\r\n]/.match(ppk.to_s))
                  private_key['Comment'] = rx[:comment]
                end
    Severity: Major
    Found in modules/post/windows/gather/enum_putty_saved_sessions.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if pid == session.sys.process.getpid
                    print_good('Success!')
                  else
                    print_error('Migration failed!')
                  end
      Severity: Major
      Found in modules/post/windows/manage/archmigrate.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    until file_exist?('All.cab')
                      sleep(1)
                      print_status('Waiting for All.cab')
                    end
        Severity: Major
        Found in modules/post/windows/gather/ntds_grabber.rb - About 45 mins to fix

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

            def run
              @needs_cleanup = false
          
              hostname = sysinfo.nil? ? cmd_exec('hostname') : sysinfo['Computer']
              print_status("Running module against #{hostname} (#{session.session_host})")
          Severity: Minor
          Found in modules/post/windows/gather/netlm_downgrade.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 install_as_service has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def install_as_service(script_on_target)
              if is_system? || is_admin?
                print_status('Installing as service..')
                nam = datastore['StartupName'] || Rex::Text.rand_text_alpha(rand(8..15))
                description = datastore['ServiceDescription'] || Rex::Text.rand_text_alpha(8)
          Severity: Minor
          Found in modules/post/windows/manage/persistence_exe.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

          Avoid deeply nested control flow statements.
          Open

                      if (rx = /^Encryption:\s(?<cipher>[-a-z0-9]+?)[\r\n]/.match(ppk.to_s))
                        private_key['Cipher'] = rx[:cipher]
                      else
                        private_key['Cipher'] = '(Unrecognised)'
                      end
          Severity: Major
          Found in modules/post/windows/gather/enum_putty_saved_sessions.rb - About 45 mins to fix

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

              def dump_data(target_pid)
                regex = datastore['REGEX']
            
                get_data_from_stack(target_pid).each do |mem|
                  idx = mem['Data'].index(regex)
            Severity: Minor
            Found in modules/post/windows/gather/memory_grep.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 read_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def read_output(pipe, logfilename)
                print_status('Start reading output')
            
                print_status("Writing output to #{logfilename}")
                logfile = File.open(logfilename, 'wb')
            Severity: Minor
            Found in modules/post/windows/manage/execute_dotnet_assembly.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                ssid = datastore['SSID']
                time = datastore['TIMEOUT']
            
                if ssid.length > 32
            Severity: Minor
            Found in modules/post/windows/wlan/wlan_probe_request.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def run
                # check admin privileges
                unless is_system? || is_admin?
                  fail_with(Failure::NotVulnerable, 'Insufficient privileges to install or remove OpenSSH')
                end
            Severity: Minor
            Found in modules/post/windows/manage/install_ssh.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 find_apps has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def find_apps
                apps = %w[
                  truecrypt bulldog ufw iptables fw-settings logrotate logwatch
                  chkrootkit clamav snort tiger firestarter avast lynis
                  rkhunter tcpdump webmin jailkit pwgen proxychains bastille
            Severity: Minor
            Found in modules/post/linux/gather/enum_protections.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 action_enum_luids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def action_enum_luids
                current_luid = get_current_luid
                luids = lsa_enumerate_logon_sessions
                fail_with(Failure::Unknown, 'Failed to enumerate logon sessions.') if luids.nil?
            
            
            Severity: Minor
            Found in modules/post/windows/manage/kerberos_tickets.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 enabletssrv has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def enabletssrv(cleanup_rc)
                service_name = 'termservice'
                srv_info = service_info(service_name)
                begin
                  print_status 'Setting Terminal Services service startup mode'
            Severity: Minor
            Found in modules/post/windows/manage/enable_rdp.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 parse_fstab_credentials has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def parse_fstab_credentials(line, file = '/etc/fstab')
                creds = {}
                # get the username option, which comes in one of four ways
                user_opt = ::Regexp.last_match(1) if (line =~ /user(?:name)?=([^, ]+)/)
                if user_opt
            Severity: Minor
            Found in modules/post/linux/gather/mount_cifs_creds.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

            Severity
            Category
            Status
            Source
            Language