rapid7/metasploit-framework — pull request #920 by nullbind (2012-10-16 19:40:37+00:00)
Title: Microsoft SQL LM/NTLM Stealer - SQLI

This module can be used to help capture or relay the LM and NTLM credentials of the account running remote SQL Server services. The module will use the SQL injection from GET_PATH to connect to the SQL Server instance and execute the native "xp_dirtree" stored procedure. The stored procedures will then force the service account to authenticate to the system defined in the SMBProxy option. In order for the attack to be successful, the SMB capture or relay module must be running on the system defined as the SMBProxy. The database account used to connect to the database should only require the "PUBLIC" role to execute. Successful execution of this attack usually results in local administrative access to the Windows system. Specifically, this works great for relaying credentials between two SQL Servers using a shared service account to get shells. However, if the relay fails, then the LM hash can be reversed using the Halflm rainbow tables and john the ripper. Thanks to "Sh2kerr" who wrote the ora_ntlm_stealer for the inspiration.

------------------------------------
Lab Process Example:
-------------------------------------
#1 Setup SMB capture or relay listener:

use auxiliary/server/capture/smb
run

#2 Run new module to obtain LM/NTLM hashes or shell via basic SQL injection:

use auxiliary/admin/mssql/mssql_ntlm_stealer_sqli
set RPORT 80
set RHOST 192.168.1.100
set GET_PATH /employee.asp?id=1;[SQLi];--
set SMBPROXY
run