自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Linux安全之PHP木馬查殺與防范

安全 網(wǎng)站安全
使用最新的操作系統(tǒng),或者最新的穩(wěn)定版(比如Ubuntu的LTS),定期打好更新,系統(tǒng)權(quán)限合理劃分,重要文件做權(quán)限安全保護。

服務器安全防范篇

1.服務器自身系統(tǒng)安全:

使用最新的操作系統(tǒng),或者最新的穩(wěn)定版(比如Ubuntu的LTS),定期打好更新,系統(tǒng)權(quán)限合理劃分,重要文件做權(quán)限安全保護。

比如:

# chattr +i /etc/passwd

# chattr +i /etc/group

# chattr +i /etc/shadow

# chattr +i /etc/gshadow

# chattr +i /etc/ssh/sshd_config

使用DenyHost程序防止SSH被暴力攻擊,具體方法見站外文章:http://www.myhack58.com/Article/48/66/2011/28833.htm

2.Web服務器和PHP的安全規(guī)則:

首先根據(jù)需求更新Web服務器和PHP,在網(wǎng)站程序目錄中嚴格定義權(quán)限,比如不會修改的地方 做好禁止寫入權(quán)限, upload目錄和cache等臨時目錄需要做好限制PHP或相關(guān)腳本運行。

nginx規(guī)則相關(guān)腳本:

location ~ .*\.(php|php5)?$ {

…….

#——————————————

rewrite ^/(uc\_client|templates|include|plugins|admin|attachments|images|

forumdata)/.*\.(php|php5)?$ /50x.php last;

#——————————————-

}

apache規(guī)則相關(guān)腳本

//注意:這里改成你需要屏蔽的目錄 比如upload目錄

php_flag engine off

Order allow,deny

Deny from all

PHP.INI需要修改的地方(很重要)

查找:disable_functions

找到后在=后面添加

exec,system,passthru,error_log,ini_alter,dl,openlog,syslog,readlink,symlink,link,leak,fsockopen,proc_open,

popepassthru,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,popen

這里都是禁止在php里面執(zhí)行的函數(shù)

服務器木馬查殺篇(PHP)

1.安裝殺毒軟件,我的服務器使用的是avast效果還算比較好。

2.根據(jù)木馬特征掃描人工排查(人工排查這個就需要個人經(jīng)驗判斷了)

PHP木馬的最明顯特征是使用了eval與base64_decode這個函數(shù)還有一些比較危險的函數(shù)。

可以輸入下面的命令 進行查詢

find /home/www/ -type f -name "*.php" | xargs grep "eval(" |more

增強版(在網(wǎng)站目錄執(zhí)行):

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

上面代碼最終會講名單輸出到 /tmp 目錄中 請直接查看列表 根據(jù)情況進行處理。

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

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

修改網(wǎng)站的權(quán)限

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

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

以上就是我最近在互聯(lián)網(wǎng)上查詢到的一些安全與查殺木馬的一些方法,也許還不是很全面,歡迎各位大大在留言中補充。

補充1:學會利用日志功能,查看黑客訪問了哪些文件逐條查詢,也許你會發(fā)現(xiàn)意想不到的東西-w-

補充2:如果覺得日志太多了,可以考慮刪除掉,然后過一會再來看。當然大型網(wǎng)站就麻煩了。

責任編輯:藍雨淚 來源: 紅黑聯(lián)盟
點贊
收藏

51CTO技術(shù)棧公眾號