这个是一个一个基于php的防火墙程序,拦截sql注入和xss攻击,无需服务器支持

< src="https://-blog.csdn.cn/20200922091707919.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2hldGFuZ3l1ZXNlMzIx,size_16,color_FFFFFF,t_70#pic_center" alt="在这里插入图片描述" ="box-sizing:border-box;outline:none;border-:none;margin:auto;max-width:100%;display:block;cursor:zoom-in;" />

安装

composer require xielei/waf
  • 1

使用说明

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

自定义拦截规则

$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盲注 '64_decode\(', //防止sql变种注入 '(?:from\W+information_schema\W)', //防止sql注入 '(?:(?:current_)user|data|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)\[', //禁用一些内置变量,建议自行修改 '\||||||||||, //防止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();
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

自定义拦截页面

$waf = new \Xielei\Waf\Waf(); if(!$waf->check()){ echo '非法请求'; die; }
  • 1
  • 2
  • 3
  • 4
  • 5

开源地址

https://github.com/xielei/waf

01-01 13:39