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
投稿

猜你喜欢

  • 浅谈python中的__init__、__new__和__call__方法

    2023-01-05 21:21:03
  • Myeclipse链接Oracle等数据库时lo exception: The Network Adapter could not establish the connection

    2023-07-19 12:40:02
  • 大规格文件的上传优化思路详解

    2022-02-13 06:05:56
  • python爬虫开发之selenium模块详细使用方法与实例全解

    2022-12-15 01:28:40
  • Windows Server 2003下修改MySQL 5.5数据库data目录

    2024-01-14 17:42:28
  • Python OpenCV Hough直线检测算法的原理实现

    2021-01-29 10:10:00
  • 简化版的vue-router实现思路详解

    2024-05-10 14:17:28
  • 利用Python编写的实用运维脚本分享

    2022-07-15 21:32:46
  • Python全栈之正则表达式

    2022-09-12 16:17:09
  • Python全栈之字符串和列表相关操作

    2022-02-04 04:15:25
  • 利用Python的Django框架中的ORM建立查询API

    2023-11-15 10:06:03
  • ASP 调用dll及封装dll实例

    2011-03-17 10:47:00
  • Redis有序集合类型的操作_动力节点Java学院整理

    2024-01-27 23:06:47
  • Jinja2过滤器的使用、控制语句示例详解

    2023-01-30 19:02:00
  • 让自定义文件下载支持断点续传

    2009-03-11 19:45:00
  • mysql数据库设置utf-8编码的方法步骤

    2024-01-19 05:30:56
  • Python实现多线程下载文件的代码实例

    2022-11-06 02:41:12
  • Python函数基础实例详解【函数嵌套,命名空间,函数对象,闭包函数等】

    2023-12-10 15:45:59
  • 浅谈js的html元素的父节点,子节点

    2024-04-23 09:31:56
  • mysql去重查询的三种方法小结

    2024-01-21 14:52:22
  • asp之家 网络编程 m.aspxhome.com