metasploit-framework/modules/post/windows/gather/win_privs.rb

70 lines
1.8 KiB
Ruby
Raw Normal View History

2011-12-04 19:44:21 +00:00
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# web site for more information on licensing and terms of use.
# http://metasploit.com/
2011-12-04 19:44:21 +00:00
##
require 'msf/core'
require 'rex'
require 'msf/core/post/windows/priv'
class Metasploit3 < Msf::Post
include Msf::Post::Common
include Msf::Post::Windows::Priv
def initialize(info={})
super( update_info( info,
'Name' => 'Windows Gather Privileges Enumeration',
'Description' => %q{
This module will print if UAC is enabled, and if the current account is
2011-12-12 17:33:17 +00:00
ADMIN enabled. It will also print UID, foreground SESSION ID, is SYSTEM status
and current process PRIVILEGES.
2011-12-04 19:44:21 +00:00
},
'License' => MSF_LICENSE,
'Author' => [ 'Merlyn Cousins <drforbin6[at]gmail.com>'],
'Platform' => [ 'windows' ],
'SessionTypes' => [ 'meterpreter' ]
))
end
def run
usr_tbl = Rex::Ui::Text::Table.new(
'Header' => 'Current User',
'Indent' => 1,
2011-12-07 06:23:06 +00:00
'Columns' => ['Is Admin', 'Is System', 'UAC Enabled', 'Foreground ID', 'UID']
2011-12-04 19:44:21 +00:00
)
privs_tbl = Rex::Ui::Text::Table.new(
'Header' =>"Windows Privileges",
'Indent' => 1,
'Columns' => ['Name']
)
# Gather data
uac = is_uac_enabled? ? 'True' : 'False'
admin = is_admin? ? 'True' : 'False'
2011-12-07 06:23:06 +00:00
sys = is_system? ? 'True' : 'False'
2011-12-04 19:44:21 +00:00
uid = client.sys.config.getuid.inspect
begin
2011-12-04 20:50:53 +00:00
# Older OS might not have this (min support is XP)
fid = client.railgun.kernel32.WTSGetActiveConsoleSessionId["return"]
rescue
fid = 'N/A'
end
2011-12-04 19:44:21 +00:00
privs = client.sys.config.getprivs
# Store in tables
2011-12-07 06:23:06 +00:00
usr_tbl << [admin, sys, uac, fid, uid]
2011-12-04 19:44:21 +00:00
privs.each do |priv|
privs_tbl << [priv]
end
# Show tables
print_line(usr_tbl.to_s)
print_line(privs_tbl.to_s)
end
end