這篇文章主要介紹了在Linux系統的伺服器上隱藏PHP版本號碼的方法,有助於預防攻擊者針對PHP詳細版本的漏洞而發起的攻擊,需要的朋友可以參考下
通常,大多數預設設定安裝的web伺服器存在資訊泄露,這其中之一就是PHP。PHP 是如今流行的服務端html嵌入式語言(之一?)。在如今這個充滿挑戰的時代,有許多攻擊者會嘗試發現你服務端的漏洞。因此,我會簡單描述如何在Linux伺服器中隱藏PHP資訊。
預設上expose_php預設是開的。關閉“expose_php”參數可以使php隱藏它的版本資訊。
?
| 1 |
[root@centos66 ~]# vi /etc/php.ini |
在你的php.ini, 定位到含有expose_php的那行把On設成Off:
?
在此之前,web伺服器頭看上去就像這樣:
?
| 1 |
[root@centos66 ~]# curl -I http://www.ehowstuff.com/ |
?
| 1 2 3 4 5 6 7 8 9 |
HTTP/1.1 200 OK Server: nginx Content-Type: text/html; charset=UTF-8 Vary: Accept-Encoding X-Powered-By: PHP/5.3.3 X-Pingback: http://www.ehowstuff.com/xmlrpc.php Date: Wed, 11 Feb 2015 14:10:43 GMT X-Page-Speed: 1.9.32.2-4321 Cache-Control: max-age=0, no-cache |
更改並重啟 Web 服務後,php就不會在web服務頭中顯示版本了:
?
| 1 2 3 4 5 6 7 8 9 |
HTTP/1.1 200 OK Server: nginx Date: Wed, 11 Feb 2015 15:38:14 GMT Content-Type: text/html; charset=UTF-8 Vary: Accept-Encoding X-Pingback: http://www.ehowstuff.com/xmlrpc.php Date: Wed, 11 Feb 2015 14:10:43 GMT X-Page-Speed: 1.9.32.2-4321 Cache-Control: max-age=0, no-cache |