Warning: Illegal string offset 'top' in /www/wwwroot/hellyhua.com/wp-content/themes/Snape/single.php on line 45

一、目录权限设置很重要:可以有效防范黑客上传木马文件.
如果通过 chmod 644 * -R 的话,php文件就没有权限访问了。
如果通过chmod 755 * -R 的话,php文件的权限就高了。

所以就需要分开设置目录权限和文件权限:

  • linux 服务器权限:经常要用到的命令:



find /path -type f -exec chmod 644 {} \;  //设置文件权限为644
find /path -type d -exec chmod 755 {} \;  //设置目录权限为755

设置完成后,再通过命令:chown root:root * -R 将目录和文件的所有者改为root。

这样就更加安全了。

  • FTP用户,确定使用的是linux主机。windows需要登录到服务器中设置。

进入到phpcms 安装根目录,选取所有文件:
设置数字值为:755,同时选定:选择递归处理子目录,只应用到目录
同样再选择所有文件,数字值为:644,选择递归处理子目录,只应用到文件
如果设置错了,重新再设置就可以了。


二、Linux find命令 查找可疑的木马文件

查找:30天内被修改的文件

find  ./  -mtime  -30  -type f  -exec ls -l  {} \;

找到目录下所有的txt文件

find ./ -name "*.txt" -print

找到目录下所有的txt文件并删除

find ./ -name "*.txt" -exec rm -rf {} \;

找到目录下所有的php文件 并且在30天之类被修改的文件

find  ./ -name "*.php" -mtime  -30  -typef  -exec  ls -l  {} \;

找到目录下所有的php文件,同时,满足 30天以内,1天之前的

find ./ -name "*.php" -mtime -30 -mtime +1 -type f -execls -l {} \;


三、通过apache配置限定:

1、apache 下 禁止目录执行php 

通过目录下面放置 .htaccess文件来限制权限。

该方法会将php文件当做附件并下载。同时,可以通过浏览器访问到文件。

php_flag engine off

 

使用场景:在下面目录放置

\uploadfile\

\statics\

\html\

\phpsso_server\uploadfile\

\phpsso_server\statics\
 

2、禁止通过浏览器访问所有文件


通过目录下面放置 .htaccess文件来限制权限。

RewriteEngine on

RewriteRule ^(.*) /index.html

 

使用场景:

\caches\

\phpsso_server\caches\

 

3、禁止php跨目录浏览权限配置:



虚拟主机配置样例:
<VirtualHost *:80>
    ServerAdmin root@phpip.com
    DocumentRoot /data/wwwroot/www
    ServerName www.phpip.com
    <Directory  /data/wwwroot/www>
        Options  FollowSymLinks
        AllowOverride Options FileInfo
        Order allow,deny
        Allow from all
        php_admin_value open_basedir /data/wwwroot/www/:/var/tmp/
        DirectoryIndex index.htm index.html index.php 
    </Directory>
    ErrorLog "| /usr/sbin/rotatelogs /data/logs/%m_%d_www.phpip.com-error_log 86400 480"
    CustomLog "| /usr/sbin/rotatelogs /data/logs/%m_%d_www.phpip.com-access_log 86400 480" common
</VirtualHost>


4、按天存放apache日志:

参考上面配置文件:
    ErrorLog "| /usr/sbin/rotatelogs /data/logs/%m_%d_www.phpip.com-error_log 86400 480"
    CustomLog "| /usr/sbin/rotatelogs /data/logs/%m_%d_www.phpip.com-access_log 86400 480" common



Warning: Illegal string offset 'footer' in /www/wwwroot/hellyhua.com/wp-content/themes/Snape/single.php on line 49