學習php安全和防注入

2021-06-11 18:21:58 字數 913 閱讀 2370

大致有:

1. sql注入防範

2. 檔案上傳漏洞防範

3. cookie欺騙防範

4. 跨站攻擊(xss)防範

主要介紹下面2個函式的使用:

<?php

//增加轉義:

if (!get_magic_quotes_gpc())

//用上面的函式

strip

cslash

es_deep遞迴增加所有引數裡面的轉義符號「\」

$_post = array_map('addslashes_deep',$_post); 

$_get = array_map('addslashes_deep',$_get); 

$_cookie = array_map('addslashes_deep',$_cookie); 

//去掉轉義:

if (!get_magic_quotes_gpc())

//用上面的函式stripslashes_deep遞迴增加所有引數裡面的轉義符號「\」

$_post = array_map('strip

cslash

es_deep',$_post); 

$_get = array_map('strip

cslash

es_deep',$_get); 

$_cookie = array_map('strip

cslash

es_deep',$_cookie); 

}總結: 1.

永遠不要相信你的使用者。

2.fliter input,escape output.

PHP 防 SQL 注入和開發安全

程式設計師水平和經驗參差不齊,一部分程式設計師在編寫 的時候沒有對使用者輸入的資料合法性進行判斷,使應用程式存在安全隱患。使用者可以提交一段資料庫查詢 根據程式返回的結果,獲得某些他想知道的資料,這就是所謂的 sql injection,即 sql 注入。受影響的系統 對輸入不進行檢查和過濾的系統。...

PHP全站防注入

arrfiltrate array union 出錯後要跳轉的url,不填則預設前一頁 strgourl 是否存在陣列中的值 functionfunstringexist strfiltrate,arrfiltrate returnfalse 合併 post和 get 驗證開始 foreach ar...

PHP防SQL注入

php防sql注入攻擊 收藏 沒有太多的過濾,主要是針對php和mysql的組合。一般性的防注入,只要使用php的 addslashes 函式就可以了。以下是一段copy來的 php post sql injection post get sql injection get function sql...