Rapid7 Vulnerability & Exploit Database

Microsoft SQL Server xp_cmdshell Command Execution

Back to Search

Microsoft SQL Server xp_cmdshell Command Execution



This module will execute a Windows command on a MSSQL/MSDE instance via the xp_cmdshell procedure. A valid username and password is required to use this module


  • tebo <tebo@attackresearch.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_exec
msf auxiliary(mssql_exec) > show actions
msf auxiliary(mssql_exec) > set ACTION < action-name >
msf auxiliary(mssql_exec) > show options
    ...show and set options...
msf auxiliary(mssql_exec) > 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