|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'metasploit/framework/login_scanner/directadmin' |
| 7 | +require 'metasploit/framework/credential_collection' |
| 8 | + |
| 9 | +class MetasploitModule < Msf::Auxiliary |
| 10 | + include Msf::Exploit::Remote::HttpClient |
| 11 | + include Msf::Auxiliary::AuthBrute |
| 12 | + include Msf::Auxiliary::Report |
| 13 | + include Msf::Auxiliary::Scanner |
| 14 | + |
| 15 | + def initialize(info={}) |
| 16 | + super(update_info(info, |
| 17 | + 'Name' => 'DirectAdmin Web Control Panel Login Utility', |
| 18 | + 'Description' => %q{ |
| 19 | + This module will attempt to authenticate to a DirectAdmin Web Control Panel. |
| 20 | + }, |
| 21 | + 'Author' => [ 'Nick Marcoccio "1oopho1e" <iremembermodems[at]gmail.com>' ], |
| 22 | + 'License' => MSF_LICENSE, |
| 23 | + 'DefaultOptions' => |
| 24 | + { |
| 25 | + 'RPORT' => 2222, |
| 26 | + 'SSL' => true, |
| 27 | + } |
| 28 | + )) |
| 29 | + |
| 30 | + register_options( |
| 31 | + [ |
| 32 | + OptString.new('USERNAME', [false, 'The username to specify for authentication', '']), |
| 33 | + OptString.new('PASSWORD', [false, 'The password to specify for authentication', '']), |
| 34 | + ]) |
| 35 | + end |
| 36 | + |
| 37 | + |
| 38 | + def scanner(ip) |
| 39 | + @scanner ||= lambda { |
| 40 | + cred_collection = Metasploit::Framework::CredentialCollection.new( |
| 41 | + blank_passwords: datastore['BLANK_PASSWORDS'], |
| 42 | + pass_file: datastore['PASS_FILE'], |
| 43 | + password: datastore['PASSWORD'], |
| 44 | + user_file: datastore['USER_FILE'], |
| 45 | + userpass_file: datastore['USERPASS_FILE'], |
| 46 | + username: datastore['USERNAME'], |
| 47 | + user_as_pass: datastore['USER_AS_PASS'] |
| 48 | + ) |
| 49 | + |
| 50 | + return Metasploit::Framework::LoginScanner::DirectAdmin.new( |
| 51 | + configure_http_login_scanner( |
| 52 | + host: ip, |
| 53 | + port: datastore['RPORT'], |
| 54 | + cred_details: cred_collection, |
| 55 | + stop_on_success: datastore['STOP_ON_SUCCESS'], |
| 56 | + bruteforce_speed: datastore['BRUTEFORCE_SPEED'], |
| 57 | + connection_timeout: 5, |
| 58 | + http_username: datastore['HttpUsername'], |
| 59 | + http_password: datastore['HttpPassword'] |
| 60 | + )) |
| 61 | + }.call |
| 62 | + end |
| 63 | + |
| 64 | + # Attempts to login |
| 65 | + def bruteforce(ip) |
| 66 | + scanner(ip).scan! do |result| |
| 67 | + credential_data = result.to_h.merge({ |
| 68 | + workspace_id: myworkspace_id, |
| 69 | + module_fullname: self.fullname, |
| 70 | + }) |
| 71 | + case result.status |
| 72 | + when Metasploit::Model::Login::Status::SUCCESSFUL |
| 73 | + print_brute(:level => :good, :ip => ip, :msg => "Success: '#{result.credential}'") |
| 74 | + create_credential_and_login(credential_data) |
| 75 | + when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT |
| 76 | + vprint_brute(:level => :verror, :ip => ip, :msg => result.proof) |
| 77 | + invalidate_login(credential_data) |
| 78 | + when Metasploit::Model::Login::Status::INCORRECT |
| 79 | + vprint_brute(:level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}'") |
| 80 | + invalidate_login(credential_data) |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + |
| 86 | + # Start here |
| 87 | + def run_host(ip) |
| 88 | + unless scanner(ip).check_setup |
| 89 | + print_brute(:level => :error, :ip => ip, :msg => 'Target is not DirectAdmin Web Control Panel') |
| 90 | + return |
| 91 | + end |
| 92 | + |
| 93 | + bruteforce(ip) |
| 94 | + end |
| 95 | +end |
0 commit comments