A new approach to preventing SQL injection attacks

Source: Internet
Author: User
Tags sql net sql injection sql injection attack
Attack
Recently because of the modification of an ASP program (with SQL injection vulnerability), in the online search for a number of related prevention methods, are not nearly satisfactory, so I will now some of the online methods to improve a little, write this ASP function, for your reference.

Function Saferequest (Paraname)
Dim Paravalue
Paravalue=request (Paraname)
If IsNumeric (paravalue) = True Then
Saferequest=paravalue
Exit Function
ElseIf Instr (LCase (Paravalue), "select") > 0 or Instr (LCase (paravalue), "Insert") > 0 or Instr (LCase (Paravalue), "de Lete from ") > 0 or Instr (LCase (Paravalue)," Count (") > 0 or Instr (LCase (Paravalue)," drop table ") > 0 or Instr (LCas E (Paravalue), "Update") > 0 or Instr (LCase (paravalue), "truncate") > 0 or Instr (LCase (Paravalue), "ASC (") > 0 or I Nstr (LCase (Paravalue), "Mid (") > 0 or Instr (LCase (Paravalue), "char (") > 0 or Instr (LCase (Paravalue), "xp_cmdshell"   ) > 0 or Instr (LCase (Paravalue), "exec master") > 0 or Instr (LCase (paravalue), "net localgroup Administrators") > 0 or Instr (LCase (Paravalue), "and") > 0 or Instr (LCase (paravalue), "NET user") > 0 or Instr (LCase (Paravalue), "or") > 0 Then
Response.Write "<script language= ' JavaScript ' >"
Response.Write "alert (' Illegal request! ');" ' Discovery SQL injection attack prompt information
Response.Write "location.href= ' http://www.wz114.com/';" ' Discovery SQL injection attack jump URL
Response.Write "<script>"
Response.End
Else
Saferequest=paravalue
End If
End Function

Replace your request with the Saferequest function

can prevent all SQL injection attacks, if you have any questions please contact me

Email:ruixing123@hotmail.com


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.