Module: Msf::Post::Linux::System

Includes:
Common, File, Unix
Defined in:
lib/msf/core/post/linux/system.rb

Instance Method Summary collapse

Methods included from Unix

#enum_user_directories, #get_groups, #get_users

Methods included from File

#append_file, #cd, #directory?, #exist?, #expand_path, #file?, #file_local_digestmd5, #file_local_digestsha1, #file_local_digestsha2, #file_local_write, #file_remote_digestmd5, #file_remote_digestsha1, #file_remote_digestsha2, #file_rm, #pwd, #read_file, #rename_file, #rm_f, #upload_file, #write_file

Methods included from Common

#cmd_exec, #cmd_exec_get_pid, #get_env, #get_envs, #has_pid?, #peer, #report_vm, #rhost, #rport

Instance Method Details

#get_sysinfoObject

Returns a Hash containing Distribution Name, Version and Kernel Information


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/msf/core/post/linux/system.rb', line 17

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"
    system_data[:version] = version

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

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

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

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

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

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

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

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

    # Others
    version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
    system_data[:distro] = "linux"
    system_data[:version] = version
  end
  return system_data
end