11月20日任務
11.28 限定某個目錄禁止解析php
11.29 限制user_agent
11.30/11.31 php相關配置php
1.限定某個目錄禁止解析phpshell
![](http://static.javashuo.com/static/loading.gif)
- 核心配置文件內容
- <Directory /data/wwwroot/www.123.com/upload> php_admin_flag engine off
- </Directory>
- curl測試時直接返回了php源代碼,並未解析
示例一:瀏覽器
![](http://static.javashuo.com/static/loading.gif)
- mkdir /data/wwwroot/www.123.com/upload 建立一個圖片上傳目錄/upload/
- 從新加載一下
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
2.限制user_agent安全
![](http://static.javashuo.com/static/loading.gif)
- user_agent能夠理解爲瀏覽器標識
- 核心配置文件內容
- <IfModule mod_rewrite.c>
- RewriteEngine on
- RewriteCond %{HTTP_USER_AGENT} .*curl.* [NC,OR]
- RewriteCond %{HTTP_USER_AGENT} .*baidu.com.* [NC]
- RewriteRule .* - [F]
- </IfModule>
- curl -A "123123" 指定user_agent
示例一:curl
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- curl -A "123123" 指定user_agent
![](http://static.javashuo.com/static/loading.gif)
3.PHP相關配置socket
![](http://static.javashuo.com/static/loading.gif)
- 查看php配置文件位置
- /usr/local/php/bin/php -i|grep -i "loaded configuration file"
- date.timezone 定義它的時區
- disable_functions 安全函數:eval,assert,popen,passthru,escapeshellarg,escapeshellcmd,passthru,exec,system,chroot,scandir,chgrp,chown,escapeshellcmd,escapeshellarg,shell_exec,proc_get_status,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,leak,popepassthru,stream_socket_server,popen,proc_open,proc_close,phpinfo
- error_log,log_errors,display_errors,error_reporting 日誌相關
- open_basedir 安全相關
- php_admin_value open_basedir "/data/wwwroot/111.com:/tmp/"
示例一:函數
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- 再加上phpinfo
- 從新加載一下配置文件
- 測試,再次訪問就打不開了
![](http://static.javashuo.com/static/loading.gif)
示例二:測試
![](http://static.javashuo.com/static/loading.gif)
示例三:日誌相關網站
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
- 查看定義所在目錄屬組和寫權限是不是Apache(httpd)的
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
示例四:安全相關,限定分別隔離網站url
- 定義php.ini 這是針對全部網站的
- 編輯該文件
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
示例五:
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)