怎么样才能让ASP避免被SQL注入啊?
来源:asp之家 发布时间:2008-08-08 12:27:00
标签:注入,sql,安全
某人使用如下过滤代码,发现经常被黑:
n=request.form("username")
p=request.form("userchr")
if instr(n,"'")<>0 then response.end
if instr(n,"=")<>0 then response.end
if instr(n,"%")<>0 then response.end
if n<>"" and p<>"" then
set rs1 = Server.CreateObject("ADODB.Recordset")
sql="select * from Character where AccountID='"&n&"' and Name='"&p&"' and pklevel<>3"
rs1.open sql,conn,1,3
下面是网友的一些建议:
只对username进行了过滤,不够严密饿.:)
没有对userchr进行过滤,导致SQL注入..
用这句就可以把数据库改了:
XX';update character set clevel=200 where accountID='YOUID';--
我总结了被黑的经验:
1.禁止远程提交:
server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))
server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))
if mid(server_v1,8,len(server_v2))<>server_v2 then
response.write "<br><br><center><table border=1 cellpadding=20 bordercolor=black bgcolor=#EEEEEE width=450>"
response.write "<tr><td style='font:9pt Verdana'>"
response.write "你提交的路径有误,禁止从站点外部提交数据!"
response.write "</td></tr></table></center>"
response.end
end if
常用的非法字串提交,尤其有有查询的页面,或写入数据库,尽量不要GET方式提交
过滤大部分敏感字符函数:
sub checkdata(datavalue)
if instr(datavalue,";")<>0 or instr(datavalue,">")<>0 or instr(datavalue,"<")<>0 or instr(datavalue,")")<>0 or instr(datavalue,"(")<>0 or instr(datavalue,"'")<>0 or instr(datavalue,"/")<>0 or instr(datavalue,"\")<>0 or instr(datavalue,",")<>0 or instr(datavalue," ")<>0 or instr(datavalue," ")<>0 or instr(datavalue,chr(13))<>0 or instr(datavalue,"&")<>0 or instr(datavalue,"%")<>0 or instr(datavalue,"=")<>0 then
response.write "<script language=javascript>alert('对不起!您所输入的数据包含非法字符');history.back()</script>"
response.end
end if
end sub
过滤一部分:
sub mincheckdata(datavalue)
if instr(datavalue,";")<>0 or instr(datavalue,"(")<>0 or instr(datavalue,"'")<>0 or instr(datavalue,"=")<>0 or instr(datavalue,"%")<>0 or instr(datavalue,"&")<>0 then
response.write "<script language=javascript>alert('对不起!您所输入的数据包含非法字符');history.back()</script>"
response.end
end if
end sub
0
投稿
猜你喜欢
- 为某国税局开发一综合 * ,需要建立一个庞大的国税系统通讯录数据库,从各省、市到每名具体工作人员,项目较多,该如何设计各表呢?数据库的表设计
- 这篇文章主要介绍了Python属性和内建属性实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友
- 前言bufio包实现了带缓冲的I/O,它封装了io.Reader和io.Writer对象,然后创建了另外一种对象(Reader或Writer
- DROP FUNCTION IF EXISTS `getPY`; DELIMITER ;; CREATE FUNCTION `getPY`(
- MySql explain语句的返回结果中,filtered字段要怎么理解?MySql5.7官方文档中描述如下:The filte
- 近来,随着XHTML(可扩展HTML)标准的出现,<script/>标签也经历了一些改变。该标签不再用language特性,而用
- js判断undefined类型今天使用showModalDialog打开页面,返回值时。当打开的页面点击关闭按钮或直接点浏览器上的关闭则返回
- 前言:分区是一种表的设计模式,通俗地讲表分区是将一大表,根据条件分割成若干个小表。但是对于应用程序来讲,分区的表和没有分区的表是一样的。换句
- 在通过拼组sql语句来实现数据插入的应用中,我们很有可能会遇到需要插入大型数据的情况,例如,在oracle中需要插入字节数超过4000的字段
- 一、使用xlrd对excel进行数据读取excel表格示例:安装xlrd库pip install xlrd导入xlrd库import xlr
- 前言相信大家应该都有所体会,在目前的软件项目中,都会较多的使用到对文档的操作,用于记录和统计相关业务信息。由于系统自身提供了对文档的相关操作
- 本文实例讲述了微信小程序之事件交互操作。分享给大家供大家参考,具体如下:微信小程序—点击事件什么是事件?指点击,触摸,按下,滑动,松开,等一
- 本文实例讲述了C#基于数据库存储过程的AJAX分页实现方法。分享给大家供大家参考。具体如下:首先我们在数据库(SQL Server)中声明定
- 很久以前就知道微软的Petshop的很经典,昨天抽出时间去学习,一开始还真的不适应,什么成员资格,还真的看不太懂,运行petshop想从登陆
- 1.hashlib密码散列hashlib模块定义了一个API来访问不同的密码散列算法。要使用一个特定的散列算法,可以用适当的构造器函数或ne
- 异步编程一直是JavaScript 编程的重大事项。关于异步方案, ES6 先是出现了 基于状态管理的 Promise,然后出现了 Gene
- 打印类的所有属性和方法利用dir(obj)方法获得obj对象的所有属性和方法名,返回一个list。for item in dir(top_k
- Python之所以这么流行,是因为它不仅能够应用于科技领域,还能用来做许多其他学科的研究工具,绘制地图便是其功能之一。今天我们用matplo
- mergemerge 函数通过一个或多个键将数据集的行连接起来。场景:针对同一个主键存在的两张包含不同特征的表,通过主键的链接,将两张表进行
- 进程、线程和协程之间的关系和区别也困扰我一阵子了,最近有一些心得,写一下。进程拥有自己独立的堆和栈,既不共享堆,亦不共享栈,进程由操作系统调