新手入门:防范SQL注入攻击的新办法

此文章主要向大家描述的是正确防范SQL注入攻击的好用方案,近段时间由于修改一个ASP程序(有SQL注入漏洞),在网上找了一些防范办法,可执行性都不咋地,所以我将现在网上的一些方法综合改良了一下,写出这个ASP函数,供大家参考。

以下是引用片段:

  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('非法的请求!');" ' 

发现SQL注入攻击提示信息

Response.Write “location.href=’http://dev.yesky.com/’;” ‘发现SQL注入攻击转跳网址

 

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

使用SafeRequest函

上述的相关内容就是对新手入门:防范SQL注入攻击的新办法

 

的描述,希望会给你带来一些帮助在此方面。

 

【编辑推荐】

  1. 防止SQL注入攻击:网络管理员的前景展望
  2. ScanSafe:近期3波SQL注入攻击100万中国网站
  3. 图文详解网站SQL注入攻击解决全过程
  4. 有效预防SQL注入攻击的六脉神剑
  5. 防止SQL注入攻击:网络管理员的前景展望

     

     

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/146505.html<

(0)
运维的头像运维
上一篇2025-03-11 03:09
下一篇 2025-03-11 03:10

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注