The application of ASP to implement the method of heavy coding for SQL injection dangerous characters

Source: Internet
Author: User
Tags sql injection
<%
'******************************
' Function: Checkstr (byVal chkstr)
' Parameters: Chkstr, characters to be validated
' Author: Arisisi
' Date: 2007/7/15
' Description: SQL injection of dangerous characters for heavy-coded processing
' Example: Checkstr ("and 1=1 or select * from")
'******************************
Function checkstr (ByVal chkstr)
Dim Str:str=chkstr
Str=trim (STR)
If IsNull (STR) Then
Checkstr = ""
Exit Function
End If
Dim RE
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Re. Pattern= "(\ r \ n) {3,}"
Str=re. Replace (STR, "$1$1$1")
Set re=nothing
str = Replace (str, "'", "" ")
str = Replace (str, "select", "select")
str = Replace (str, "join", "join")
str = Replace (str, "union", "union")
str = Replace (str, "where", "where")
str = Replace (str, INSERT, insert)
str = Replace (str, "delete", "delete")
str = Replace (str, "Update", "Update")
str = Replace (str, "like", "like")
str = Replace (str, "Drop", "drop")
str = Replace (str, "create", "create")
str = Replace (str, "Modify", "modify")
str = Replace (str, "rename", "Rename")
str = Replace (str, "ALTER", "alter")
str = Replace (str, "cast", "cast")
Checkstr=str
End Function

' Reverse the string processed by the above function

Function Uncheckstr (STR)
str = Replace (str, "select", "select")
str = Replace (str, "join", "join")
str = Replace (str, "union", "union")
str = Replace (str, "where", "where")
str = Replace (str, INSERT, insert)
str = Replace (str, "delete", "delete")
str = Replace (str, "Update", "Update")
str = Replace (str, "like", "like")
str = Replace (str, "Drop", "drop")
str = Replace (str, "create", "create")
str = Replace (str, "Modify", "modify")
str = Replace (str, "rename", "Rename")
str = Replace (str, "ALTER", "alter")
str = Replace (str, "cast", "cast")
Uncheckstr=str
End Function
%>
Related Article

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.