MySQL Server Version Enumeration - Metasploit


This page contains detailed information about how to use the auxiliary/scanner/mysql/mysql_version metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: MySQL Server Version Enumeration
Module: auxiliary/scanner/mysql/mysql_version
Source code: modules/auxiliary/scanner/mysql/mysql_version.rb
Disclosure date: -
Last modification time: 2017-07-24 06:26:21 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 3306
List of CVEs: -

Enumerates the version of MySQL servers.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


This module is a scanner module, and is capable of testing against multiple hosts.

msf > use auxiliary/scanner/mysql/mysql_version
msf auxiliary(mysql_version) > show options
    ... show and set options ...
msf auxiliary(mysql_version) > set RHOSTS ip-range
msf auxiliary(mysql_version) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(mysql_version) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(mysql_version) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(mysql_version) > set RHOSTS file:/tmp/ip_list.txt

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Description


This module, as its name implies, scans a host or range of hosts to determine the version of MySQL that is running.

Verification Steps


  1. Do: use auxiliary/scanner/mysql/mysql_version
  2. Do: set RHOSTS [IP]
  3. Do: set THREADS [number of threads]
  4. Do: run

Scenarios


msf > use auxiliary/scanner/mysql/mysql_version 
msf auxiliary(mysql_version) > set RHOSTS 192.168.1.200-254
RHOSTS => 192.168.1.200-254
msf auxiliary(mysql_version) > set THREADS 20
THREADS => 20
msf auxiliary(mysql_version) > run

[*] 192.168.1.200:3306 is running MySQL 5.0.51a-3ubuntu5 (protocol 10)
[*] 192.168.1.201:3306 is running MySQL, but responds with an error: \x04Host '192.168.1.101' is not allowed to connect to this MySQL server
[*] Scanned 21 of 55 hosts (038% complete)
[*] 192.168.1.203:3306 is running MySQL, but responds with an error: \x04Host '192.168.1.101' is not allowed to connect to this MySQL server
[*] Scanned 22 of 55 hosts (040% complete)
[*] Scanned 42 of 55 hosts (076% complete)
[*] Scanned 44 of 55 hosts (080% complete)
[*] Scanned 45 of 55 hosts (081% complete)
[*] Scanned 48 of 55 hosts (087% complete)
[*] Scanned 50 of 55 hosts (090% complete)
[*] Scanned 51 of 55 hosts (092% complete)
[*] Scanned 52 of 55 hosts (094% complete)
[*] Scanned 55 of 55 hosts (100% complete)
[*] Auxiliary module execution completed
msf auxiliary(mysql_version) >

Go back to menu.

Msfconsole Usage


Here is how the scanner/mysql/mysql_version auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/mysql/mysql_version

msf6 auxiliary(scanner/mysql/mysql_version) > show info

       Name: MySQL Server Version Enumeration
     Module: auxiliary/scanner/mysql/mysql_version
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  kris katterjohn <[email protected]>

Check supported:
  No

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT    3306             yes       The target port (TCP)
  THREADS  1                yes       The number of concurrent threads (max one per host)

Description:
  Enumerates the version of MySQL servers.

Module Options


This is a complete list of options available in the scanner/mysql/mysql_version auxiliary module:

msf6 auxiliary(scanner/mysql/mysql_version) > show options

Module options (auxiliary/scanner/mysql/mysql_version):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT    3306             yes       The target port (TCP)
   THREADS  1                yes       The number of concurrent threads (max one per host)

Advanced Options


Here is a complete list of advanced options supported by the scanner/mysql/mysql_version auxiliary module:

msf6 auxiliary(scanner/mysql/mysql_version) > show advanced

Module advanced options (auxiliary/scanner/mysql/mysql_version):

   Name                 Current Setting  Required  Description
   ----                 ---------------  --------  -----------
   CHOST                                 no        The local client address
   CPORT                                 no        The local client port
   ConnectTimeout       10               yes       Maximum number of seconds to establish a TCP connection
   Proxies                               no        A proxy chain of format type:host:port[,type:host:port][...]
   SSL                  false            no        Negotiate SSL/TLS for outgoing connections
   SSLCipher                             no        String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
   SSLVerifyMode        PEER             no        SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
   SSLVersion           Auto             yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   ShowProgress         true             yes       Display progress messages during a scan
   ShowProgressPercent  10               yes       The interval in percent that progress should be shown
   VERBOSE              false            no        Enable detailed status messages
   WORKSPACE                             no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the scanner/mysql/mysql_version module can do:

msf6 auxiliary(scanner/mysql/mysql_version) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the scanner/mysql/mysql_version auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(scanner/mysql/mysql_version) > show evasion

Module evasion options:

   Name                Current Setting  Required  Description
   ----                ---------------  --------  -----------
   TCP::max_send_size  0                no        Maxiumum tcp segment size.  (0 = disable)
   TCP::send_delay     0                no        Delays inserted before every send.  (0 = disable)

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

The connection to <RHOST>:<RPORT> timed out


Here is a relevant code snippet related to the "The connection to <RHOST>:<RPORT> timed out" error message:

28:	    begin
29:	      s = connect(false)
30:	      data = s.get_once(-1,10)
31:	      disconnect(s)
32:	      if data.nil?
33:	        print_error "The connection to #{rhost}:#{rport} timed out"
34:	        return
35:	      end
36:	    rescue ::Rex::ConnectionError, ::EOFError
37:	      vprint_error("#{rhost}:#{rport} - Connection failed")
38:	      return

<RHOST>:<RPORT> - Connection failed


Here is a relevant code snippet related to the "<RHOST>:<RPORT> - Connection failed" error message:

32:	      if data.nil?
33:	        print_error "The connection to #{rhost}:#{rport} timed out"
34:	        return
35:	      end
36:	    rescue ::Rex::ConnectionError, ::EOFError
37:	      vprint_error("#{rhost}:#{rport} - Connection failed")
38:	      return
39:	    rescue ::Exception
40:	      print_error("Error: #{$!}")
41:	      return
42:	    end

Error


Here is a relevant code snippet related to the "Error" error message:

35:	      end
36:	    rescue ::Rex::ConnectionError, ::EOFError
37:	      vprint_error("#{rhost}:#{rport} - Connection failed")
38:	      return
39:	    rescue ::Exception
40:	      print_error("Error: #{$!}")
41:	      return
42:	    end
43:	
44:	    offset = 0
45:	

<RHOST>:<RPORT> is running MySQL, but responds with an error: <ERR_MSG>


Here is a relevant code snippet related to the "<RHOST>:<RPORT> is running MySQL, but responds with an error: <ERR_MSG>" error message:

55:	
56:	    # Application-level error condition
57:	    if proto == 255
58:	      offset += 2
59:	      err_msg = Rex::Text.to_hex_ascii(data[offset..-1].to_s)
60:	      print_status("#{rhost}:#{rport} is running MySQL, but responds with an error: #{err_msg}")
61:	      report_service(
62:	        :host => rhost,
63:	        :port => rport,
64:	        :name => "mysql",
65:	        :info => "Error: #{err_msg}"

Error: <ERR_MSG>


Here is a relevant code snippet related to the "Error: <ERR_MSG>" error message:

60:	      print_status("#{rhost}:#{rport} is running MySQL, but responds with an error: #{err_msg}")
61:	      report_service(
62:	        :host => rhost,
63:	        :port => rport,
64:	        :name => "mysql",
65:	        :info => "Error: #{err_msg}"
66:	      )
67:	    else
68:	      offset += 1
69:	      version = data[offset..-1].unpack('Z*')[0]
70:	      print_good("#{rhost}:#{rport} is running MySQL #{version} (protocol #{proto})")

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


kris katterjohn

Version


This page has been produced using Metasploit Framework version 6.1.27-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.