Added calls to enumerate users and groups to linux post mixin
git-svn-id: file:///home/svn/framework3/trunk@12828 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
46cb4954b5
commit
e1c8e9032b
|
@ -5,8 +5,8 @@ module Msf
|
|||
class Post
|
||||
|
||||
module System
|
||||
include Msf::Post::Common
|
||||
include Msf::Post::File
|
||||
include ::Msf::Post::Common
|
||||
include ::Msf::Post::File
|
||||
|
||||
# Returns a Hash containing Distribution Name, Version and Kernel Information
|
||||
def linux_ver
|
||||
|
@ -87,6 +87,42 @@ module System
|
|||
return system_data
|
||||
end
|
||||
|
||||
# Returns an array of hashes each representing a user
|
||||
# Keys are name, uid, gid, info, dir and shell
|
||||
def get_users
|
||||
users = []
|
||||
cmd_out = `cat /etc/passwd`.split("\n")
|
||||
cmd_out.each do |l|
|
||||
entry = {}
|
||||
user_field = l.split(":")
|
||||
entry[:name] = user_field[0]
|
||||
entry[:uid] = user_field[2]
|
||||
entry[:gid] = user_field[3]
|
||||
entry[:info] = user_field[4]
|
||||
entry[:dir] = user_field[5]
|
||||
entry[:shell] = user_field[6]
|
||||
users << entry
|
||||
end
|
||||
return users
|
||||
end
|
||||
|
||||
# Returns an array of hashes each hash representing a user group
|
||||
# Keys are name, gid and users
|
||||
def get_groups
|
||||
groups = []
|
||||
cmd_out = `cat /etc/group`.split("\n")
|
||||
cmd_out.each do |l|
|
||||
entry = {}
|
||||
user_field = l.split(":")
|
||||
entry[:name] = user_field[0]
|
||||
entry[:gid] = user_field[2]
|
||||
entry[:users] = user_field[3]
|
||||
groups << entry
|
||||
end
|
||||
return groups
|
||||
end
|
||||
|
||||
|
||||
end # System
|
||||
end # Post
|
||||
end # Msf
|
||||
|
|
Loading…
Reference in New Issue