Three illegal SQL injection characters for filtering illegal SQL characters

Source: Internet
Author: User
Tags chr sql injection trim

'**************************************************
' Function name: R
' Parameters: Strchar-----The characters to filter
' Return value: Filtered character
'**************************************************

Public Function R (Strchar)
If Strchar = "" Or IsNull (strchar) Then R = "": Exit Function
Dim Strbadchar, Arrbadchar, Tempchar, I
' Strbadchar = ' $,#, ',%,^,&,?, (,), <,>,[,],{,},/,,;,:, "& Chr (+) &", & Chr (0) & ""
Strbadchar = "+, ',--,%,^,&,?, (,), <,>,[,],{,},/,,;,:," & Chr (+) & ", & Chr (0) &" "
Arrbadchar = Split (Strbadchar, ",")
Tempchar = Strchar
For I = 0 to UBound (Arrbadchar)
Tempchar = Replace (Tempchar, Arrbadchar (I), "")
Next
Tempchar = Replace (Tempchar, "@@", "@")
R = Tempchar
End Function
' Filter XSS
Function CHECKXSS (ByVal strcode)
Dim Re
Set re=new REGEXP
Re. IgnoreCase =true
Re. Global=true
Re. Pattern= ". [^>]* (Style) .> "
Strcode = Re. Replace (Strcode, "")
Re. Pattern= "< (a.[^>]*|/a|li|br| B|/li|/b|font. [^>]*|/font) > "
Strcode=re. Replace (Strcode, "[$]")
Strcode=replace (Replace (Strcode, "<", "<"), ">", ">")
Re. Pattern= "[(a.[^]]*|/a|li|br| B|/li|/b|font. [^]] *|/font)] "
Strcode=re. Replace (Strcode, "<$1>")
Re. Pattern= ". [^>]* (On (Load|click|dbclick|mouseover|mouseout|mousedown|mouseup|mousewheel|keydown|submit|change|focus)). > "
Strcode = Re. Replace (Strcode, "")
Set re=nothing
Checkxss=strcode
End Function

Anti-SQL illegal character injection two

Function Filterids (ByVal strids)
Dim Arrids,i,strreturn
Strids=trim (Strids)
If Len (strids) =0 Then Exit Function
Arrids=split (Strids, ",")
For i=0 to Ubound (arrids)
If chkclng (Trim (Arrids (i)) <>0 Then
Strreturn=strreturn & "," & Int (Arrids (i))
End If
Next
If Left (strreturn,1) = "," Then strreturn=right (Strreturn,len (Strreturn)-1)
Filterids=strreturn
End Function

Filter SQL injection Character selector

' **************************************************
Function name: R
' function: Filtering illegal SQL characters
' parameter: Strchar-----characters to filter
' return value: Filtered character
' **************************************************

Public Function R (Strchar)
If Strchar = "" Or IsNull (strchar) Then R = "": Exit Function
Dim Strbadchar, Arrbadchar, Tempchar, I
' Strbadchar = ' $,#, ',%,^,&,?, (,), <,>,[,],{,},/,,;,:, "& Chr (+) &", & Chr (0) & ""
Strbadchar = "+, ',--,%,^,&,?, (,), <,>,[,],{,},/,,;,:," & Chr (+) & ", & Chr (0) &" "
Arrbadchar = Split (Strbadchar, ",")
Tempchar = Strchar
For I = 0 to UBound (Arrbadchar)
Tempchar = Replace (Tempchar, Arrbadchar (I), "")
Next
Tempchar = Replace (Tempchar, "@@", "@")
R = Tempchar
End Function

SQL anti-injection Four

Function Checksql ()' Prevent SQL injection
Dim Sql_injdata
Sql_injdata = "' |and|exec|insert|select|delete|update|count|*|%| Chr|mid|master|truncate|char|declare "
Sql_inj = Split (Sql_injdata, "|")
If request.querystring<> "" Then
For each sql_get in Request.QueryString
For Sql_data=0 to Ubound (Sql_inj)
If InStr (Request.QueryString (Sql_get), Sql_inj (sql_data)) >0 Then
Response.Write "<script language= ' JavaScript tutorial ' >{alert (' Do not include illegal characters in Parameters!) '); History.back ( -1)}</script> "
Response.End
End If
Next
Next
End If
If request.form<> "" Then
For each sql_post in Request.Form
For Sql_data=0 to Ubound (Sql_inj)
If InStr (Request.Form (Sql_post), Sql_inj (sql_data)) >0 Then
Response.Write "<script language= ' JavaScript ' >{alert (' Do not include illegal characters in Parameters! '); History.back ( -1)} </Script> "
Response.End
End If
Next
Next
End If
End 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.