The technique of ASP anti-XSS injection function

Source: Internet
Author: User
'*************************************
' Anti-XSS injection function updated to 2009-04-21 by Evio
' CHECKXSS is more secure than CHECKSTR ()
'*************************************
Function CHECKXSS (ByVal chkstr)
Dim STR
STR = Chkstr
If IsNull (STR) Then
Checkstr = ""
Exit Function
End If
str = Replace (str, "&", "&")
str = Replace (str, "'", "´")
str = Replace (str, "" "", """)
str = Replace (str, "<", "&lt;")
str = Replace (str, ">", "&gt;")
str = Replace (str, "/", "& #47;")
str = Replace (str, "*", "& #42;")
Dim RE
Set re = New RegExp
Re. IgnoreCase = True
Re. Global = True
Re. Pattern = "(w) (here)"
Str = Re. Replace (Str, "$1h& #101; Re")
Re. Pattern = "(s) (elect)"
Str = Re. Replace (Str, "$1el& #101; CT")
Re. Pattern = "(i) (nsert)"
Str = Re. Replace (Str, "$1ns& #101; RT")
Re. Pattern = "(c) (reate)"
Str = Re. Replace (Str, "$1r& #101; ate")
Re. Pattern = "(d) (ROP)"
Str = Re. Replace (Str, "$1ro& #112;")
Re. Pattern = "(a) (Lter)"
Str = Re. Replace (Str, "$1lt& #101; R")
Re. Pattern = "(d) (elete)"
Str = Re. Replace (Str, "$1el& #101; TE")
Re. Pattern = "(u) (pdate)"
Str = Re. Replace (Str, "$1p& #100; ate")
Re. Pattern = "(s) (or)"
Str = Re. Replace (Str, "$1o& #114;")
Re. Pattern = "(n)"
Str = Re. Replace (Str, "$1o& #114;")
'----------------------------------
Re. Pattern = "(Java) (script)"
Str = Re. Replace (Str, "$1scri& #112; t")
Re. Pattern = "(j) (script)"
Str = Re. Replace (Str, "$1scri& #112; t")
Re. Pattern = "(VB) (script)"
Str = Re. Replace (Str, "$1scri& #112; t")
'----------------------------------
If Instr (Str, "exPRession") > 0 Then
str = Replace (str, "expression", "e& #173; Xpression", 1,-1, 0) ' Prevent XSS injection
End If
Set re = Nothing
CHECKXSS = 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.