三招針對(duì)PHP木馬攻擊的易行防御之道
Jun 08, 2016 pm 05:34 PM首先修改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ò)誤顯示打開(kāi)的話會(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
打開(kāi)safe_mode,在php.ini中設(shè)置
disable_functions= passthru,exec,shell_exec,system
二者選一即可,也可都選
3、防止php木馬讀寫(xiě)文件目錄
在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木馬拿我們沒(méi)轍了,遺憾的是這樣的話,利用文本數(shù)據(jù)庫(kù)的那些東西就都不能用了。
如果是在windos平臺(tái)下搭建的apache我們還需要注意一點(diǎn),apache默認(rèn)運(yùn)行是system權(quán)限,這很恐怖,這讓人感覺(jué)很不爽.那我們就給apache降降權(quán)限吧。
net user apache fuckmicrosoft /add
net localgroup users apache /del
ok.我們建立了一個(gè)不屬于任何組的用戶apche。
我們打開(kāi)計(jì)算機(jī)管理器,選服務(wù),點(diǎn)apache服務(wù)的屬性,我們選擇log on,選擇this account,我們填入上面所建立的賬戶和密碼,重啟apache服務(wù),ok,apache運(yùn)行在低權(quán)限下了。
實(shí)際上我們還可以通過(guò)設(shè)置各個(gè)文件夾的權(quán)限,來(lái)讓apache用戶只能執(zhí)行我們想讓它能干的事情,給每一個(gè)目錄建立一個(gè)單獨(dú)能讀寫(xiě)的用戶。這也是當(dāng)前很多虛擬主機(jī)提供商的流行配置方法哦,不過(guò)這種方法用于防止這里就顯的有點(diǎn)大材小用了。

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??











PHP ??? ??????? ?? ??? ??? ??? ??? ?? ??? ?? ??? ????. ??? ?? ?????. 1. ?? PHP ?? ? ???? ??? ???? ?? ? ?? phpinfo.php ??? ???? ? ? ????. 2. ??? ? ??? ???? ??????. 8.2 ?? 8.1? ???? ?? ????. Linux ???? Package Manager? ???? MacOS ???? Homebrew? ?????. 3. ?? ?? ? ???? ???????? php.ini? ?????? ??? ??? ??????. 4. ? ???? ????? ?? ??? ????? ?? ??? ???? ??? ??? ??? ??????. ?? ??? ??? ???? ???? ?????? ????? ?? ? ? ????.

TopreventCSRFattacksinPHP,implementanti-CSRFtokens.1)Generateandstoresecuretokensusingrandom_bytes()orbin2hex(random_bytes(32)),savethemin$_SESSION,andincludetheminformsashiddeninputs.2)ValidatetokensonsubmissionbystrictlycomparingthePOSTtokenwiththe

PHP ?? ??? ????? ??? ??? ???? ??? ???? ???????. ?? ???? PHP ?? ???? ? ?? ?? ??? ?????. ? ?? (Apache ?? Nginx), PHP ?? ? ?????? (? : MySQL/MariaDB); ???? XAMPP ?? MAMP? ?? ?? ???? ???? ?? ????? ????? ?? ????. XAMPP? Windows ? MacOS? ?????. ?? ? ???? ??? HTDOCS ????? ???? LocalHost? ?? ??????. mAMP? MAC ????? ???? PHP ??? ??? ??? ????? ?? ???? ??? ???? ????. ④ ?? ???? MacOS/Linux ????? Homebrew? ???? ??? ? ????.

? ?? PHP ??? ???? ?? ? ?? ????? ? ?? ?? ??? ????. 1. ??? ??? ?? ?? ??? ?? Array_Merge ? Array_unique ??? ??????. ?? Array_Merge ($ array1, $ array2)? ?? ? ?? Array_Unique ()? ???? ?? ?? ? ?? ???? ? ??? ?????. 2. ?? ?? ? ? ?? ???? ? ? ?? ????? ???? ??????. $ result = $ array1 $ array2? ? ?? ??? ?? ? ?? ??? ?? ?? ?? ??????. ? ? ?? ??? ? ??? ????? ??? ?? ?

EXIT ()? ???? ??? ?? ???? ? ???? PHP? ?????. ???? ???? ??? ?????. 1. ??? ???? ??? ??? ???? ?? ?? ??? ?? ? ? ????? ?? ?????. 2. ??? ? ?? ?? ?? ? ?? ??; 3. ?? ?? ??? ???? ?? Header ()? ?? ???? ? Exit ()? ??????. ?? exit ()? ??? ?? ??? ?? ??? ?? ??? ?? ??? ?? ? ? ??? ??? ?? ()???.

HTML?? ??? ??? ????? ???? ??? ?? ???, ??? ? SEO ??? ?? ? ? ????. 1. ??? ????? ??? ?? ??? ? ??? ??? ????? ?? ????????. 2. ????? ??? ???? ?? ?? ???? ???? ???? ?? ??? ?????. 3. ? ???? ??? ?? ??? ????? ??? ? ?? ?? ?? ?? ????? ?? ??? ????. ?? ???? ??? ??????? ?? ??? ??? ??? ???? ???? ??? ??? ?? ??? ???? ???????.

PHP? ?? ???? ?????? ?? ??? ??? ?? $ _session hyperglobal ???? ?? ???????. 1. ??? session_start ()? ???? ??????, ?? ?? ??? ???????. 2. ?? ???? ??? ? ? ?? ????? ??????. ISSET ($ _ session [ 'key']) ?? array_key_exists ( 'key', $ _ session)? ??? ? ????. 3. ?? ??? ????? ????????. ?? ???? $ _session ??? ?? ???????. 4. UNSET ($ _ session [ 'key'])? ?? ???? ??? ?? ???? ??? $ _session? ? ??? ??????.

?? ??? PHP? ?? ? ??? ?????. ?? ??? 1???. ?? ??? ???? (?? ?), 2. ??? ???? ?? ??? ???? (?? ?). ?? ? ??? ????, ?? ?? ??? ?????, ?? ?? ??, ???? ???? ?? ?? ?? ??? ??? ?????, ??? ?? ? ?? ?? ???? ?????? ???????. ?? ?? ?? ??? ??????? ?? ??? ?? ?????? ?? ?? ??? ????? ?? ??? ????????. ?? ??, ????? ?? ? ? ??? ?? ????? ???? ?? ??? ?? ? ??? ?? ??? ?????.
