Class: Metasploit::Framework::LoginScanner::MySQL

Inherits:
Object
  • Object
show all
Includes:
Base, RexSocket, Tcp::Client
Defined in:
lib/metasploit/framework/login_scanner/mysql.rb

Overview

This is the LoginScanner class for dealing with MySQL Database servers. It is responsible for taking a single target, and a list of credentials and attempting them. It then saves the results.

Constant Summary collapse

DEFAULT_PORT =
3306
LIKELY_PORTS =
[3306]
LIKELY_SERVICE_NAMES =
['mysql']
PRIVATE_TYPES =
[:password]
REALM_KEY =
nil

Instance Attribute Summary

Attributes included from Tcp::Client

#max_send_size, #send_delay, #sock

Instance Method Summary collapse

Methods included from Tcp::Client

#chost, #connect, #cport, #disconnect, #proxies, #rhost, #rport, #set_tcp_evasions, #ssl, #ssl_version

Instance Method Details

#attempt_login(credential) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/metasploit/framework/login_scanner/mysql.rb', line 24

def (credential)
  result_options = {
    credential:   credential,
    host:         host,
    port:         port,
    protocol:     'tcp',
    service_name: 'mysql'
  }

  begin
    # manage our behind the scenes socket. Close any existing one and open a new one
    disconnect if self.sock
    connect

    ::Mysql.connect(host, credential.public, credential.private, '', port, sock)

  rescue ::SystemCallError, Rex::ConnectionError => e
    result_options.merge!({
      status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
      proof: e
    })
  rescue Mysql::ClientError => e
    result_options.merge!({
      status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
      proof: e
    })
  rescue Mysql::HostNotPrivileged => e
    result_options.merge!({
      status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
      proof: e
    })
  rescue Mysql::AccessDeniedError => e
    result_options.merge!({
      status: Metasploit::Model::Login::Status::INCORRECT,
      proof: e
    })
  rescue Mysql::HostIsBlocked => e
    result_options.merge!({
      status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT,
      proof: e
    })
  end

  unless result_options[:status]
    result_options[:status] = Metasploit::Model::Login::Status::SUCCESSFUL
  end

  ::Metasploit::Framework::LoginScanner::Result.new(result_options)
end

#set_sane_defaultsObject

This method sets the sane defaults for things like timeouts and TCP evasion options



76
77
78
79
80
81
# File 'lib/metasploit/framework/login_scanner/mysql.rb', line 76

def set_sane_defaults
  self.connection_timeout ||= 30
  self.port               ||= DEFAULT_PORT
  self.max_send_size      ||= 0
  self.send_delay         ||= 0
end