@@ -16,64 +16,70 @@ class MySQL
16
16
include Metasploit ::Framework ::Tcp ::Client
17
17
18
18
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
23
23
24
24
def attempt_login ( credential )
25
25
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'
31
31
}
32
32
33
- # manage our behind the scenes socket. Close any existing one and open a new one
34
- disconnect if self . sock
35
- connect
36
-
37
33
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
+
38
38
::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"
47
53
} )
48
- rescue Errno ::ECONNREFUSED
54
+ rescue Errno ::ECONNREFUSED , Rex :: ConnectionRefused
49
55
result_options . merge! ( {
50
56
status : Metasploit ::Model ::Login ::Status ::UNABLE_TO_CONNECT ,
51
- proof : "Connection refused"
57
+ proof : "Connection refused"
52
58
} )
53
59
rescue RbMysql ::ClientError
54
60
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"
57
63
} )
58
- rescue Errno ::ETIMEDOUT
64
+ rescue Errno ::ETIMEDOUT , Rex :: ConnectionTimeout
59
65
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"
62
68
} )
63
69
rescue RbMysql ::HostNotPrivileged
64
70
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"
67
73
} )
68
74
rescue RbMysql ::AccessDeniedError
69
75
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"
72
78
} )
73
79
rescue RbMysql ::HostIsBlocked
74
80
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"
77
83
} )
78
84
end
79
85
@@ -97,4 +103,4 @@ def set_sane_defaults
97
103
98
104
end
99
105
end
100
- end
106
+ end
0 commit comments