PHP 之防木马攻击配置技巧
1、防止跳出 web 目录
首先修改 httpd.conf,如果你只允许你的 php 脚本程序在 web 目录里操作,还可以修
改 httpd.conf 文件限制 php 的操作路径。比如你的 web 目录是/usr/local/apache/htdocs,那么
在 httpd.conf 里加上这么几行:
php_admin_value open_basedir /usr/local/apache
/htdocs
这样,如果脚本要读取/usr/local/apache/htdocs 以外的文件将不会被允许,如果错误显
示打开的话会提示这样的错误:
Warning: open_basedir restriction in effect. File is in wrong directory in
/usr/local/apache/htdocs/open.php on line 4
等等。
2、防止 php 木马执行 webshell
打开 safe_mode,在,php.ini 中设置
disable_functions= passthru,exec,shell_exec,system
二者选一即可,也可都选
3、防止 php 木马读写文件目录
在 php.ini 中的
disable_functions= passthru,exec,shell_exec,system
后面加上 php 处理文件的函数
主要有
fopen,mkdir,rmdir,chmod,unlink,dir
fopen,fread,fclose,fwrite,file_exists
closedir,is_dir,readdir.opendir
fileperms.copy,unlink,delfile
即成为
disable_functions=
passthru,exec,shell_exec,system,fopen,mkdir,rmdir,chmod,unlink,dir
,fopen,fread,fclose,fwrite,file_exists
,closedir,is_dir,readdir.opendir
,fileperms.copy,unlink,delfile
ok,大功告成,php 木马拿我们没辙了,遗憾的是这样的话,利用文本数据库的那
些东西就都不能用了。
如果是在 windos 平台下搭建的 apache 我们还需要注意一点, apache 默认运行是
system 权限,这很恐怖,这让人感觉很不爽.那我们就给 apache 降降权限吧。
net user apache fuckmicrosoft /add
net localgroup users apache /del