首页WEB开发ASP教程 → asp防范SQL注入攻击函数

asp防范SQL注入攻击函数

日期:2007-10-17 20:58:45 出处:其他转载 作者:不详 人气:

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='http://www.baidu.com/';"  '发现SQL注入攻击转跳网址
 Response.Write "<script>"
 Response.end
else
SafeRequest=ParaValue
End If
End function

使用方法:用SafeRequest函数替换所有用Request的场合

关于本站 | 帮 助 | 广告服务 | 版权声明 | 业务合作 | 捐助本站 | 软件发布 | 联系我们
77资源下载 www.77zy.com ©2007-2008 版权所有
备案编号:赣ICP备07002641号  QQ:674648476