Microsoft SQL Server Configuration Enumerator - Metasploit


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

Module Overview


Name: Microsoft SQL Server Configuration Enumerator
Module: auxiliary/admin/mssql/mssql_enum
Source code: modules/auxiliary/admin/mssql/mssql_enum.rb
Disclosure date: -
Last modification time: 2017-08-16 21:40:03 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: ms-sql2000, ms-sql-s, sybase
Target network port(s): 1433, 1434, 1435, 2533, 2638, 9152, 14330
List of CVEs: -

This module will perform a series of configuration audits and security checks against a Microsoft SQL Server database. For this module to work, valid administrative user credentials must be supplied.

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


msf > use auxiliary/admin/mssql/mssql_enum
msf auxiliary(mssql_enum) > show targets
    ... a list of targets ...
msf auxiliary(mssql_enum) > set TARGET target-id
msf auxiliary(mssql_enum) > show options
    ... show and set options ...
msf auxiliary(mssql_enum) > exploit

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 admin/mssql/mssql_enum auxiliary module looks in the msfconsole:

msf6 > use auxiliary/admin/mssql/mssql_enum

msf6 auxiliary(admin/mssql/mssql_enum) > show info

       Name: Microsoft SQL Server Configuration Enumerator
     Module: auxiliary/admin/mssql/mssql_enum
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Carlos Perez <[email protected]>

Check supported:
  No

Basic options:
  Name                 Current Setting  Required  Description
  ----                 ---------------  --------  -----------
  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                1433             yes       The target port (TCP)
  TDSENCRYPTION        false            yes       Use TLS/SSL for TDS data "Force Encryption"
  USERNAME             sa               no        The username to authenticate as
  USE_WINDOWS_AUTHENT  false            yes       Use windows authentification (requires DOMAIN option set)

Description:
  This module will perform a series of configuration audits and 
  security checks against a Microsoft SQL Server database. For this 
  module to work, valid administrative user credentials must be 
  supplied.

Module Options


This is a complete list of options available in the admin/mssql/mssql_enum auxiliary module:

msf6 auxiliary(admin/mssql/mssql_enum) > show options

Module options (auxiliary/admin/mssql/mssql_enum):

   Name                 Current Setting  Required  Description
   ----                 ---------------  --------  -----------
   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                1433             yes       The target port (TCP)
   TDSENCRYPTION        false            yes       Use TLS/SSL for TDS data "Force Encryption"
   USERNAME             sa               no        The username to authenticate as
   USE_WINDOWS_AUTHENT  false            yes       Use windows authentification (requires DOMAIN option set)

Advanced Options


Here is a complete list of advanced options supported by the admin/mssql/mssql_enum auxiliary module:

msf6 auxiliary(admin/mssql/mssql_enum) > show advanced

Module advanced options (auxiliary/admin/mssql/mssql_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
   DOMAIN                  WORKSTATION                                                           yes       The domain to use for windows authentication
   HEX2BINARY              /opt/metasploit-framework/embedded/framework/data/exploits/mssql/h2b  no        The path to the hex2binary script on the disk
   NTLM::SendLM            true                                                                  yes       Always send the LANMAN response (except when NTLMv2_session is specified)
   NTLM::SendNTLM          true                                                                  yes       Activate the 'Negotiate NTLM key' flag, indicating the use of NTLM responses
   NTLM::SendSPN           true                                                                  yes       Send an avp of type SPN in the ntlmv2 client blob, this allows authentication on Windows 7+/Server 2008 R2+ when SPN is required
   NTLM::UseLMKey          false                                                                 yes       Activate the 'Negotiate Lan Manager Key' flag, using the LM key when the LM response is sent
   NTLM::UseNTLM2_session  true                                                                  yes       Activate the 'Negotiate NTLM2 key' flag, forcing the use of a NTLMv2_session
   NTLM::UseNTLMv2         true                                                                  yes       Use NTLMv2 instead of NTLM2_session when 'Negotiate NTLM2' key is true
   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)
   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 admin/mssql/mssql_enum module can do:

msf6 auxiliary(admin/mssql/mssql_enum) > show actions

Auxiliary actions:

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

Evasion Options


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

msf6 auxiliary(admin/mssql/mssql_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.

Login was unsuccessful. Check your credentials.


Here is a relevant code snippet related to the "Login was unsuccessful. Check your credentials." error message:

23:	
24:	  def run
25:	    print_status("Running MS SQL Server Enumeration...")
26:	
27:	    if !mssql_login_datastore
28:	      print_error("Login was unsuccessful. Check your credentials.")
29:	      disconnect
30:	      return
31:	    end
32:	
33:	    # Get Version

C2 Audit Mode is Not Enabled


Here is a relevant code snippet related to the "C2 Audit Mode is Not Enabled" error message:

75:	        :proto => 'TCP',
76:	        :port => datastore['RPORT'],
77:	        :type => 'MSSQL_ENUM',
78:	        :data => "C2 Audit Mode is Enabled")
79:	    else
80:	      print_status("\tC2 Audit Mode is Not Enabled")
81:	      report_note(:host => datastore['RHOST'],
82:	        :proto => 'TCP',
83:	        :port => datastore['RPORT'],
84:	        :type => 'MSSQL_ENUM',
85:	        :data => "C2 Audit Mode is Not Enabled")

xp_cmdshell is Not Enabled


Here is a relevant code snippet related to the "xp_cmdshell is Not Enabled" error message:

94:	          :proto => 'TCP',
95:	          :port => datastore['RPORT'],
96:	          :type => 'MSSQL_ENUM',
97:	          :data => "xp_cmdshell is Enabled")
98:	      else
99:	        print_status("\txp_cmdshell is Not Enabled")
100:	        report_note(:host => datastore['RHOST'],
101:	          :proto => 'TCP',
102:	          :port => datastore['RPORT'],
103:	          :type => 'MSSQL_ENUM',
104:	          :data => "xp_cmdshell is Not Enabled")

xp_cmdshell is Not Enabled


Here is a relevant code snippet related to the "xp_cmdshell is Not Enabled" error message:

111:	          :proto => 'TCP',
112:	          :port => datastore['RPORT'],
113:	          :type => 'MSSQL_ENUM',
114:	          :data => "xp_cmdshell is Enabled")
115:	      else
116:	        print_status("\txp_cmdshell is Not Enabled")
117:	        report_note(:host => datastore['RHOST'],
118:	          :proto => 'TCP',
119:	          :port => datastore['RPORT'],
120:	          :type => 'MSSQL_ENUM',
121:	          :data => "xp_cmdshell is Not Enabled")

remote access is Not Enabled


Here is a relevant code snippet related to the "remote access is Not Enabled" error message:

130:	        :proto => 'TCP',
131:	        :port => datastore['RPORT'],
132:	        :type => 'MSSQL_ENUM',
133:	        :data => "remote access is Enabled")
134:	    else
135:	      print_status("\tremote access is Not Enabled")
136:	      report_note(:host => datastore['RHOST'],
137:	        :proto => 'TCP',
138:	        :port => datastore['RPORT'],
139:	        :type => 'MSSQL_ENUM',
140:	        :data => "remote access is not Enabled")

allow updates is Not Enabled


Here is a relevant code snippet related to the "allow updates is Not Enabled" error message:

148:	        :proto => 'TCP',
149:	        :port => datastore['RPORT'],
150:	        :type => 'MSSQL_ENUM',
151:	        :data => "allow updates is Enabled")
152:	    else
153:	      print_status("\tallow updates is Not Enabled")
154:	      report_note(:host => datastore['RHOST'],
155:	        :proto => 'TCP',
156:	        :port => datastore['RPORT'],
157:	        :type => 'MSSQL_ENUM',
158:	        :data => "allow updates is not Enabled")

Database Mail XPs is Not Enabled


Here is a relevant code snippet related to the "Database Mail XPs is Not Enabled" error message:

167:	          :proto => 'TCP',
168:	          :port => datastore['RPORT'],
169:	          :type => 'MSSQL_ENUM',
170:	          :data => "Database Mail XPs is Enabled")
171:	      else
172:	        print_status("\tDatabase Mail XPs is Not Enabled")
173:	        report_note(:host => datastore['RHOST'],
174:	          :proto => 'TCP',
175:	          :port => datastore['RPORT'],
176:	          :type => 'MSSQL_ENUM',
177:	          :data => "Database Mail XPs is not Enabled")

Database Mail XPs is Not Enabled


Here is a relevant code snippet related to the "Database Mail XPs is Not Enabled" error message:

184:	          :proto => 'TCP',
185:	          :port => datastore['RPORT'],
186:	          :type => 'MSSQL_ENUM',
187:	          :data => "Database Mail XPs is Enabled")
188:	      else
189:	        print_status("\tDatabase Mail XPs is Not Enabled")
190:	        report_note(:host => datastore['RHOST'],
191:	          :proto => 'TCP',
192:	          :port => datastore['RPORT'],
193:	          :type => 'MSSQL_ENUM',
194:	          :data => "Database Mail XPs is not Enabled")

Ole Automation Procedures are Not Enabled


Here is a relevant code snippet related to the "Ole Automation Procedures are Not Enabled" error message:

204:	          :proto => 'TCP',
205:	          :port => datastore['RPORT'],
206:	          :type => 'MSSQL_ENUM',
207:	          :data => "Ole Automation Procedures are Enabled")
208:	      else
209:	        print_status("\tOle Automation Procedures are Not Enabled")
210:	        report_note(:host => datastore['RHOST'],
211:	          :proto => 'TCP',
212:	          :port => datastore['RPORT'],
213:	          :type => 'MSSQL_ENUM',
214:	          :data => "Ole Automation Procedures are not Enabled")

Ole Automation Procedures are Not Enabled


Here is a relevant code snippet related to the "Ole Automation Procedures are Not Enabled" error message:

221:	          :proto => 'TCP',
222:	          :port => datastore['RPORT'],
223:	          :type => 'MSSQL_ENUM',
224:	          :data => "Ole Automation Procedures are Enabled")
225:	      else
226:	        print_status("\tOle Automation Procedures are Not Enabled")
227:	        report_note(:host => datastore['RHOST'],
228:	          :proto => 'TCP',
229:	          :port => datastore['RPORT'],
230:	          :type => 'MSSQL_ENUM',
231:	          :data => "Ole Automation Procedures are not Enabled")

Could not enumerate System Logins!


Here is a relevant code snippet related to the "Could not enumerate System Logins!" error message:

284:	          :port => datastore['RPORT'],
285:	          :type => 'MSSQL_ENUM',
286:	          :data => "Database: Master User: #{acc.join}")
287:	      end
288:	    else
289:	      print_error("\tCould not enumerate System Logins!")
290:	      report_note(:host => datastore['RHOST'],
291:	        :proto => 'TCP',
292:	        :port => datastore['RPORT'],
293:	        :type => 'MSSQL_ENUM',
294:	        :data => "Could not enumerate System Logins")

No Accounts Policy is set for


Here is a relevant code snippet related to the "No Accounts Policy is set for" error message:

319:	    end
320:	
321:	    #-------------------------------------------------------
322:	    # Get list of accounts for which password policy does not apply on System
323:	    if vernum.join != "2000"
324:	      print_status("No Accounts Policy is set for:")
325:	      nopolicysyslogins = mssql_query("select name from master.sys.sql_logins where is_policy_checked = 0")[:rows]
326:	      if nopolicysyslogins != nil
327:	        nopolicysyslogins.each do |acc|
328:	          print_status("\t#{acc.join}")
329:	          report_note(:host => datastore['RHOST'],

Password Expiration is not checked for


Here is a relevant code snippet related to the "Password Expiration is not checked for" error message:

343:	    end
344:	
345:	    #-------------------------------------------------------
346:	    # Get list of accounts for which password expiration is not checked
347:	    if vernum.join != "2000"
348:	      print_status("Password Expiration is not checked for:")
349:	      passexsyslogins = mssql_query("select name from master.sys.sql_logins where is_expiration_checked = 0")[:rows]
350:	      if passexsyslogins != nil
351:	        passexsyslogins.each do |acc|
352:	          print_status("\t#{acc.join}")
353:	          report_note(:host => datastore['RHOST'],

Could not enumerate sysadmin accounts!


Here is a relevant code snippet related to the "Could not enumerate sysadmin accounts!" error message:

382:	          :port => datastore['RPORT'],
383:	          :type => 'MSSQL_ENUM',
384:	          :data => "Sysdba: #{acc.join}")
385:	      end
386:	    else
387:	      print_error("\tCould not enumerate sysadmin accounts!")
388:	      report_note(:host => datastore['RHOST'],
389:	        :proto => 'TCP',
390:	        :port => datastore['RPORT'],
391:	        :type => 'MSSQL_ENUM',
392:	        :data => "Could not enumerate sysadmin accounts")

xp_enumerrorlogs


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

552:	      'xp_dsninfo',
553:	      'xp_enum_activescriptengines',
554:	      'xp_enum_oledb_providers',
555:	      'xp_enumcodepages',
556:	      'xp_enumdsn',
557:	      'xp_enumerrorlogs',
558:	      'xp_enumgroups',
559:	      'xp_enumqueuedtasks',
560:	      'xp_eventlog',
561:	      'xp_execresultset',
562:	      'xp_fileexist',

xp_readerrorlog


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

588:	      'xp_perfstart',
589:	      'xp_printstatements',
590:	      'xp_prop_oledb_provider',
591:	      'xp_proxiedmetadata',
592:	      'xp_qv',
593:	      'xp_readerrorlog',
594:	      'xp_readmail',
595:	      'xp_readwebtask',
596:	      'xp_regaddmultistring',
597:	      'xp_regdeletekey',
598:	      'xp_regdeletevalue',

No instances found, possible permission problem


Here is a relevant code snippet related to the "No instances found, possible permission problem" error message:

761:	          :port => datastore['RPORT'],
762:	          :type => 'MSSQL_ENUM',
763:	          :data => "Instance Name: #{i}")
764:	      end
765:	    else
766:	      print_status("No instances found, possible permission problem")
767:	    end
768:	
769:	    #---------------------------------------------------------
770:	    # Enumerate under what accounts the instance services are running under
771:	    print_status("Default Server Instance SQL Server Service is running under the privilege of:")

Could not enumerate credentials for Instance.


Here is a relevant code snippet related to the "Could not enumerate credentials for Instance." error message:

797:	                :port => datastore['RPORT'],
798:	                :type => 'MSSQL_ENUM',
799:	                :data => "#{i} Instance SQL Server running as: #{p[1]}")
800:	            end
801:	          else
802:	            print_status("\tCould not enumerate credentials for Instance.")
803:	          end
804:	        end
805:	      end
806:	    end
807:	

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Carlos Perez <carlos_perez[at]darkoperator.com>

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.