This file can be contained in the header of any ASP file that needs to be called to the database, and illegal injection can be taken into account directly.

Source: Internet
Author: User
<% 'This file can be contained in the header of any ASP file that needs to be called to the database, and illegal injection can be ignored directly.
'Call method: <! -- # Include file = "safe. asp" -->
Function Safe (str) 'this Function is used to determine whether the passed variable contains special characters. TRUE is not returned.
Dim s_BadStr, n, I
S_BadStr = "'& <>? % ,;:()'~! @ # $ ^ * {} [] |/+-= "& Chr (34) & Chr (9) & Chr (32)
N = Len (s_BadStr)
Safe = True
For I = 1 To n
If Instr (str, Mid (s_BadStr, I, 1)> 0 Then
Safe = False
Exit Function
End If
Next
End Function
'The following code directly checks whether the requested URL contains invalid characters
On Error Resume Next
Dim strTemp
If LCase (Request. ServerVariables ("HTTPS") = "off" Then
StrTemp = "http ://"
Else
StrTemp = "https ://"
End If
StrTemp = strTemp & Request. ServerVariables ("SERVER_NAME ")
If Request. ServerVariables ("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request. ServerVariables ("SERVER_PORT ")
StrTemp = strTemp & Request. ServerVariables ("URL ")
If Trim (Request. QueryString) <> "Then strTemp = strTemp &"? "& Trim (Request. QueryString)
StrTemp = LCase (strTemp)
If Instr (strTemp, "select % 20") or Instr (strTemp, "insert % 20") or Instr (strTemp, "delete % 20 from") or Instr (strTemp, "count (") or Instr (strTemp, "drop % 20 table") or Instr (strTemp, "update % 20") or Instr (strTemp, "truncate % 20 ") or Instr (strTemp, "asc (") or Instr (strTemp, "mid (") or Instr (strTemp, "char (") or Instr (strTemp, "xp_{shell ") or Instr (strTemp, "exec % 20 master") or Instr (strTemp, "net % 20 localgroup % 20 administrators") or Instr (strTemp, "db_name (") or Instr (strTemp, "net % 20 user") or Instr (strTemp, "'") or Instr (strTemp, "% 20or") or Instr (strTemp, "backup % 20") then

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.