最近爆发出来的hash dos漏洞威力十足,杀伤力很大。随便一台服务器就可以发起ddos攻击,导致cpu长期占用100%,从而使服务器down机。下面给出php-5.2.x和php-5.3.x的修复方法。
php-5.2.x:
到这里https://github.com/laruence/laruence.github.com/tree/master/php-5.2- max-input-vars下载对应的补丁版本,进入php目录,执行patch -p1 < php-5.2.*-max-input-vars.patch打上补丁,之后make 和make install即可。
php-5.3.x:
php-5.3.x没有提供相应的补丁版本,laruence建议使用php5.3.x的升级到5.3.9RC4或者按照php5.2.x的补丁修改适应成php5.3.x的补丁。下面我们提供直接修改文件的方法,虽然比较麻烦。
1、修改/main/main.c文件,把STD_PHP_INI_ENTRY宏加到main.c的PHP_INI_BEGIN()和PHP_INI_END()宏之间来注册PHP INI指令:
- STD_PHP_INI_ENTRY(" max_input_vars", "1000", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLongGEZero, max_input_vars, php_core_globals, core_globals)
2、修改文件/main/php_globals.h,_php_core_globals结构体内加上:
- long max_input_vars;
3、修改文件/main/php_variables.c,在:
- zend_symtable_update(symtable1, escaped_index, index_len + 1, &gpc_element, sizeof(zval *), (void **) &gpc_element_p);
之前加入:
- if (zend_hash_num_elements(symtable1) >= PG(max_input_vars))
- {
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Input variables exceeded %ld. To increase the limit change max_input_vars in php.ini.", PG(max_input_vars));
- }
一共有两处,第一处数组中的键时的操作,而第二处是普通变量时的操作。
参考:http://www.snakezero.com/index.php/archives/118/
如非注明则为本站原创文章,欢迎转载。转载请注明转载自:moon's blog
那个网址哪里有可以下载的啊,给的都是代码啊~!怎么下载啊?
这里下载:https://github.com/laruence/laruence.github.com/tarball/master
服了,随便留了个言,居然回复了,还怎么快,不说个服字都不行,
无耻的再问你一个问题,因为我是菜鸟
我的系统是centos5.6 用yum安装的php,
解决方法中说的进入php目录,也有的是说cd到php src,
这个到底是怎么进入?我还真不知道php的目录在哪里啊?
望指教。 😛
yum 安装的php还真打不了,建议你采用源代码编译安装
我按照步骤怎么编译完了还是一样啊
官方目前提供的解决方案是给自己的PHP环境打一个Patch,5.2和5.3都可以使用。Patch地址如下:
https://github.com/laruence/laruence.github.com/tree/master/php-5.2-max-input-vars
https://github.com/laruence/laruence.github.com/tarball/master