Rapid7 Vulnerability & Exploit Database

Microsoft SQL Server SUSER_SNAME SQL Logins Enumeration

Back to Search

Microsoft SQL Server SUSER_SNAME SQL Logins Enumeration



This module can be used to obtain a list of all logins from a SQL Server with any login. Selecting all of the logins from the master..syslogins table is restricted to sysadmins. However, logins with the PUBLIC role (everyone) can quickly enumerate all SQL Server logins using the SUSER_SNAME function by fuzzing the principal_id parameter. This is pretty simple, because the principal IDs assigned to logins are incremental. Once logins have been enumerated they can be verified via sp_defaultdb error analysis. This is important, because not all of the principal IDs resolve to SQL logins (some resolve to roles instead). Once logins have been enumerated, they can be used in dictionary attacks.


  • nullbind <scott.sutherland@netspi.com>



Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use auxiliary/admin/mssql/mssql_enum_sql_logins
msf auxiliary(mssql_enum_sql_logins) > show actions
msf auxiliary(mssql_enum_sql_logins) > set ACTION < action-name >
msf auxiliary(mssql_enum_sql_logins) > show options
    ...show and set options...
msf auxiliary(mssql_enum_sql_logins) > run 

Time is precious, so I don’t want to do something manually that I can automate. Leveraging the Metasploit Framework when automating any task keeps us from having to re-create the wheel as we can use the existing libraries and focus our efforts where it matters.

– Jim O’Gorman | President, Offensive Security