国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

php.ini 啟用disable

2019-11-02 16:29:59
字體:
來源:轉載
供稿:網友
Q. I run a small Apache based webserver for my personal use and it is shared with friends and family. However, most script kiddie try to exploit php application such as wordpress using exec() , passthru() , shell_exec() , system() etc functions. How do I disable these functions to improve my php script security?

A. PHP has a lot of functions which can be used to crack your server if not used properly. You can set list of functions in php.ini using disable_functions directive. This directive allows you to disable certain functions for security reasons. It takes on a comma-delimited list of function names. disable_functions is not affected by Safe Mode. This directive must be set in php.ini For example, you cannot set this in httpd.conf.

Open php.ini file:

# vi /etc/php.ini

Find disable_functions and set new list as follows:

查找disable_functions然后用下面的替換

復制代碼 代碼如下:

disable_functions =phpinfo,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source

Save and close the file. Restart httpd:

復制代碼 代碼如下:

# service httpd restart

Note that the disable_functions directive can not be used outside of the php.ini file which means that you cannot disable functions on a per-virtualhost or per-directory basis in your httpd.conf file. If we add this to our php.ini file:

iis中設置方法,在c:/windows/php.ini

星外的設置:

復制代碼 代碼如下:

disable_functions =exec,system,passthru,popen,pclose,shell_exec,proc_open,dl,chmod,gzinflate,set_time_limit

建議增加phpinfo等,可以參考上面的設置,以后在使用過程中可能會出現php不支持部分功能的現象,然后大家可以搜索下錯誤提示,去掉相應的函數即可。

支持的越多越不安全,對于采集程序來說需要去掉curl_exec,大家多測試即可。

下面提供一個更完整的版本

復制代碼 代碼如下:

disable_functions =phpinfo,exec,system,passthru,popen,pclose,shell_exec,proc_open,dl,curl_exec,multi_exec,chmod,gzinflate,set_time_limit,

iis中設置后,運行中輸入 iisreset /restart即可。

注意下面的突破方法:建議打開安全模式

PHP是一款功能強大應用廣泛的腳本語言,很大一部分網站都是使用PHP架構的。因為其提供了強大的文件操作功能和與系統交互的功能,所以大部分的服務器都對PHP做了嚴格的限制,包括使用open_basedir限制可以操作的目錄以及使用disable_functions限制程序使用一些可以直接執行系統命令的函數如system,exec,passthru,shell_exec,proc_open等等。但是如果服務器沒有對dl()函數做限制,一樣可以利用dl()函數饒過這些限制。

dl()函數允許在php腳本里動態加載php模塊,默認是加載extension_dir目錄里的擴展,該選項是PHP_INI_SYSTEM范圍可修改的,只能在php.ini或者apache主配置文件里修改。當然,你也可以通過enable_dl選項來關閉動態加載功能,而這個選項默認為On的,事實上也很少人注意到這個。dl()函數在設計時存在安全漏洞,可以用../這種目錄遍歷的方式指定加載任何一個目錄里的so等擴展文件,extension_dir限制可以被隨意饒過。所以我們可以上傳自己的so文件,并且用dl函數加載這個so文件然后利用so文件里的函數執行其他操作,包括系統命令。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 精河县| 石首市| 安陆市| 嘉峪关市| 东乌珠穆沁旗| 长白| 安龙县| 永福县| 获嘉县| 锦州市| 景洪市| 鄂托克旗| 云南省| 渑池县| 咸宁市| 成都市| 镇雄县| 大悟县| 湾仔区| 普兰县| 安庆市| 哈巴河县| 海南省| 宝坻区| 开封县| 玉树县| 长宁区| 盖州市| 庆云县| 曲靖市| 阳江市| 周口市| 涞水县| 深州市| 铜川市| 泾阳县| 柳河县| 闻喜县| 平湖市| 于都县| 北海市|