1 Star 1 Fork 1

zhq1 / waf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PHP防火墙

一个基于php的防火墙程序,拦截sql注入和xss攻击等

安装

composer require xielei/waf

使用说明

$waf = new \Xielei\Waf\Waf();
$waf->run();

自定义拦截规则

$rules = [
    '\.\./', //禁用包含 ../ 的参数
    '\<\?', //禁止php脚本出现
    '\s*or\s+.*=.*', //匹配' or 1=1 ,防止sql注入
    'select([\s\S]*?)(from|limit)', //防止sql注入
    '(?:(union([\s\S]*?)select))', //防止sql注入
    'having|updatexml|extractvalue', //防止sql注入
    'sleep\((\s*)(\d*)(\s*)\)', //防止sql盲注
    'benchmark\((.*)\,(.*)\)', //防止sql盲注
    'base64_decode\(', //防止sql变种注入
    '(?:from\W+information_schema\W)', //防止sql注入
    '(?:(?:current_)user|database|schema|connection_id)\s*\(', //防止sql注入
    '(?:etc\/\W*passwd)', //防止窥探linux用户信息
    'into(\s+)+(?:dump|out)file\s*', //禁用mysql导出函数
    'group\s+by.+\(', //防止sql注入
    '(?:define|eval|file_get_contents|include|require|require_once|shell_exec|phpinfo|system|passthru|preg_\w+|execute|echo|print|print_r|var_dump|(fp)open|alert|showmodaldialog)\(', //禁用webshell相关某些函数
    '(gopher|doc|php|glob|file|phar|zlib|ftp|ldap|dict|ogg|data)\:\/', //防止一些协议攻击
    '\$_(GET|post|cookie|files|session|env|phplib|GLOBALS|SERVER)\[', //禁用一些内置变量,建议自行修改
    '\<(iframe|script|body|img|layer|div|meta|style|base|object|input)', //防止xss标签植入
    '(onmouseover|onerror|onload|onclick)\=', //防止xss事件植入
    '\|\|.*(?:ls|pwd|whoami|ll|ifconfog|ipconfig|&&|chmod|cd|mkdir|rmdir|cp|mv)', //防止执行shell
    '\s*and\s+.*=.*' //匹配 and 1=1
];

$waf = new \Xielei\Waf($rules);
$waf->run();

自定义拦截页面

$waf = new \Xielei\Waf\Waf();
if(!$waf->check()){
    echo '非法请求';
    die;
}
MIT License Copyright (c) 2020 xielei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

php waf 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/zhq1_admin/waf.git
git@gitee.com:zhq1_admin/waf.git
zhq1_admin
waf
waf
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891