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

首頁 > 編程 > ASP > 正文

ASP防SQL注入的兩種函數(shù)代碼

2024-05-04 11:07:26
字體:
供稿:網(wǎng)友

Function SafeRequest(ParaName,ParaType) 
’--- 傳入?yún)?shù) --- 
’ParaName:參數(shù)名稱-字符型 
’ParaType:參數(shù)類型-數(shù)字型(1表示以上參數(shù)是數(shù)字,0表示以上參數(shù)為字符) 

Dim ParaValue 
ParaValue=Request(ParaName) 
If ParaType=1 then 
If not isNumeric(ParaValue) then 
Response.write "參數(shù)" & ParaName & "必須為數(shù)字型!" 
Response.end 
End if 
Else 
ParaValue=replace(ParaValue,"’","’’") 
End if 
SafeRequest=ParaValue 
End function 

用SafeRequest(ParaName,ParaType)代替request.form("")和request..querystring("")

   *********************************************************************************************************

-------------------------------------------------------------------------------------------------------------------------------------------

   *********************************************************************************************************

<%
dim sql_injdata
sql_injdata="’|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
sql_injHint=replace(sql_injdata,"|"," ")
sql_injHint=replace(sql_injHint,"’","’")
sql_inj=split(sql_injdata,"|")

if request.querystring<>"" then
    for each getData in request.querystring
    for i=0 to ubound(sql_inj)
        if instr(lcase(request.querystring(getData)),sql_inj(i))>0 then
        hint="alert(’為了保證用戶的信息安全,請(qǐng)不要使用非法注入字符。如下字符為非法的: @sql_injHint@’);"
        hint=replace(hint,"@sql_injHint@",sql_injHint)
        response.write "<script language=javascript>"
        response.write hint
        response.write "history.back()"
        response.write "</script>"
        response.end
      end if
    next
    next
end if

if request.form<>"" then
    for each getData in request.querystring
    for i=0 to ubound(sql_inj)
        if instr(lcase(request.form(getData)),sql_inj(i))>0 then
        hint="alert(’為了保證用戶的信息安全,請(qǐng)不要使用非法注入字符。如下字符為非法的: @sql_injHint@’);"
        hint=replace(hint,"@sql_injHint@",sql_injHint)
        response.write "<script language=javascript>"
        response.write hint
        response.write "history.back()"
        response.write "</script>"
        response.end
      end if
    next
    next
end if
%>將此段代碼形成一個(gè)文件 (如:defanj.asp),將所有要用到數(shù)據(jù)庫的文件頭部加入<!--#include file=defanj.asp-->

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 太仓市| 阳江市| 岳阳市| 将乐县| 炉霍县| 沂水县| 安国市| 寿宁县| 绥德县| 台北县| 迁西县| 科技| 宜君县| 麦盖提县| 桐梓县| 庆安县| 容城县| 华安县| 乌海市| 碌曲县| 江门市| 新和县| 泰安市| 于田县| 高邮市| 双流县| 沅江市| 安龙县| 南丹县| 柳江县| 阿克| 河东区| 新绛县| 洛浦县| 遂平县| 休宁县| 惠州市| 洪江市| 文昌市| 宜阳县| 邻水|