Getting Started: A new way to prevent SQL injection attacks

Source: Internet
Author: User

This article mainly describes how to correctly prevent SQL injection attacks. Recently, due to modifying an ASP program (with SQL Injection Vulnerabilities), I found some preventive measures on the Internet, the enforceability is not very good, so I have improved some methods on the Internet to write this ASP function for your reference.

The following is a reference clip:

 
 
  1. Function SafeRequest (ParaName)
  2. Dim ParaValue
  3. ParaValue = Request (ParaName)
  4. If IsNumeric (ParaValue) = True then
  5. SafeRequest = ParaValue
  6. Exit Function
  7. ElseIf Instr (LCase (ParaValue), "select")> 0 or Instr (LCase (ParaValue), "insert ")

    > 0 or Instr (LCase (ParaValue), "delete from")> 0 or Instr (LCase (ParaValue), "count (")

    > 0 or Instr (LCase (ParaValue), "drop table")> 0 or Instr (LCase (ParaValue), "update ")

    > 0 or Instr (LCase (ParaValue), "truncate")> 0 or Instr (LCase (ParaValue), "asc (")> 0

    Or Instr (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
  8. Response. Write "<script language = 'javascript '>"
  9. Response. Write "alert ('invalid request! ');"'

SQL Injection Attack prompt information found

Response. Write "location. href = 'HTTP: // dev.yesky.com/';" 'web site redirection from SQL injection attacks

 
 
  1. Response.Write "<script>"   
  2. Response.end   
  3. else   
  4. SafeRequest=ParaValue   
  5. End If   
  6. End function  

Use the SafeRequest letter

The above content is a new way to prevent SQL injection attacks.

In this regard.

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.