Module: Msf::Post::OSX::System

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

Instance Method Summary collapse

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_groupsObject

Returns an array of hashes each representing user group on the system Keys are name, guid and users


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/msf/core/post/osx/system.rb', line 90

def get_groups
  cmd_output = cmd_exec("/usr/bin/dscacheutil -q group")
  groups = []
  groups_arry = cmd_output.split("\n\n")
  groups_arry.each do |u|
    entry = Hash.new
    u.each_line do |l|
      field,val = l.chomp.split(": ")
      next if field == "password"
      entry[field] = val.chomp

    end
    groups << entry
  end
  return groups
end

#get_nonsystem_accountsObject

Returns an array of hashes each representing non system accounts on the system Keys are name, gid, uid, dir and shell


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/msf/core/post/osx/system.rb', line 69

def get_nonsystem_accounts
  cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
  users = []
  users_arry = cmd_output.split("\n\n")
  users_arry.each do |u|
    entry = {}
    u.each_line do |l|
      field,val = l.chomp.split(": ")
      next if field == "password"
      entry[field] = val.chomp
    end
    next if entry["name"] =~ /^_/
    users << entry
  end
  return users
end

#get_sysinfoObject

Return a hash with system Information


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/msf/core/post/osx/system.rb', line 10

def get_sysinfo
  system_info = {}
  cmd_output = cmd_exec("/usr/bin/sw_vers").split("\n")
  cmd_output.each do |l|
    field,val = l.chomp.split(":")
    system_info[field] = val.strip
  end
  system_info["Kernel"] = cmd_exec("uname -a")
  system_info["Hostname"] = system_info["Kernel"].split(" ")[1]

  return system_info
end

#get_system_accountsObject

Returns an array of hashes each representing a system accounts on the system Keys are name, gid, uid, dir and shell


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/msf/core/post/osx/system.rb', line 48

def get_system_accounts
  cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
  users = []
  users_arry = cmd_output.split("\n\n")
  users_arry.each do |u|
    entry = {}
    u.each_line do |l|
      field,val = l.chomp.split(": ")
      next if field == "password"
      entry[field] = val.chomp
    end
    next if entry["name"] !~ /^_/
    users << entry
  end
  return users
end

#get_usersObject

Returns an array of hashes each representing a user on the system Keys are name, gid, uid, dir and shell


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/msf/core/post/osx/system.rb', line 27

def get_users
  cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
  users = []
  users_arry = cmd_output.split("\n\n")
  users_arry.each do |u|
    entry = Hash.new
    u.each_line do |l|
      field,val = l.chomp.split(": ")
      next if field == "password"
      entry[field] = val.chomp

    end
    users << entry
  end
  return users
end