当前位置: 首页 > 图文教程 > 数据库 > MYSQL > 防范SQL注入攻击的新办法

MYSQL
Timeout error occurred trying to start MySQL Daemon
Phpcms2008网站内容管理系统免费开源
PHP教程:常用mysql操作
MySQL教程:Order By用法
MYSQL导入数据Got a packet bigger than...错误
MySQL安装向导所作的更改
MySQL教程:Order By索引优化
MySQL教程:Order By语法
MySQL教程:Order By Rand()
MySQL教程:Replace INTO说明
MySQL server has gone away问题原因
MySQL教程:Group By用法
MySQL命令终端有beep声
mysql与sqlserver的所有区别
SQLite数据库最适合做网站内容管理系统(CMS)
mysql proxy问题
Windows下PHP+MySQL+IIS安全平台搭建
e2php搭建Windows下Apache+PHP+MySQL环境
PHP简单学习,保证入门学会
MYSQL的DATE_FORMAT()格式化日期

MYSQL 中的 防范SQL注入攻击的新办法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-17   浏览: 49 ::
收藏到网摘: n/a

  近段时间由于修改一个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='http://blog.knowsky.com/';"  '发现SQL注入攻击转跳网址
 Response.Write "<script>"
 Response.end
else
SafeRequest=ParaValue
End If
End function

  使用SafeRequest函数替换你的Request

  请作者联系本站,及时附注您的姓名。联系邮箱:edu#ruanchen.com(把#改为@)。