module
Microsoft SQL Server Payload Execution via SQL Injection
Disclosed | Created |
---|---|
05/30/2000 | 05/30/2018 |
Disclosed
05/30/2000
Created
05/30/2018
Description
This module will execute an arbitrary payload on a Microsoft SQL
Server, using a SQL injection vulnerability.
Once a vulnerability is identified this module
will use xp_cmdshell to upload and execute Metasploit payloads.
It is necessary to specify the exact point where the SQL injection
vulnerability happens. For example, given the following injection:
http://www.example.com/show.asp?id=1;exec xp_cmdshell 'dir';--&cat=electrical
you would need to set the following path:
set GET_PATH /showproduct.asp?id=1;[SQLi];--&cat=foobar
In regard to the payload, unless there is a closed port in the web server,
you dont want to use any "bind" payload, specially on port 80, as you will
stop reaching the vulnerable web server host. You want a "reverse" payload, probably to
your port 80 or to any other outbound port allowed on the firewall.
For privileged ports execute Metasploit msfconsole as root.
Currently, three delivery methods are supported.
First, the original method uses Windows 'debug.com'. File size restrictions are
avoided by incorporating the debug bypass method presented by SecureStat at
Defcon 17. Since this method invokes ntvdm, it is not available on x64 systems.
A second method takes advantage of the Command Stager subsystem. This allows using
various techniques, such as using a TFTP server, to send the executable. By default
the Command Stager uses 'wcsript.exe' to generate the executable on the target.
Finally, ReL1K's latest method utilizes PowerShell to transmit and recreate the
payload on the target.
NOTE: This module will leave a payload executable on the target system when the
attack is finished.
Server, using a SQL injection vulnerability.
Once a vulnerability is identified this module
will use xp_cmdshell to upload and execute Metasploit payloads.
It is necessary to specify the exact point where the SQL injection
vulnerability happens. For example, given the following injection:
http://www.example.com/show.asp?id=1;exec xp_cmdshell 'dir';--&cat=electrical
you would need to set the following path:
set GET_PATH /showproduct.asp?id=1;[SQLi];--&cat=foobar
In regard to the payload, unless there is a closed port in the web server,
you dont want to use any "bind" payload, specially on port 80, as you will
stop reaching the vulnerable web server host. You want a "reverse" payload, probably to
your port 80 or to any other outbound port allowed on the firewall.
For privileged ports execute Metasploit msfconsole as root.
Currently, three delivery methods are supported.
First, the original method uses Windows 'debug.com'. File size restrictions are
avoided by incorporating the debug bypass method presented by SecureStat at
Defcon 17. Since this method invokes ntvdm, it is not available on x64 systems.
A second method takes advantage of the Command Stager subsystem. This allows using
various techniques, such as using a TFTP server, to send the executable. By default
the Command Stager uses 'wcsript.exe' to generate the executable on the target.
Finally, ReL1K's latest method utilizes PowerShell to transmit and recreate the
payload on the target.
NOTE: This module will leave a payload executable on the target system when the
attack is finished.
Authors
David Kennedy "ReL1K" jduck Rodrigo Marcos
Platform
Windows
Architectures
x86, x64
References
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 exploit/windows/mssql/mssql_payload_sqli msf /(i) > show actions ...actions... msf /(i) > set ACTION < action-name > msf /(i) > show options ...show and set options... msf /(i) > run

NEW
Explore Exposure Command
Confidently identify and prioritize exposures from endpoint to cloud with full attack surface visibility and threat-aware risk context.