天天看點

asp有效防注入

’******************************************

’ str1 允許的字元串清單

’ str2 外部輸入字元串清單

Function isValid(str1,str2)

’Dim strText

isValid = False

For i = 1 to Len(Trim(str2))

If i = 1 Then

If (Mid(str2,i,1) = "_") Or (Mid(str2,i,1) = "-")   Then

Exit For

End If

If InStr(str1,Mid(str2,i,1)) > 0 Then

isValid = True

Else

Next

End Function

str1 = "0123456789"

if not isValid(str1,request("id")) Then

response.write "

警告!請不要嘗試送出非法字元!你的IP已經被記錄!

本頁3秒後自動傳回

"

Response.end

End if

繼續閱讀