網頁

顯示具有 WAMP 標籤的文章。 顯示所有文章
顯示具有 WAMP 標籤的文章。 顯示所有文章

2013年8月15日 星期四

WampServer Security Scanner

如何修復網站與作業系統常見之漏洞與弱點


AppScan偵測之漏洞: XSS Scripting 跨網站 Scripting

原程式加上php 提供之 function: htmlentities(),修改後之login_submit.php 內容: echo "您輸入的帳號: " . htmlentities($_POST['login']) . " 錯誤!";..


解決方法:
  

$password =  htmlentities($_POST['password']);  //Preventing XSS Scripting  Attacks

AppScan偵測之漏洞: SQL Injection SQL 注入

解決方法:
/etc/php.ini 有個參數: ; Magic quotes for incoming GET/POST/Cookie data. magic_quotes_gpc = On wamp/bin/php/php5.4.12/php.ini
; scheduled for removal in PHP 6.
; Default Value: On
; Development Value: Off
; Production Value: Off
; http://php.net/magic-quotes-gpc
magic_quotes_gpc = On ;LINE 750


當啟用 magic_quotes_gpc 參數後,對於GET/POST 中使用者輸入之特殊字元,如單引號(')雙引號( " )、反斜線( \ ), 前面會自動再加上反斜線( \ ),此時即視同為字元。當 magic_quotes_gpc 功能開啟後,SQL 執行之語法已改變為: SELECT * FROM admin where login='davis' and passwd='\' or \'a\'=\'a'

防止SQL注入攻擊 (mysql_real_escape_string) (轉)


AppScan偵測之漏洞:目錄清單瀏覽
需修改/etc/httpd/conf/httpd.conf 將 Options 中 Indexes 字串移除:
 

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
 

2013年6月27日 星期四

wampserver

在 Windows 7 安裝 WampServer


window server 2012 要安裝
Microsoft Visual C++ 2010 SP1 可轉散發套件 (x64)

wamp server install



Error MSVCR100.DLL Solution
Posted by: stevenmartin99 (Moderator)
Date: June 03, 2012 11:42AM

For Windows 32 : Be sure that you have installed the Visual C++ 2010 SP1 Redistributable Package x86
: VC10 SP1 vcredist_x86.exe >>http://www.microsoft.com/download/en/details.aspx?id=8328


For Windows 64 : Be sure that you have installed the Visual C++ 2010 SP1 Redistributable Package x64
: VC10 SP1 vcredist_x64.exe >>http://www.microsoft.com/zh-tw/download/details.aspx?id=13523


Window Server 2012






新增完成之後重新開機(不是重開Apache,要重開機)


wamp httpd conf

C:\wamp\bin\apache\apache2.4.2\conf\httpd conf


WAMP的mysql密碼設定






C:\wamp\apps\phpmyadmin4.0.4\config.inc.php 
第一次登入phpmyadmin root/ 無賬密
  
/*
 * First server
 */
$i++;
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = true; 


修改密碼



另:.html 內不能跑php 需 .php 或得另行處理


Server上PHP特別注意數值初始化的錯誤問題

PHP Notice: undefined index 完美解决方法

   $val = !empty($_GET[$str]) ? $_GET[$str] : null;

@SSL (https) on WAMP

如果提示错误信息如下:
Syntax error on line 76 of /etc/httpd/extra/httpd-ssl.conf:
SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).
就将/etc/httpd/extra/httpd-ssl.conf文件中的SSLSessionCache模块注释掉即可,如下所示:  
#SSLSessionCache        "shmcb:/usr/local/apache/logs/ssl_scache(512000)"
@How to find to the command prompt in Windows Server 2012 @WAMPSERVER無法正常​​啟動的解決方法(黃色圖標)【精華篇】
直接运行httpd.exe能有错误提示,从安装目录找到了E:\wampServer\bin\apache\Apache2.2.21\bin httpd.exe文件
双击,一个黑框一闪而过,啥也没看到,后来经验告诉我,应该从CMD(命令提示符启动)打开命令提示符 开始->运行->cmd
然后把httpd.exe文件拖动到cmd.exe的黑框里面

2013年4月2日 星期二

wampserver php.ini

php.ini的變數設定詳解

錯誤記錄( error log)


php 內建就有記錄程式錯誤的功能,方便工程師 debug。
  • error_reporting = E_ALL : 指定哪些錯誤類型須要php記錄
    • E_ALL : 是指全部的 error 訊息都要記錄
    • E_ERROR: 嚴重錯誤,會使得程式當掉的才記錄下來
    • E_WARNING : warning 記錄下來
    • E_PARSE : 編譯錯誤記錄下來
    • E_NOTICE : 提醒工程師,可能會出錯的訊息
    • error_reporting = E_ERROR & E_WARNING :只記錄這兩種錯誤
    • error_reporting = E_ALL & ~E_NOTICE :除了 Notice以外的錯誤都記錄下來
  • display_errors = On
    • [On] : 在網頁顯示錯誤訊息,
如果打開這個功能,當程式發生錯誤時,user會立即在網頁上看到錯誤訊息,除了會讓user以為看到亂碼之外,還有安全性上的風險。
  • [Off] : 不在網頁上顯示錯誤訊息,
  • display_startup_errors
    • [On] : php 起始錯誤會記錄下來,如module載入失敗等等訊息。
    • [Off] : 建議關閉,預設也是關閉的
  • log_errors = On
    • [On] : 將錯誤訊息記錄在檔案裡。
    • [Off] : 關閉記錄錯誤訊息在檔案的功能。
  • log_errors_max_len = 1024 : log檔案的最大size
  • error_log = "/logs/error_log" :指定log的檔案名稱
  • ignore_repeated_errors : 同一個檔案,同一行,忽略重覆的錯誤訊息。
  • ignore_repeated_source : 當同一個錯誤,是執行在不同的檔案時産生,忽略此錯誤訊息。
  • report_memleaks = On : 記錄 memory leak (E_WARNING)
  • track_errors :將誤錯訊息存在變數 $php_errormsg


设置php.ini
1、PHP程序不能自动设置编码问题及解决方法
default_charset = "utf-8"

2、部署到WampServer页面出现( ! ) SCREAM: Error suppression ignored for错误及解决方法


PHP Notice: undefined index 完美解决方法

   $val = !empty($_GET[$str]) ? $_GET[$str] : null;


更改如下属性为:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE 
#error_reporting = E_ALL 

display_startup_errors = Off

ignore_repeated_errors = Off

ignore_repeated_source = Off

track_errors = Off

html_errors = Off

重启WampServer服务,就OK了




( ! ) Fatal error: Call to undefined function ldap_connect()

E:\wamp\bin\php\php5.4.12/php.ini

 ;extension=php_ldap.dll  #962 註解打開



如何修復網站與作業系統常見之漏洞與弱點


避免了 SQL Injection 之攻擊。


/etc/php.ini 有個參數:
  
; http://php.net/magic-quotes-gpc
magic_quotes_gpc = On

當啟用 magic_quotes_gpc 參數後,對於GET/POST 中使用者輸入之特殊字元,如單引號(')雙引號( " )、反斜線( \ ), 前面會自動再加上反斜線( \ ),此時即視同為字元。當 magic_quotes_gpc 功能開啟後,SQL 執行之語法已改變為:
SELECT * FROM admin where login='davis' and passwd='\' or \'a\'=\'a'














Session Cookie without HttpOnly flag set


Description
This session cookie doesn''t have the HTTPOnly flag set. When a cookie is set with the HTTPOnly flag, it instructs the browser that the cookie can only be accessed by the server and not by client-side scripts. This is an important security protection for session cookies.
Impact
None
Recommendation
If possible, you should set the HTTPOnly flag for this cookie.


Session Cookie without HttpOnly flag set
  
; Whether or not to add the httpOnly flag to the cookie, which makes it inaccessible to browser scripting languages such as JavaScript.
; http://php.net/session.cookie-httponly
session.cookie_httponly = true
Session Cookie without Secure flag set
  
; http://php.net/session.cookie-secure
session.cookie_secure = true

2013年3月10日 星期日

wamp server #1045


WAMP的mysql密碼設定






C:\wamp\apps\phpmyadmin3.5.1\config.inc.php
/* Server: localhost [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'localhost';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie'; //config
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'yourdbpassword';
$cfg['Servers'][$i]['AllowNoPassword'] = true;

2013年3月5日 星期二

wamp server apache 403 Forbidden error



C:\wamp\bin\apache\apache2.4.2\conf\httpd.conf
如果使用的是httpd-2.2x版本请使用下面的配置
注意“Allow from all”
如果使用的是http-2.4x版本,请使用如下配置:
注意:“Require all granted”




<Directory />
    AllowOverride none
    #Require all denied
    Require all granted
</Directory>


DocumentRoot "D:/wamp/www/"
<directory wamp="" www="">
    ....
    #Require local
    Order Deny,Allow
    Allow from all
    Allow from 127.0.0.1

</directory>

Wamp -> 重新啟動所有服務



WAMP error: Forbidden You don't have permission to access /phpmyadmin/ on this server


Change the file content of c:\wamp\alias\phpmyadmin.conf to the following.

<Directory "D:/wamp/apps/phpmyadmin3.5.1/">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride all
   #Require local
   Allow from all
</Directory>