General Anti-SQL Injection code ASP Edition

Source: Internet
Author: User
Tags servervariables

General Anti-SQL Injection code ASP Edition

 

Code

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 (Request. QueryString)
Response. Write "<Script> alert! '); 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 (Request. Form)
Response. Write "<Script> alert! '); History. back (-1) </Script>"

Response. end
End if
Next
Next
End If

Sss = LCase (request. servervariables ("QUERY_STRING "))

If instr (sss, "select") <> 0 or instr (sss, "inster") <> 0 or instr (sss, "delete ") <> 0 or instr (sss, "(") <> 0 or instr (sss, "'or") <> 0 then
Response. write "<BR> <center> your website is invalid"
Response. end
End if

StrTemp = request. servervariables ("server_name") & request. servervariables ("url ")&"? "& 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, "net % 20 user ") or Instr (StrTemp, "% 20or % 20") or Instr (StrTemp, "'") or Instr (StrTemp, "% 20") or Instr (StrTemp, ") or Instr (StrTemp,": ") or Instr (StrTemp ,": ") or Instr (StrTemp,"; ") or Instr (StrTemp,"; ") or Instr (StrTemp,", ") or Instr (StrTemp ,",") or Instr (StrTemp, "% 27") then
Response. Write "<script language = 'javascript '> alert ('invalid operation! Return now! '); History. back (); </script>"

Response. end

End If

 

 

 

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.