Skip to content

Commit aeed66b

Browse files
David MaloneyDavid Maloney
authored andcommitted
missing mysql rescue
1 parent d708de0 commit aeed66b

File tree

1 file changed

+41
-35
lines changed
  • lib/metasploit/framework/login_scanner

1 file changed

+41
-35
lines changed

lib/metasploit/framework/login_scanner/mysql.rb

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,64 +16,70 @@ class MySQL
1616
include Metasploit::Framework::Tcp::Client
1717

1818
DEFAULT_PORT = 3306
19-
LIKELY_PORTS = [ 3306 ]
20-
LIKELY_SERVICE_NAMES = [ 'mysql' ]
21-
PRIVATE_TYPES = [ :password ]
22-
REALM_KEY = nil
19+
LIKELY_PORTS = [3306]
20+
LIKELY_SERVICE_NAMES = ['mysql']
21+
PRIVATE_TYPES = [:password]
22+
REALM_KEY = nil
2323

2424
def attempt_login(credential)
2525
result_options = {
26-
credential: credential,
27-
host: host,
28-
port: port,
29-
protocol: 'tcp',
30-
service_name: 'mysql'
26+
credential: credential,
27+
host: host,
28+
port: port,
29+
protocol: 'tcp',
30+
service_name: 'mysql'
3131
}
3232

33-
# manage our behind the scenes socket. Close any existing one and open a new one
34-
disconnect if self.sock
35-
connect
36-
3733
begin
34+
# manage our behind the scenes socket. Close any existing one and open a new one
35+
disconnect if self.sock
36+
connect
37+
3838
::RbMysql.connect({
39-
:host => host,
40-
:port => port,
41-
:read_timeout => 300,
42-
:write_timeout => 300,
43-
:socket => sock,
44-
:user => credential.public,
45-
:password => credential.private,
46-
:db => ''
39+
:host => host,
40+
:port => port,
41+
:read_timeout => 300,
42+
:write_timeout => 300,
43+
:socket => sock,
44+
:user => credential.public,
45+
:password => credential.private,
46+
:db => ''
47+
})
48+
49+
rescue Rex::HostUnreachable
50+
result_options.merge!({
51+
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
52+
proof: "Host was unreachable"
4753
})
48-
rescue Errno::ECONNREFUSED
54+
rescue Errno::ECONNREFUSED, Rex::ConnectionRefused
4955
result_options.merge!({
5056
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
51-
proof: "Connection refused"
57+
proof: "Connection refused"
5258
})
5359
rescue RbMysql::ClientError
5460
result_options.merge!({
55-
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
56-
proof: "Connection timeout"
61+
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
62+
proof: "Connection timeout"
5763
})
58-
rescue Errno::ETIMEDOUT
64+
rescue Errno::ETIMEDOUT, Rex::ConnectionTimeout
5965
result_options.merge!({
60-
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
61-
proof: "Operation Timed out"
66+
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
67+
proof: "Operation Timed out"
6268
})
6369
rescue RbMysql::HostNotPrivileged
6470
result_options.merge!({
65-
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
66-
proof: "Unable to login from this host due to policy"
71+
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
72+
proof: "Unable to login from this host due to policy"
6773
})
6874
rescue RbMysql::AccessDeniedError
6975
result_options.merge!({
70-
status: Metasploit::Model::Login::Status::INCORRECT,
71-
proof: "Access Denied"
76+
status: Metasploit::Model::Login::Status::INCORRECT,
77+
proof: "Access Denied"
7278
})
7379
rescue RbMysql::HostIsBlocked
7480
result_options.merge!({
75-
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
76-
proof: "Host blocked"
81+
status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
82+
proof: "Host blocked"
7783
})
7884
end
7985

@@ -97,4 +103,4 @@ def set_sane_defaults
97103

98104
end
99105
end
100-
end
106+
end

0 commit comments

Comments
 (0)