New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CentOS detected as Amazon Linux #10934

Closed
bcoles opened this Issue Nov 7, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@bcoles
Contributor

bcoles commented Nov 7, 2018

The get_sysinfo method in Msf::Post::Linux::System uses a massive if/elsif block to detect the Linux distribution. /etc/system-release is the second check, and was traditionally used to detect amazon.

  #
  # Returns a Hash containing Distribution Name, Version and Kernel Information
  #
  def get_sysinfo
    system_data = {}
    etc_files = cmd_exec("ls /etc").split()

    kernel_version = cmd_exec("uname -a")
    system_data[:kernel] = kernel_version

    # Debian
    if etc_files.include?("debian_version")
      if kernel_version =~ /Ubuntu/
        version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
        system_data[:distro] = "ubuntu"
        system_data[:version] = version
      else
        version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
        system_data[:distro] = "debian"
        system_data[:version] = version
      end

    # Amazon
    elsif etc_files.include?("system-release")
      version = read_file("/etc/system-release").gsub(/\n|\\n|\\l/,'')
      system_data[:distro] = "amazon"

Some time around CentOS 6 or 7, it started shipping with a /etc/system-release. As such, CentOS is detected as Amazon.

@bcoles bcoles added library bug labels Nov 7, 2018

@bcoles bcoles self-assigned this Nov 7, 2018

@bcoles

This comment has been minimized.

Contributor

bcoles commented Nov 7, 2018

Fixed in #10927

@h00die

This comment has been minimized.

Contributor

h00die commented Nov 10, 2018

merged

@h00die h00die closed this Nov 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment