install~
1.安裝apache
由於安裝很簡單,pass~!,只是要注意的是,請勿安裝到系統磁碟分割上
因為這樣,無論從備份,維護,災難性恢複上,都是有優勢的.
假設安裝到了d:\\
2.安裝php
具體安裝過程請參考php目錄裡的install.txt
需要注意的是,請勿使用cgi方式
以下為引用資料
------------------------------------------------------------------
Title 17/2/2002
PHP for Windows Arbitrary Files Execution (GIF, MP3)
Summary
Through PHP.EXE, an attacker can cause PHP to interpret any file as a PHP file,
even if its extensions are not PHP. This would enable the remote attacker to
execute arbitrary commands, leading to a system compromise.
Details
Vulnerable systems:
PHP version 4.1.1 under Windows
PHP version 4.0.4 under Windows
An attacker can upload innocent looking files (with mp3, txt or gif extensions)
through any uploading systems such as WebExplorer (or any other PHP program that
has uploading capabilities), and then request PHP to execute it.
Example:
After uploading a file a \"gif\" extension (in our example huh.gif) that contains
PHP code such as:
#------------
<?
phpinfo();
?>
#------------
An attacker can type the following address to get in to cause the PHP file to be
executed:
http://www.example.com/php/php.exe/UPLOAD_DIRECTORY/huh.gif
Notice: php/php.exe is included in the URL.
Additional information
The information has been provided by CompuMe and RootExtractor.
ps:大部分版本都有這個毛病.包括一些最新版本,所以請不要以cgi安裝!切記...
3.安裝mysql
安裝到d:\\,也很簡單,具體過程pass.
只是mysql安裝後的預設設定實在讓人擔心
以下引用我原來的文章
-----------------------------------------------------------------------------------
2002/12/21
寫在前面:無事可做,生命被消耗,痛~~~啊,所以就寫了,本文no原創,整理而成!
預設安裝的mysql服務不安全因素涉及的內容有:
一.mysql預設的授權表
二.缺乏日誌能力
三.my.ini檔案泄露口令
四.服務預設被綁定全部的網路介面上
五.預設安裝路徑下的mysql目錄許可權
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
一.mysql預設的授權表
由於mysql對身分識別驗證是基於mysql這個資料庫的,也叫授權表。所有的使用權限設定都在這裡了。
我們只討論最為重要的一個表 user表。它控制的是接受或拒絕串連。
先看一下
select host,user,password,Delete_priv from user;
+-----------+------+------------------+-------------+
| host | user | password | Delete_priv |
+-----------+------+------------------+-------------+
| localhost | root | 67457e226a1a15bd | Y |
| % | root | | Y |
| localhost | | | Y |
| % | | | N |
+-----------+------+------------------+-------------+
現在新的版本,安裝完畢都會出現一個快速設定視窗,用於設定口令。
以上,就是user表裡的內容(略了點)看看有什麼問題?
我們知道mysql的驗證方式是比較特殊的,它基於兩個2個資訊來進行的
1.從那裡串連
2.使用者名稱
第一條沒什麼問題,當然口令必須是安全的。
第二條從任何主機,以使用者root,不需要口令都可以串連,許可權為所有的許可權。(注:這裡的許可權是全域許可權)
第三條從本地主機,任何使用者名稱(註:user為空白,不表示不需要使用者名稱),不需要口令,都可以串連,所有的許可權
第四條從任何主機,任何使用者名稱,不需要口令,都可以串連,無任何許可權。
可以看出,2\\3\\4都是不安全的,如何攻擊這裡就不說了,請參看資料文庫。
如果你mysql只允許本地串連,刪除host的%和user中的nul(表示空)
delete from user where host=‘%‘;
delete from host where user=‘‘;
最後的user表,看起來因該是這個樣子
+-----------+------+------------------+-------------+
| host | user | password | Delete_priv |
+-----------+------+------------------+-------------+
| localhost | root | 67457e226a1a15bd | Y |
+-----------+------+------------------+-------------+
最後需要重新整理授權表,使其立刻生效
flush privileges;
如果你的mysql需要被遠程使用,需要為%段中的root帳號,加上一個安全的密碼
update user set password=password(‘youpass‘) where host=‘%‘;
其中youpass,就是口令
mysql> select host,user,password,Delete_priv from user;
+-----------+------+------------------+-------------+
| host | user | password | Delete_priv |
+-----------+------+------------------+-------------+
| localhost | root | 67457e226a1a15bd | Y |
| % | root | 77c590fa148bc9fb | Y |
+-----------+------+------------------+-------------+
更好的做法是,對遠程主機的串連,指定為特定的
修改host中的%為允許串連的主機,比如:
192.168.0.% 允許一個特定的子網
www.sandflee.net 允許一個特定的主機
帳號預設的名字也是擔心的問題。有可能導致被暴力破解
update user set user=‘localadmin‘ where host=‘localhost‘;
update user set user=‘remoteadmin‘ where host=‘%‘;
最後的user表看起來像是這個樣子
mysql> select host,user,password,Delete_priv from user;
+-----------+-------------+------------------+-------------+
| host | user | password | Delete_priv |
+-----------+-------------+------------------+-------------+
| localhost | localadmin | 67457e226a1a15bd | Y |
| % | remoteadmin | 77c590fa148bc9fb | Y |
+-----------+-------------+------------------+-------------+
更為詳細的資料,請去參考晏子的《MySQL中文參考手冊》。隨便那都有下
二.缺乏日誌能力
mysql安裝完成以後,會在%SystemRoot%目錄下產生my.ini的設定檔案
預設的內容如下:
——————————————————————————————
basedir=C:/mysql
#bind-address=192.168.0.1
datadir=C:/mysql/data
#language=C:/mysql/share/your language directory
#slow query log#=
#tmpdir#=
#port=3306
#set-variable=key_buffer=16M
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=root
password=root
———————————————————————————————
注意log#=這個
它沒有被定義,且被登出掉了。
更改為一個適合的路徑,比如:
log=c:/mysql/logs/mysql.log
三.my.ini檔案泄露口令
我們看到my.ini最後,有這兩句
user=root
password=root
如果,你安裝完成時,使用了mysql所提供的快速設定功能,(較新的版本)你的帳號和口令將被寫到my.ini檔案中。
這也是mysql寫到啟動組裡的winmysqladmin.exe工具,運行時需要讀取的。它提供的mysql服務
的一些監視功能。這樣winmysqladmin.exe才能獲得mysql服務的狀態資訊。
其實,這個也不算漏洞,我們看看my.ini預設的許可權,它可以被user組使用者讀取。
從而導致口令被泄露
解決方案:
從新設定my.ini檔案的許可權.
從新設定帳號及口令
不使用快速設定
四.服務預設被綁定全部的網路介面上
服務被綁定到了所有的網路介面上,比如,你只需要一個運行在內網的mysql服務,但是你的機器有
外網的介面,mysql也會被綁定上,從而帶來一些不必要的麻煩和威脅。
在my.ini裡的這句
#bind-address=192.168.0.1
它預設被登出掉了
應該開啟它
如果,只是本地使用,更改為
bind-address=127.0.0.1
如果是其它情況,應該選者一個合適的網路介面
五.預設安裝路徑下的mysql目錄許可權
mysql預設的安裝路徑為c:\\mysql,基本上都難得改,要改的話也是麻煩,還要去改my.ini。
但,這樣就有個問題
通常c:\\的許可權是everyone組-所有的許可權。這是預設的,由於繼承性,導致mysql下的data目錄
也是everyone組-所有的許可權。導致被隨意訪問、讀取、刪除,可能泄露和破壞資料。
更改mysql目錄到一個合適,安全的存取權限。
over...
-----------------------------------------------------------------------------------------
這裡面有個小小的語法錯誤,請自己找出來:)
engine = On --開啟php支援,如果不讓php工作可以engine = Off
safe_mode = Off --安全模式,應該開啟它safe_mode = On
safe_mode_exec_dir = --設定安全模式下可以執行程式的目錄
disable_functions = 要關閉的函數,用\",\"分隔建議關閉phpinfo,get_cfg_var
expose_php = On 建議expose_php = Off,這樣在header裡就不會有php的版本號碼
display_errors =On 建議 display_errors =Off,這樣所有錯誤資訊,都將關閉
register_globals = Off 自動全域變數,一般都要開啟register_globals = On,但會引發很多
安全問題,特別是一些寫編寫的不是很好的php指令碼,有可能危及到你的web server
file_uploads = On 是否允許上傳檔案,如果你不需要就off
allow_url_fopen = Off 是否遠程開啟功能,建議關閉
htpasswd -n[mdps] username
htpasswd -nb[mdps] username password
-c Create a new file. //建立一個新的密碼檔案(你第一次使用,因該使用這個參數)
-n Don\'t update file; display results on stdout. //顯示到螢幕
-m Force MD5 encryption of the password (default). //加密口令(md5方式)預設的
-d Force CRYPT encryption of the password. //使用CRYPT方式加密口令
-p Do not encrypt the password (plaintext). //不加密口令
-s Force SHA encryption of the password. //使用sha演算法加密
-b Use the password from the command line rather than prompting for it. //互交方式
On Windows, TPF and NetWare systems the \'-m\' flag is used by default.
On all other systems, the \'-p\' flag will probably not work.
——————————————————————————————————————
列子:
d:\\Apache\\bin>htpasswd.exe -c d:\\apache\\user taotao
Automatically using MD5 format on Windows.
New password: ***
Re-type new password: ***
Adding password for user taotao
就建立完成了
其中,要注意的
passwordfile,不應該放到web目錄,因為會被人下載,很蠢,雖然密碼已經被md5過
-c 參數是用於建立一個新的密碼檔案。
d:\\apache\\user路徑,要和你在
AuthUserFile d:/Apache/user 設定的一致。
然後從新啟動你的apache服務