MYSQL Directory Write Test - Metasploit


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

Module Overview


Name: MYSQL Directory Write Test
Module: auxiliary/scanner/mysql/mysql_writable_dirs
Source code: modules/auxiliary/scanner/mysql/mysql_writable_dirs.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: -

Enumerate writeable directories using the MySQL SELECT INTO DUMPFILE feature, for more information see the URL in the references. Note: For every writable directory found, a file with the specified FILE_NAME containing the text test will be written to the directory.

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_writable_dirs
msf auxiliary(mysql_writable_dirs) > show options
    ... show and set options ...
msf auxiliary(mysql_writable_dirs) > set RHOSTS ip-range
msf auxiliary(mysql_writable_dirs) > exploit

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(mysql_writable_dirs) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(mysql_writable_dirs) > set RHOSTS 192.168.1.1/24

Example 3:

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

Required Options


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

Go back to menu.

Msfconsole Usage


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

msf6 > use auxiliary/scanner/mysql/mysql_writable_dirs

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

       Name: MYSQL Directory Write Test
     Module: auxiliary/scanner/mysql/mysql_writable_dirs
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  AverageSecurityGuy <[email protected]>

Check supported:
  No

Basic options:
  Name       Current Setting  Required  Description
  ----       ---------------  --------  -----------
  DIR_LIST                    yes       List of directories to test
  FILE_NAME  vxJhjYKR         yes       Name of file to write
  PASSWORD                    no        The password for the specified username
  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)
  USERNAME   root             yes       The username to authenticate as

Description:
  Enumerate writeable directories using the MySQL SELECT INTO DUMPFILE 
  feature, for more information see the URL in the references. 
  ***Note: For every writable directory found, a file with the 
  specified FILE_NAME containing the text test will be written to the 
  directory.***

References:
  https://dev.mysql.com/doc/refman/5.7/en/select-into.html

Module Options


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

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

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

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   DIR_LIST                    yes       List of directories to test
   FILE_NAME  vxJhjYKR         yes       Name of file to write
   PASSWORD                    no        The password for the specified username
   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)
   USERNAME   root             yes       The username to authenticate as

Advanced Options


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

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

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

   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_writable_dirs module can do:

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

Auxiliary actions:

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

Evasion Options


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

msf6 auxiliary(scanner/mysql/mysql_writable_dirs) > 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.

For every writable directory found, a file called <FILE_NAME> with the text test will be written to the directory.


Here is a relevant code snippet related to the "For every writable directory found, a file called <FILE_NAME> with the text test will be written to the directory." error message:

37:	    res = @mysql_handle.query(sql)
38:	    res
39:	  end
40:	
41:	  def run_host(ip)
42:	    print_warning("For every writable directory found, a file called #{datastore['FILE_NAME']} with the text test will be written to the directory.")
43:	    print_status("Login...")
44:	
45:	    unless mysql_login_datastore
46:	      print_error('Unable to login to the server.')
47:	      return

Unable to login to the server.


Here is a relevant code snippet related to the "Unable to login to the server." error message:

41:	  def run_host(ip)
42:	    print_warning("For every writable directory found, a file called #{datastore['FILE_NAME']} with the text test will be written to the directory.")
43:	    print_status("Login...")
44:	
45:	    unless mysql_login_datastore
46:	      print_error('Unable to login to the server.')
47:	      return
48:	    end
49:	
50:	    File.read(datastore['DIR_LIST']).each_line do |dir|
51:	      check_dir(dir.chomp)

Timeout: <E.MESSAGE>


Here is a relevant code snippet related to the "Timeout: <E.MESSAGE>" error message:

58:	      print_status("Checking #{dir}...")
59:	      res = mysql_query_no_handle("SELECT _utf8'test' INTO DUMPFILE '#{dir}/" + datastore['FILE_NAME'] + "'")
60:	    rescue ::RbMysql::ServerError => e
61:	      print_warning(e.to_s)
62:	    rescue Rex::ConnectionTimeout => e
63:	      print_error("Timeout: #{e.message}")
64:	    else
65:	      print_good("#{dir} is writeable")
66:	      report_note(
67:	        :host  => rhost,
68:	        :type  => "filesystem.file",

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • AverageSecurityGuy <stephen[at]averagesecurityguy.info>

Version


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

Go back to menu.