asp防范SQL注入攻击的函数
时间:2008-03-11 12:23:00
近段时间由于修改一个ASP程序(有SQL注入漏洞),在网上找了很多相关的一些防范办法,都不近人意,所以我将现在网上的一些方法综合改良了一下,写出这个ASP函数,供大家参考。
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),"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
Response.Write "<script language='javascript'>"
Response.Write "alert('非法的请求!');" '发现SQL注入攻击提示信息
Response.Write "location.href='https://www.aspxhome.com/';" '发现SQL注入攻击转跳网址
Response.Write "<script>"
Response.end
else
SafeRequest=ParaValue
End If
End function
使用SafeRequest函数替换你的Request
标签:注入,sql,函数,asp
0
投稿
猜你喜欢
asp fso创建与删除文件与文件夹
2008-12-31 16:07:00
图片放大镜,多图片放大(已更新)[可调整倍数、区域大小、展示区域位置]
2011-06-16 20:43:07
SQLServer 连接 EXCEL
2009-07-09 19:00:00
Css Reset(复位)整理
2008-09-09 21:58:00
Linux上MySql远程备份方案
2010-11-25 17:23:00
浅谈ASP自动采集程序及入库
2007-08-17 11:25:00
ASP基础教程:常用的 ASP ActiveX 组件
2008-10-14 15:15:00
善用用户反馈——浅谈用户反馈数据的处理
2010-07-09 16:58:00
CSS元素类型
2009-04-27 12:25:00
WEB页面工具语言XML应用分类之运用
2008-05-29 10:58:00
如何将服务器端变量转换为客户端的变量?
2009-12-03 19:54:00
破解 屏蔽 防框架代码 top.location != self.location
2008-11-27 12:59:00
JavaScript创始人Brendan Eich访谈录
2008-09-16 12:01:00
如何提示用户打开Cookie?
2010-06-07 20:53:00
ASP实例:读取xml文件的程序
2007-11-04 18:47:00
慢慢的网页
2009-11-12 12:53:00
一个简单的像素画小工具
2010-01-01 15:33:00
一个用JavaScript写的本周是本学期第几周的程序
2009-03-09 12:49:00
Mysql使用Describe命令判断字段是否存在
2011-04-25 18:27:00
使用 TRUNCATE TABLE 删除所有行
2008-04-24 19:20:00