服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Linux - Linux如何使用shell命令检测PHP木马防止脚本木马的破坏

Linux如何使用shell命令检测PHP木马防止脚本木马的破坏

2019-09-25 15:00服务器之家 Linux

在Linux系统中,可使用shell命令检测PHP木马,为了防止脚本木马的破坏,保证网站的安全,学会使用shell命令查找PHP木马是非常重要的,下面有个方法,大家可以看看

PHP木马主要用于攻击网站,会在网站中插入代码,在Linux系统中,可使用shell命令检测PHP木马,为了防止脚本木马的破坏,保证网站的安全,学会使用shell命令查找PHP木马是非常重要的,下面小编就给大家介绍下方法。

Linux如何使用shell命令检测PHP木马防止脚本木马的破坏

  1、一句话查找PHP木马

  代码如下

  # find 。/ -name “*.php” |xargs egrep “phpspy|c99sh|milw0rm|eval\(gunerpress|eval\(base64_decoolcode|spider_bc”》 /tmp/php.txt

  # grep -r --include=*.php ‘[^a-z]eval($_POST’ 。 》 /tmp/eval.txt

  # grep -r --include=*.php ‘file_put_contents(.*$_POST\[.*\]);’ 。 》 /tmp/file_put_contents.txt

  # find 。/ -name “*.php” -type f -print0 | xargs -0 egrep “(phpspy|c99sh|milw0rm|eval\(gzuncompress\(base64_decoolcode|eval\(base64_decoolcode|spider_bc|gzinflate)” | awk -F: ‘{print $1}’ | sort | uniq

        2、查找最近一天被修改的PHP文件

  一般站点里的页面文件都很少更改,当然动态临时生成的除外。而那些一般不会变的页面目录里的文件如果被修改了,可大可能是被人做了手脚。

  代码如下

  # find -mtime -1 -type f -name \*.php

  3、修改网站的权限

  代码如下

  # find -type f -name \*.php -exec chmod 444 {} \;

  # find 。/ -type d -exec chmod 555{} \;

  4、常见的一句话后门:

  代码如下

  grep -r --include=*.php ‘[^a-z]eval($_POST’ 。 》 grep.txt

  grep -r --include=*.php ‘file_put_contents(.*$_POST\[.*\]);’ 。 》 grep.txt

  把搜索结果写入文件,下载下来慢慢分析,其他特征木马、后门类似。有必要的话可对全站所有文件来一次特征查找,上传图片肯定有也捆绑的,来次大清洗

  5、禁用不常用函数

  将用不到的权限又比较大的php函数在php.ini文件里禁掉。修改方法如下:

  disable_functions = system,exec,shell_exec

  上面就是Linux使用shell命令检测PHP木马的方法介绍了,在不确定自己的网站是否被攻击的情况下,最好使用shell命令检测下。

延伸 · 阅读

精彩推荐