fix formating, replace spaces for tabs
git-svn-id: file:///home/svn/framework3/trunk@12833 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
a25ce9055e
commit
4499aa543d
|
@ -6,15 +6,15 @@ class Post
|
||||||
module Priv
|
module Priv
|
||||||
include ::Msf::Post::Common
|
include ::Msf::Post::Common
|
||||||
|
|
||||||
# Returns true if running as root, false if not.
|
# Returns true if running as root, false if not.
|
||||||
def is_root?
|
def is_root?
|
||||||
root_priv = false
|
root_priv = false
|
||||||
user_id = cmd_exec("/bin/id -u")
|
user_id = cmd_exec("/bin/id -u")
|
||||||
if user_id.to_i == 0
|
if user_id.to_i == 0
|
||||||
root_priv = true
|
root_priv = true
|
||||||
|
end
|
||||||
|
return root_priv
|
||||||
end
|
end
|
||||||
return root_priv
|
|
||||||
end
|
|
||||||
|
|
||||||
end # Priv
|
end # Priv
|
||||||
end # Post
|
end # Post
|
||||||
|
|
|
@ -6,121 +6,121 @@ class Post
|
||||||
|
|
||||||
module System
|
module System
|
||||||
include ::Msf::Post::Common
|
include ::Msf::Post::Common
|
||||||
include ::Msf::Post::File
|
include ::Msf::Post::File
|
||||||
|
|
||||||
# Returns a Hash containing Distribution Name, Version and Kernel Information
|
# Returns a Hash containing Distribution Name, Version and Kernel Information
|
||||||
def linux_ver
|
def linux_ver
|
||||||
system_data = {}
|
system_data = {}
|
||||||
etc_files = cmd_exec("ls /etc").split()
|
etc_files = cmd_exec("ls /etc").split()
|
||||||
|
|
||||||
# Debian
|
# Debian
|
||||||
if etc_files.include?("debian_version")
|
if etc_files.include?("debian_version")
|
||||||
kernel_version = cmd_exec("uname -a")
|
kernel_version = cmd_exec("uname -a")
|
||||||
if kernel_version =~ /Ubuntu/
|
if kernel_version =~ /Ubuntu/
|
||||||
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
|
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
|
||||||
system_data[:distro] = "ubuntu"
|
system_data[:distro] = "ubuntu"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
else
|
||||||
|
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "debian"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
end
|
||||||
|
|
||||||
|
# Fedora
|
||||||
|
elsif etc_files.include?("fedora-release")
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
|
version = read_file("/etc/fedora-release").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "fedora"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
|
||||||
|
# RedHat
|
||||||
|
elsif etc_files.include?("redhat-release")
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
|
version = read_file("/etc/redhat-release").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "redhat"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
|
||||||
|
# Slackware
|
||||||
|
elsif etc_files.include?("slackware-version")
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
|
version = read_file("/etc/slackware-version").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "slackware"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
|
||||||
|
# Mandrake
|
||||||
|
elsif etc_files.include?("mandrake-release")
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
|
version = read_file("/etc/mandrake-release").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "mandrake"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
|
||||||
|
#SuSE
|
||||||
|
elsif etc_files.include?("SuSE-release")
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
|
version = read_file("/etc/SuSE-release").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "suse"
|
||||||
|
system_data[:version] = version
|
||||||
|
system_data[:kernel] = kernel_version
|
||||||
|
|
||||||
|
# Gentoo
|
||||||
|
elsif etc_files.include?("gentoo-release")
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
|
version = read_file("/etc/gentoo-release").gsub(/\n|\\n|\\l/,'')
|
||||||
|
system_data[:distro] = "gentoo"
|
||||||
system_data[:version] = version
|
system_data[:version] = version
|
||||||
system_data[:kernel] = kernel_version
|
system_data[:kernel] = kernel_version
|
||||||
else
|
else
|
||||||
|
|
||||||
|
# Others
|
||||||
|
kernel_version = cmd_exec("uname -a")
|
||||||
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
|
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
|
||||||
system_data[:distro] = "debian"
|
system_data[:distro] = "linux"
|
||||||
system_data[:version] = version
|
system_data[:version] = version
|
||||||
system_data[:kernel] = kernel_version
|
system_data[:kernel] = kernel_version
|
||||||
end
|
end
|
||||||
|
return system_data
|
||||||
# Fedora
|
|
||||||
elsif etc_files.include?("fedora-release")
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/fedora-release").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "fedora"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
|
|
||||||
# RedHat
|
|
||||||
elsif etc_files.include?("redhat-release")
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/redhat-release").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "redhat"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
|
|
||||||
# Slackware
|
|
||||||
elsif etc_files.include?("slackware-version")
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/slackware-version").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "slackware"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
|
|
||||||
# Mandrake
|
|
||||||
elsif etc_files.include?("mandrake-release")
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/mandrake-release").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "mandrake"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
|
|
||||||
#SuSE
|
|
||||||
elsif etc_files.include?("SuSE-release")
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/SuSE-release").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "suse"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
|
|
||||||
# Gentoo
|
|
||||||
elsif etc_files.include?("gentoo-release")
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/gentoo-release").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "gentoo"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
else
|
|
||||||
|
|
||||||
# Others
|
|
||||||
kernel_version = cmd_exec("uname -a")
|
|
||||||
version = read_file("/etc/issue").gsub(/\n|\\n|\\l/,'')
|
|
||||||
system_data[:distro] = "linux"
|
|
||||||
system_data[:version] = version
|
|
||||||
system_data[:kernel] = kernel_version
|
|
||||||
end
|
end
|
||||||
return system_data
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns an array of hashes each representing a user
|
# Returns an array of hashes each representing a user
|
||||||
# Keys are name, uid, gid, info, dir and shell
|
# Keys are name, uid, gid, info, dir and shell
|
||||||
def get_users
|
def get_users
|
||||||
users = []
|
users = []
|
||||||
cmd_out = cmd_exec("cat /etc/passwd").split("\n")
|
cmd_out = cmd_exec("cat /etc/passwd").split("\n")
|
||||||
cmd_out.each do |l|
|
cmd_out.each do |l|
|
||||||
entry = {}
|
entry = {}
|
||||||
user_field = l.split(":")
|
user_field = l.split(":")
|
||||||
entry[:name] = user_field[0]
|
entry[:name] = user_field[0]
|
||||||
entry[:uid] = user_field[2]
|
entry[:uid] = user_field[2]
|
||||||
entry[:gid] = user_field[3]
|
entry[:gid] = user_field[3]
|
||||||
entry[:info] = user_field[4]
|
entry[:info] = user_field[4]
|
||||||
entry[:dir] = user_field[5]
|
entry[:dir] = user_field[5]
|
||||||
entry[:shell] = user_field[6]
|
entry[:shell] = user_field[6]
|
||||||
users << entry
|
users << entry
|
||||||
end
|
end
|
||||||
return users
|
return users
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of hashes each hash representing a user group
|
# Returns an array of hashes each hash representing a user group
|
||||||
# Keys are name, gid and users
|
# Keys are name, gid and users
|
||||||
def get_groups
|
def get_groups
|
||||||
groups = []
|
groups = []
|
||||||
cmd_out = cmd_exec("cat /etc/group").split("\n")
|
cmd_out = cmd_exec("cat /etc/group").split("\n")
|
||||||
cmd_out.each do |l|
|
cmd_out.each do |l|
|
||||||
entry = {}
|
entry = {}
|
||||||
user_field = l.split(":")
|
user_field = l.split(":")
|
||||||
entry[:name] = user_field[0]
|
entry[:name] = user_field[0]
|
||||||
entry[:gid] = user_field[2]
|
entry[:gid] = user_field[2]
|
||||||
entry[:users] = user_field[3]
|
entry[:users] = user_field[3]
|
||||||
groups << entry
|
groups << entry
|
||||||
end
|
end
|
||||||
return groups
|
return groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end # System
|
end # System
|
||||||
|
|
|
@ -6,100 +6,97 @@ class Post
|
||||||
|
|
||||||
module System
|
module System
|
||||||
include ::Msf::Post::Common
|
include ::Msf::Post::Common
|
||||||
include ::Msf::Post::File
|
include ::Msf::Post::File
|
||||||
|
|
||||||
# Return a hash with system Information
|
|
||||||
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"] = `uname -a`.chomp
|
|
||||||
system_info["Hostname"] = system_info["Kernel"].split(" ")[1]
|
|
||||||
|
|
||||||
return system_info
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns an array of hashes each representing a user on the system
|
|
||||||
# Keys are name, gid, uid, dir and shell
|
|
||||||
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
|
|
||||||
|
|
||||||
|
# Return a hash with system Information
|
||||||
|
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
|
end
|
||||||
users << entry
|
system_info["Kernel"] = `uname -a`.chomp
|
||||||
end
|
system_info["Hostname"] = system_info["Kernel"].split(" ")[1]
|
||||||
return users
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns an array of hashes each representing a system accounts on the system
|
return system_info
|
||||||
# Keys are name, gid, uid, dir and shell
|
end
|
||||||
def get_system_accounts
|
|
||||||
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
|
# Returns an array of hashes each representing a user on the system
|
||||||
users = []
|
# Keys are name, gid, uid, dir and shell
|
||||||
users_arry = cmd_output.split("\n\n")
|
def get_users
|
||||||
users_arry.each do |u|
|
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
|
||||||
entry = {}
|
users = []
|
||||||
u.each_line do |l|
|
users_arry = cmd_output.split("\n\n")
|
||||||
field,val = l.chomp.split(": ")
|
users_arry.each do |u|
|
||||||
next if field == "password"
|
entry = Hash.new
|
||||||
entry[field] = val.chomp
|
u.each_line do |l|
|
||||||
|
field,val = l.chomp.split(": ")
|
||||||
|
next if field == "password"
|
||||||
|
entry[field] = val.chomp
|
||||||
|
|
||||||
|
end
|
||||||
|
users << entry
|
||||||
end
|
end
|
||||||
next if entry["name"] !~ /^_/
|
return users
|
||||||
users << entry
|
|
||||||
end
|
end
|
||||||
return users
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns an array of hashes each representing non system accounts on the system
|
# Returns an array of hashes each representing a system accounts on the system
|
||||||
# Keys are name, gid, uid, dir and shell
|
# Keys are name, gid, uid, dir and shell
|
||||||
def get_nonsystem_accounts
|
def get_system_accounts
|
||||||
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
|
cmd_output = cmd_exec("/usr/bin/dscacheutil -q user")
|
||||||
users = []
|
users = []
|
||||||
users_arry = cmd_output.split("\n\n")
|
users_arry = cmd_output.split("\n\n")
|
||||||
users_arry.each do |u|
|
users_arry.each do |u|
|
||||||
entry = {}
|
entry = {}
|
||||||
u.each_line do |l|
|
u.each_line do |l|
|
||||||
field,val = l.chomp.split(": ")
|
field,val = l.chomp.split(": ")
|
||||||
next if field == "password"
|
next if field == "password"
|
||||||
entry[field] = val.chomp
|
entry[field] = val.chomp
|
||||||
|
end
|
||||||
|
next if entry["name"] !~ /^_/
|
||||||
|
users << entry
|
||||||
end
|
end
|
||||||
next if entry["name"] =~ /^_/
|
return users
|
||||||
users << entry
|
|
||||||
end
|
end
|
||||||
return users
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns an array of hashes each representing user group on the system
|
|
||||||
# Keys are name, guid and users
|
|
||||||
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
|
|
||||||
|
|
||||||
|
# Returns an array of hashes each representing non system accounts on the system
|
||||||
|
# Keys are name, gid, uid, dir and shell
|
||||||
|
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
|
end
|
||||||
groups << entry
|
return users
|
||||||
end
|
end
|
||||||
return groups
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
# Returns an array of hashes each representing user group on the system
|
||||||
|
# Keys are name, guid and users
|
||||||
|
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
|
||||||
end # System
|
end # System
|
||||||
end # Post
|
end # Post
|
||||||
end # Msf
|
end # Msf
|
||||||
|
|
Loading…
Reference in New Issue