Windows XP Windows 7 Windows 2003 Windows Vista Windows教程綜合 Linux 系統教程
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟件教程
 Windows教程網 >> Linux系統教程 >> 關於Linux >> Linux如何使用shell命令檢測PHP木馬

Linux如何使用shell命令檢測PHP木馬

日期:2017/1/25 10:25:17      編輯:關於Linux

  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命令檢測下。

Copyright © Windows教程網 All Rights Reserved