Skip to content

Commit 93c7855

Browse files
author
Brent Cook
committed
remove brocade_telnet scanner, extend telnet
Rather than duplicate the entire telnet scanner, add a pre-login hook that a module can use to extend the behavior on connect. This also adds a local pass-through print_error method like http has.
1 parent dc053ae commit 93c7855

File tree

3 files changed

+39
-143
lines changed

3 files changed

+39
-143
lines changed

lib/metasploit/framework/login_scanner/brocade_telnet.rb

Lines changed: 0 additions & 122 deletions
This file was deleted.

lib/metasploit/framework/login_scanner/telnet.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class Telnet
3030
#
3131
# @return [Fixnum]
3232
attr_accessor :telnet_timeout
33+
# @!attribute verbosity
34+
# Prepend code to call before checking for a user login
35+
#
36+
# @return [Proc]
37+
attr_accessor :pre_login
3338

3439
validates :banner_timeout,
3540
presence: true,
@@ -66,6 +71,10 @@ def attempt_login(credential)
6671
end
6772

6873
unless result_options[:status]
74+
if pre_login
75+
pre_login.call(self)
76+
end
77+
6978
unless password_prompt?
7079
send_user(credential.public)
7180
end
@@ -108,13 +117,18 @@ def set_sane_defaults
108117
self.port ||= DEFAULT_PORT
109118
self.banner_timeout ||= 25
110119
self.telnet_timeout ||= 10
120+
self.pre_login ||= nil
111121
self.connection_timeout ||= 30
112122
self.max_send_size ||= 0
113123
self.send_delay ||= 0
114124
# Shim to set up the ivars from the old Login mixin
115125
create_login_ivars
116126
end
117127

128+
def print_error( message )
129+
return if !@parent
130+
@parent.print_error message
131+
end
118132
end
119133
end
120134
end

modules/auxiliary/scanner/telnet/brocade_enable_login.rb

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
require 'msf/core'
77
require 'rex'
88
require 'metasploit/framework/credential_collection'
9-
require 'metasploit/framework/login_scanner/brocade_telnet'
9+
require 'metasploit/framework/login_scanner/telnet'
1010

1111
class Metasploit4 < Msf::Auxiliary
1212

@@ -20,16 +20,14 @@ def initialize
2020
super(
2121
'Name' => 'Brocade Enable Login Check Scanner',
2222
'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
23+
This module will test a range of Brocade network devices for a
24+
privileged logins and report successes. The device authentication mode
25+
must be set as 'aaa authentication enable default local'.
26+
Telnet authentication, e.g. 'enable telnet authentication', should not
27+
be enabled in the device configuration.
28+
29+
This module has been tested against the following devices:
30+
ICX6450-24 SWver 07.4.00bT311,
3331
FastIron WS 624 SWver 07.2.02fT7e1
3432
},
3533
'Author' => 'h00die <mike[at]shorebreaksecurity.com>',
@@ -48,25 +46,29 @@ def initialize
4846
end
4947

5048
def get_username_from_config(un_list,ip)
51-
["config","running-config"].each do |command|
49+
["config", "running-config"].each do |command|
5250
print_status(" Attempting username gathering from #{command} on #{ip}")
53-
sock.puts("\r\n") #ensure the buffer is clear
51+
sock.puts("\r\n") # ensure that the buffer is clear
5452
config = sock.recv(1024)
5553
sock.puts("show #{command}\r\n")
54+
55+
# pull the entire config
5656
while true do
57-
sock.puts(" \r\n") #paging
57+
sock.puts(" \r\n") # paging
5858
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.
59+
# Read until we are back at a prompt and have received the 'end' of
60+
# the config.
6061
break if config.match(/>$/) and config.match(/end/)
61-
end #pull the entire config
62+
end
63+
6264
config.each_line do |un|
6365
if un.match(/^username/)
6466
found_username = un.split(" ")[1].strip
6567
un_list.push(found_username)
6668
print_status(" Found: #{found_username}@#{ip}")
67-
end #username match
68-
end #each line in config
69-
end #end config/running-config loop
69+
end
70+
end
71+
end
7072
end
7173

7274
attr_accessor :no_pass_prompt
@@ -99,7 +101,7 @@ def run_host(ip)
99101

100102
cred_collection = prepend_db_passwords(cred_collection)
101103

102-
scanner = Metasploit::Framework::LoginScanner::Brocade_Telnet.new(
104+
scanner = Metasploit::Framework::LoginScanner::Telnet.new(
103105
host: ip,
104106
port: rport,
105107
proxies: datastore['PROXIES'],
@@ -111,6 +113,7 @@ def run_host(ip)
111113
send_delay: datastore['TCP::send_delay'],
112114
banner_timeout: datastore['TelnetBannerTimeout'],
113115
telnet_timeout: datastore['TelnetTimeout'],
116+
pre_login: lambda{ |s| raw_send("enable\r\n", nsock = s.sock) },
114117
framework: framework,
115118
framework_module: self,
116119
)
@@ -121,6 +124,7 @@ def run_host(ip)
121124
module_fullname: self.fullname,
122125
workspace_id: myworkspace_id
123126
)
127+
124128
if result.success?
125129
credential_core = create_credential(credential_data)
126130
credential_data[:core] = credential_core
@@ -132,7 +136,7 @@ def run_host(ip)
132136
print_error("#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status}: #{result.proof})")
133137
end
134138
end
135-
end #end un loop
139+
end
136140
end
137141

138142
def start_telnet_session(host, port, user, pass, scanner)

0 commit comments

Comments
 (0)