MYSQL File/Directory Enumerator - Metasploit


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

Module Overview


Name: MYSQL File/Directory Enumerator
Module: auxiliary/scanner/mysql/mysql_file_enum
Source code: modules/auxiliary/scanner/mysql/mysql_file_enum.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 files and directories using the MySQL load_file feature, for more information see the URL in the references.

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

Other examples of setting the RHOSTS option:

Example 1:

msf auxiliary(mysql_file_enum) > set RHOSTS 192.168.1.3-192.168.1.200 

Example 2:

msf auxiliary(mysql_file_enum) > set RHOSTS 192.168.1.1/24

Example 3:

msf auxiliary(mysql_file_enum) > 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_file_enum auxiliary module looks in the msfconsole:

msf6 > use auxiliary/scanner/mysql/mysql_file_enum

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

       Name: MYSQL File/Directory Enumerator
     Module: auxiliary/scanner/mysql/mysql_file_enum
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Robin Wood <[email protected]>

Check supported:
  No

Basic options:
  Name           Current Setting  Required  Description
  ----           ---------------  --------  -----------
  DATABASE_NAME  mysql            yes       Name of database to use
  FILE_LIST                       yes       List of directories to enumerate
  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)
  TABLE_NAME     NgszeFyV         yes       Name of table to use - Warning, if the table already exists its contents will be corrupted
  THREADS        1                yes       The number of concurrent threads (max one per host)
  USERNAME       root             yes       The username to authenticate as

Description:
  Enumerate files and directories using the MySQL load_file feature, 
  for more information see the URL in the references.

References:
  http://pauldotcom.com/2013/01/mysql-file-system-enumeration.html
  http://www.digininja.org/projects/mysql_file_enum.php

Module Options


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

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

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

   Name           Current Setting  Required  Description
   ----           ---------------  --------  -----------
   DATABASE_NAME  mysql            yes       Name of database to use
   FILE_LIST                       yes       List of directories to enumerate
   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)
   TABLE_NAME     NgszeFyV         yes       Name of table to use - Warning, if the table already exists its contents will be corrupted
   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_file_enum auxiliary module:

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

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

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

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

Auxiliary actions:

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

Evasion Options


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

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

MySQL Error: <E.CLASS> <E.TO_S>


Here is a relevant code snippet related to the "MySQL Error: <E.CLASS> <E.TO_S>" error message:

49:	    end
50:	
51:	    begin
52:	      mysql_query_no_handle("USE " + datastore['DATABASE_NAME'])
53:	    rescue ::RbMysql::Error => e
54:	      vprint_error("MySQL Error: #{e.class} #{e.to_s}")
55:	      return
56:	    rescue Rex::ConnectionTimeout => e
57:	      vprint_error("Timeout: #{e.message}")
58:	      return
59:	    end

Timeout: <E.MESSAGE>


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

52:	      mysql_query_no_handle("USE " + datastore['DATABASE_NAME'])
53:	    rescue ::RbMysql::Error => e
54:	      vprint_error("MySQL Error: #{e.class} #{e.to_s}")
55:	      return
56:	    rescue Rex::ConnectionTimeout => e
57:	      vprint_error("Timeout: #{e.message}")
58:	      return
59:	    end
60:	
61:	    res = mysql_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" + datastore['DATABASE_NAME'] + "' AND TABLE_NAME = '" + datastore['TABLE_NAME'] + "';")
62:	    table_exists = (res.size == 1)

<DIR> does not exist


Here is a relevant code snippet related to the "<DIR> does not exist" error message:

100:	        :port  => rport,
101:	        :proto => 'tcp',
102:	        :update => :unique_data
103:	      )
104:	    rescue ::RbMysql::ServerError
105:	      vprint_warning("#{dir} does not exist")
106:	    rescue ::RbMysql::Error => e
107:	      vprint_error("MySQL Error: #{e.class} #{e.to_s}")
108:	      return
109:	    rescue Rex::ConnectionTimeout => e
110:	      vprint_error("Timeout: #{e.message}")

MySQL Error: <E.CLASS> <E.TO_S>


Here is a relevant code snippet related to the "MySQL Error: <E.CLASS> <E.TO_S>" error message:

102:	        :update => :unique_data
103:	      )
104:	    rescue ::RbMysql::ServerError
105:	      vprint_warning("#{dir} does not exist")
106:	    rescue ::RbMysql::Error => e
107:	      vprint_error("MySQL Error: #{e.class} #{e.to_s}")
108:	      return
109:	    rescue Rex::ConnectionTimeout => e
110:	      vprint_error("Timeout: #{e.message}")
111:	      return
112:	    else

Timeout: <E.MESSAGE>


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

105:	      vprint_warning("#{dir} does not exist")
106:	    rescue ::RbMysql::Error => e
107:	      vprint_error("MySQL Error: #{e.class} #{e.to_s}")
108:	      return
109:	    rescue Rex::ConnectionTimeout => e
110:	      vprint_error("Timeout: #{e.message}")
111:	      return
112:	    else
113:	      print_good("#{dir} is a file and exists")
114:	      report_note(
115:	        :host  => rhost,

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


  • Robin Wood <robin[at]digininja.org>

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.