ASP total Station to prevent injection of code

Source: Internet
Author: User

NOTE: Reprint please indicate the source
On Error Resume Next ' This line of code is placed in the first line of conn.asp.

' Prevent injection
Dim qs,errc,iii
Qs=request.servervariables ("Query_string")
' Response.Write (QS)
Dim destr (18)
DESTR (0) = "NET user"
DESTR (1) = "xp_cmdshell"
DESTR (2) = "/add"
DESTR (3) = "Exec%20master.dbo.xp_cmdshell"
DESTR (4) = "Net localgroup Administrators"
DESTR (5) = "Select"
DESTR (6) = "Count"
DESTR (7) = "ASC"
DESTR (8) = "char"
DESTR (9) = "Mid"
DESTR (10) = "'"
DESTR (11) = ":"
DESTR (12) = "" "
DESTR (+) = "Insert"
destr = "Delete"
DESTR = "Drop"
DESTR = "Truncate"
Destr (a) = "from"
DESTR (18) = "%"
Errc=false
For iii= 0 To UBound (DESTR)
If InStr (QS,DESTR (iii)) <>0 then
Errc=true
End If
Next
If ERRC Then
Response.Write ("Sorry, illegal URL address request!")
Response.End
End If

Put this code in your database connection file like conn.asp. Insert it in front of the database connection code. Because all connection library files are to include conn.asp this file, so for each page, if there is an illegal injection, then we can stop the execution of the page before the database connection. To achieve the total station to prevent injection function.



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.