好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Linux中shell命令查找PHP木马方法 - linux教程

Linux中shell命令查找PHP木马方法

在linux中如果我们要查找木马可以使用几句命令就能快速查出来了,当然下面的代码只是根据php木马的特点来进行查找的哦,下面PHP粉丝网小伙伴就为各位同学介绍一下吧.

一句话查找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 

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

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

    修改网站的权限 ,代码如下:

  • # find -type f - name  \*.php - exec  chmod 444 {} \; 
  • --phpfensi.com  
  • # find ./ -type d -exec  chmod 555{} \; 

    常见的一句话后门,代码如下:

    grep -r --include=*.php '[^a-z]eval($_POST' . > grep.txt

    grep -r --include=*.php 'file_put_contents(.*$_POST\[.*\]);' . > grep.txt

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

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

    disable_functions = system,exec,shell_exec ………

    查看更多关于Linux中shell命令查找PHP木马方法 - linux教程的详细内容...

  •   阅读:65次