ASP prevents SQL injection methods

Source: Internet
Author: User
Tags servervariables sql injection sql injection methods

Generic 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 ""

Response.End

End If

Next

Next

End If

If request.form<> "" Then ' liehuo.net

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 ""

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 "

Your URL is illegal.

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%20from") or Instr (strtemp, "Count (") or Instr (strtemp," drop%20table ") 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_cmdshell ") or Instr (strtemp," exec% ") 20master ") or Instr (strtemp," net%20localgroup%20administrators ") or Instr (strtemp," Net%20user ") 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, ",") or Instr (strtemp, ",") or Instr (strtemp, "%27") Then

Response.Write ""

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.