最新消息:

PHP5.2.*防止Hash冲突拒绝服务攻击的Patch

PHP应用 admin 4717浏览 0评论

由我前面的俩篇文章介绍(通过构造Hash冲突实现各种语言的拒绝服务攻击, PHP数组的Hash冲突实例 ), 这个攻击方法危害很高, 攻击成本也很小. 一个台式机可以轻松搞垮数十台, 上百台服务器.

而和Pierre沟通后, 官方开发组不会为此发布PHP 5.2.18, 但是目前还是由不少公司还在使用5.2, 所以我特将dmitry为5.4写的patch, 分别apply到5.2上.

大家如果有用5.2的, 如果被此类攻击威胁, 可以打上下面的patch, PHP5.3的, 可以考虑升级到5.3.9, 已经包含了此patch(因为5.3.9目前是RC状态, 所以如果不愿意升级, 也可以参照这个patch自己为5.3写一个):

https://github.com/laruence/laruence.github.com/tree/master/php-5.2-max-input-vars

另外, 其他语言java, ruby等, 请各位也预先想好对策, 限制post_size是治标不治本的方法, 不过可以用来做临时解决方案.

thanks


Comments

  • 2011/12/30, cha369 writes: 鸟哥效率啊,造福大众
  • 2011/12/30, 板子 writes: 鸟哥,这两篇文章一发,大家都不得不升级了
    攻击门槛被降低到约等于0了
  • 2011/12/30, 雪候鸟 writes: @板子 不能怨我啊, 这个方法是国外曝出来的…..
  • 2011/12/30, -_- writes: 弱弱的问一下 如何给线上运行的PHP打path
  • 2011/12/31, 蘑菇 writes: 呃,php 5.3.9 在哪?
  • 2011/12/31, coralzd writes: cd Php-5.2.17 ;
    执行patch -p1 php-5.2.17-max-input-vars.patch
    一直在那里卡住!
  • 2011/12/31, Anders writes: 貌似必须restart 才行啊, reload都不行呢。
  • 2011/12/31, 饼饼 writes: patch -p1 < laruence-laruence.github.com-43969a1/php-5.2-max-input-vars/php-5.2.17-max-input-vars.patch
    can't find file to patch at input line 4
    Perhaps you used the wrong -p or –strip option?
    The text leading up to this was:
    ————————–
    |diff -u -r php-5.2.17/configure php-5.2.17-patched/configure
    |— php-5.2.17/configure 2011-01-07 07:04:43.000000000 +0800
    |+++ php-5.2.17-patched/configure 2011-12-31 11:46:11.000000000 +0800
    ————————–
    File to patch:

    不行挖。。

  • 2011/12/31, boyaa writes: it is can not make effect even though I patched the php-5.2.10 successfully !
  • 2011/12/31, Justin writes: sed -i “s/PHP_EXTRA_VERSION=””/PHP_EXTRA_VERSION=”p1″/” ./configure
    sed -i “s/PHP_EXTRA_VERSION=””/PHP_EXTRA_VERSION=”p1″/” ./configure.in
    sed -i “s/define PHP_EXTRA_VERSION “”/define PHP_EXTRA_VERSION “p1″/” ./main/php_version.h
    sed -i “s/long max_input_nesting_level;/&ntlong max_input_vars;/” ./main/php_globals.h

    sed -ie “/Z_TYPE_PP(gpc_element_p) != IS_ARRAY) {/a\tttttif (zend_hash_num_elements(symtable1) >= PG(max_input_vars)) {nttttttphp_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));nttttt}” ./main/php_variables.c

    sed -ie “/zval_ptr_dtor(&gpc_element);/{n; s/} else {/&nttttif (zend_hash_num_elements(symtable1) >= PG(max_input_vars)) {ntttttphp_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));ntttt}/;}” ./main/php_variables.c

    sed -ie “/PHP_INI_BEGIN()/{n; s/$/&ntSTD_PHP_INI_ENTRY(“max_input_vars”, “1000”, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateLongGEZero, max_input_vars, php_core_globals, core_globals)/;}” ./main/main.c


Related posts:


Copyright © 2010 风雪之隅 版权所有, 转载务必注明. 该Feed只供个人使用, 禁止未注明的转载或商业应用. 非法应用的, 一切法律后果自负. 如有问题, 可发E-mail至my at laruence.com.(Digital Fingerprint: 73540ba0a1738d7d07d4b6038d5615e2)

Related Posts:

转载请注明:爱开源 » PHP5.2.*防止Hash冲突拒绝服务攻击的Patch

您必须 登录 才能发表评论!