fix user enumeration methods, be more robust

GSoC/Meterpreter_Web_Console
Brent Cook 2018-09-24 22:17:32 -05:00
parent e1ec0ec899
commit c89d8f8fb7
1 changed files with 17 additions and 11 deletions

View File

@ -27,14 +27,15 @@ module Msf::Post::OSX::System
def get_users
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
users = []
users_arry = cmd_output.split("\n\n")
users_arry = cmd_output.tr("\r", "").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
unless val.nil?
entry[field] = val.strip
end
end
users << entry
end
@ -48,15 +49,17 @@ module Msf::Post::OSX::System
def get_system_accounts
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
users = []
users_arry = cmd_output.split("\n\n")
users_arry = cmd_output.tr("\r", "").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
unless val.nil?
entry[field] = val.strip
end
next if entry["name"] !~ /^_/
end
next if entry["name"][0] != '_'
users << entry
end
return users
@ -69,15 +72,17 @@ module Msf::Post::OSX::System
def get_nonsystem_accounts
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
users = []
users_arry = cmd_output.split("\n\n")
users_arry = cmd_output.tr("\r", "").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
unless val.nil?
entry[field] = val.strip
end
next if entry["name"] =~ /^_/
end
next if entry["name"][0] == '_'
users << entry
end
return users
@ -96,8 +101,9 @@ module Msf::Post::OSX::System
u.each_line do |l|
field,val = l.chomp.split(": ")
next if field == "password"
entry[field] = val.chomp
unless val.nil?
entry[field] = val.strip
end
end
groups << entry
end