PHP Firewall是一款由Cyril Levert编写的开源软件,可以作为通用的PHP网站防护之用; 也可以通过对部分源代码进行了修改,增加SaeStorage存储支持、中文语言支持,为新浪云SAE(Sinaapp)应用提供PHP防火墙功能, 有能力有时间的朋友不放做个试试。
一、下载PHP_Firewall文件
点击下载http://www.php-firewall.info/PHP_Firewall_103.tar.gz文件,解压后将”php-firewall”文件夹及”Read me.txt”文件放在您的代码文件夹根目录下。
二、配置SAE应用
在sina app engine应用中,点击左侧的storage,新建一个domain,名称为”upload”(其它名称也可以,但是需要注意修改”firewall.php”脚本中的名称),用以存放php firewall运行的日志文件。
三、部署PHP Firewall脚本
打开您的首页或者需要防护php页面(最好在所有页面都有引用的php文件,如common.php中),在文件头部添加对“php-firewall”文件夹下“firewall.php”的引用,php代码如下:
———————————————–
define('PHP_FIREWALL_REQUEST_URI', strip_tags( $_SERVER['REQUEST_URI']
) );
define('PHP_FIREWALL_ACTIVATION', true );
if ( is_file( @dirname(__FILE__).'/php-firewall/firewall.php' ) )
include_once( @dirname(__FILE__).'/php-firewall/firewall.php' );
———————————————–
保存文件后,svn commit至sae服务器。这样就可以起到基本的防护作用了。
四、关于PHP Firewall
目前版本为1.0.3,支持以下防护:
* XSS protection
* UNION SQL Injection protection
* Bads bots protection
* Bads requests methods protection
* Small DOS protection
* Inclusion files protection
* Santy and others worms protection
* Server Protection
* URL Query protection
* Cookies sanitize
* Post vars sanitize
* Get vars sanitize
* IPs range reserved denied
* IPs range spam denied
* IPs protected
* Unset globals PHP var
Kenel code write by Cyril Levert, Copyright (c) 2009-2010
Patch by TangGuofang, 2012, 10, 25
zp8497586rq