天天看点

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

继续阅读