欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP 木馬攻擊防御技巧

 更新時(shí)間:2009年06月13日 00:11:56   作者:  
實(shí)際上我們還可以通過設(shè)置各個(gè)文件夾的權(quán)限,來讓apache用戶只能執(zhí)行我們想讓它能干的事情,給每一個(gè)目錄建立一個(gè)單獨(dú)能讀寫的用戶。
1、防止跳出web目錄

首先修改httpd.conf,如果你只允許你的php腳本程序在web目錄里操作,還可以修改httpd.conf文件限制php的操作路徑。比如你的web目錄是/usr/local/apache/htdocs,那么在httpd.conf里加上這么幾行:

php_admin_value open_basedir /usr/local/apache

/htdocs

這樣,如果腳本要讀取/usr/local/apache/htdocs以外的文件將不會(huì)被允許,如果錯(cuò)誤顯示打開的話會(huì)提示這樣的錯(cuò)誤:

Warning: open_basedir restriction in effect. File is in wrong directory in

/usr/local/apache/htdocs/open.php on line 4

等等。

2、防止php木馬執(zhí)行webshell

打開safe_mode,

在,php.ini中設(shè)置

disable_functions= passthru,exec,shell_exec,system

二者選一即可,也可都選

3、防止php木馬讀寫文件目錄

在php.ini中的

disable_functions= passthru,exec,shell_exec,system

后面加上php處理文件的函數(shù)

主要有

fopen,mkdir,rmdir,chmod,unlink,dir

fopen,fread,fclose,fwrite,file_exists

closedir,is_dir,readdir.opendir

fileperms.copy,unlink,delfile

即成為

disable_functions= passthru,exec,shell_exec,system,fopen,mkdir,rmdir,chmod,unlink,dir

,fopen,fread,fclose,fwrite,file_exists

,closedir,is_dir,readdir.opendir

,fileperms.copy,unlink,delfile

ok,大功告成,php木馬拿我們沒轍了,遺憾的是這樣的話,利用文本數(shù)據(jù)庫的那些東西就都不能用了。

如果是在windos平臺下搭建的apache我們還需要注意一點(diǎn),apache默認(rèn)運(yùn)行是system權(quán)限,這很恐怖,這讓人感覺很不爽.那我們就給apache降降權(quán)限吧。

net user apache fuckmicrosoft /add

net localgroup users apache /del

ok.我們建立了一個(gè)不屬于任何組的用戶apche。

我們打開計(jì)算機(jī)管理器,選服務(wù),點(diǎn)apache服務(wù)的屬性,我們選擇log on,選擇this account,我們填入上面所建立的賬戶和密碼,重啟apache服務(wù),ok,apache運(yùn)行在低權(quán)限下了。

實(shí)際上我們還可以通過設(shè)置各個(gè)文件夾的權(quán)限,來讓apache用戶只能執(zhí)行我們想讓它能干的事情,給每一個(gè)目錄建立一個(gè)單獨(dú)能讀寫的用戶。這也是當(dāng)前很多虛擬主機(jī)提供商的流行配置方法哦,不過這種方法用于防止這里就顯的有點(diǎn)大材小用了。

相關(guān)文章

最新評論