rapid7/metasploit-framework

View on GitHub

Showing 16,065 of 22,177 total issues

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

  def exploit
    validate_service_stub_encoder!

    # automatically select an SMB share unless one is explicitly specified
    if datastore['SMBSHARE'] && !datastore['SMBSHARE'].blank?
Severity: Minor
Found in modules/exploits/windows/smb/psexec.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def check
    checkcode = CheckCode::Unknown

    res = send_request_cgi(
      'method' => 'GET',
Severity: Minor
Found in modules/exploits/linux/upnp/belkin_wemo_upnp_exec.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 create_simple_smb_client! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def create_simple_smb_client!
    if session
      print_status("Using existing session #{session.sid}")
      client = session.client
      self.simple = ::Rex::Proto::SMB::SimpleClient.new(client.dispatcher.tcp_socket, client: client)
Severity: Minor
Found in modules/exploits/windows/smb/psexec.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 l.include? 'VERSION="'
                  number = l.split("=")[1].split('"')[1]
                  if number.match /(\d+\.)?(\d+\.)?(\d+\.)?(\*|\d+)$/
                    if number <= '8.1.1.50' and not number < '7'
                      return Exploit::CheckCode::Appears
Severity: Major
Found in modules/exploits/windows/misc/ahsay_backup_fileupload.rb - About 45 mins to fix

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

      def exploit
        # [in] [unique] wchar *
        # [in] [unique] wchar *
        # [out] long
    
    
    Severity: Minor
    Found in modules/exploits/windows/smb/ms06_066_nwwks.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 magic_packet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def magic_packet(mac, username, password)
        mac = mac.gsub(/[:-]/, '').upcase
    
        if mac.length != 12
          fail_with(Failure::BadConfig, 'MAC must be 12 bytes without : or -')
    Severity: Minor
    Found in modules/exploits/linux/telnet/netgear_telnetenable.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 exploit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def exploit
        print_status( "Connecting to the target (#{datastore['RHOST']}:#{datastore['RPORT']})..." )
        connect
    
        # we use ReadAddress to avoid problems in srv2!SrvProcCompleteRequest
    Severity: Minor
    Found in modules/exploits/windows/smb/ms09_050_smb2_negotiate_func_index.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 check_ld_so_build_id_readelf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_ld_so_build_id_readelf
        file_cmd_output = ''
    
        # This needs to be split up by distro as Ubuntu has readlink and which installed by default but "ld.so" is not
        # defined on the path like it is on Debian. Also Ubuntu doesn't have ldconfig install by default.
    Severity: Minor
    Found in modules/exploits/linux/local/glibc_tunables_priv_esc.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 check_ld_so_build_id_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_ld_so_build_id_file
        file_cmd_output = ''
    
        # This needs to be split up by distro as Ubuntu has readlink and which installed by default but "ld.so" is not
        # defined on the path like it is on Debian. Also Ubuntu doesn't have ldconfig install by default.
    Severity: Minor
    Found in modules/exploits/linux/local/glibc_tunables_priv_esc.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check
        # Sanity check
        if is_root?
          fail_with(Failure::None, 'Session already has root privileges')
        end
    Severity: Minor
    Found in modules/exploits/linux/local/zimbra_postfix_priv_esc.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check
        if yama_enabled?
          vprint_error 'YAMA ptrace scope is restrictive'
          return CheckCode::Safe
        end
    Severity: Minor
    Found in modules/exploits/linux/local/ptrace_sudo_token_priv_esc.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 exploit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def exploit
        if check != CheckCode::Detected
          fail_with Failure::NotVulnerable, 'Target is not vulnerable'
        end
    
    
    Severity: Minor
    Found in modules/exploits/linux/local/juju_run_agent_priv_esc.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 check_ld_so_build_id_perf has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_ld_so_build_id_perf
        perf_cmd_output = ''
    
        # This needs to be split up by distro as Ubuntu has readlink and which installed by default but "ld.so" is not
        # defined on the path like it is on Debian. Also Ubuntu doesn't have ldconfig install by default.
    Severity: Minor
    Found in modules/exploits/linux/local/glibc_tunables_priv_esc.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check
        kernel_core_pattern = cmd_exec 'grep abrt-hook-ccpp /proc/sys/kernel/core_pattern'
        unless kernel_core_pattern.include? 'abrt-hook-ccpp'
          vprint_error 'System is not configured to use ABRT for crash reporting'
          return CheckCode::Safe
    Severity: Minor
    Found in modules/exploits/linux/local/abrt_sosreport_priv_esc.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 exploit_nss has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def exploit_nss(resolved_target)
        if target.name == 'Manual'
          fail_with(Failure::BadConfig, 'The "Lengths" advanced option must be specified for the manual target') if datastore['Lengths'].blank?
          exploit_params = datastore['Lengths'].gsub(/,/, ' ').gsub(/  +/, ' ')
        else
    Severity: Minor
    Found in modules/exploits/linux/local/sudo_baron_samedit.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 exploit_userspec has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def exploit_userspec(resolved_target)
        fail_with(Failure::BadConfig, 'The "NewUser" advanced option must be specified for this target') if datastore['NewUser'].blank?
    
        python_binary = find_exec_program
        fail_with(Failure::NotFound, 'The python binary was not found') unless python_binary
    Severity: Minor
    Found in modules/exploits/linux/local/sudo_baron_samedit.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 exploit has a Cognitive Complexity of 8 (exceeds 5 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: Minor
    Found in modules/exploits/linux/local/lastore_daemon_dbus_priv_esc.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 mounts_exist? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def mounts_exist?()
          vprint_status('Checking if mount points exist')
          if target.name == 'CVE-2015-1328'
            if not directory?('/tmp/ns_sploit')
              vprint_good('/tmp/ns_sploit not created')
    Severity: Minor
    Found in modules/exploits/linux/local/overlayfs_priv_esc.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 exploit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def exploit
        # Check if we're already root
        if is_root? && !datastore['ForceExploit']
          fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override'
        end
    Severity: Minor
    Found in modules/exploits/linux/local/tomcat_rhel_based_temp_priv_esc.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 check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def check
        print_status('Unable to determine host OS, this check method is unlikely to be accurate if the host isn\'t Ubuntu')
        release = kernel_release
        # https://people.canonical.com/~ubuntu-security/cve/2022/CVE-2022-0492
        release_short = Rex::Version.new(release.split('-').first)
    Severity: Minor
    Found in modules/exploits/linux/local/docker_cgroup_escape.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