首 页 ASP ASP.NET PHP JSP Ajax DIV+CSS JavaScript XML C#
MySQL MSSQL Access Oracle Linux Server 电脑技巧 网络安全 建站经验 其它

在ASP中过滤用户输入 提高安全性

整理日期:2007年08月04日 【字体:


伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-08/1186200425.html
strUserInput = Replace(strUserInput, "'", vbNullString)
strUserInput = Replace(strUserInput, "%", vbNullString)
strUserInput = Replace(strUserInput, ";", vbNullString)
strUserInput = Replace(strUserInput, "(", vbNullString)
strUserInput = Replace(strUserInput, ")", vbNullString)
strUserInput = Replace(strUserInput, "&", vbNullString)
strUserInput = Replace(strUserInput, "+", vbNullString)
strUserInput = Replace(strUserInput, "-", vbNullString)

Set rst = New Recordset
rst.ActiveConnection = "PROVIDER=SQLOLEDB;DATA SOURCE=SQLServer;" & _
            "Initial Catalog=pubs;Integrated Security=SSPI"
rst.Open "Select * from authors where au_lname = '" & strUserInput & _
     "'", , adOpenStatic
'Do something with recordset 1

Set rst2 = rst.NextRecordset()
'Do something with recordset 2

在用户的输入中嵌入命令也是攻击ASP Web应用程序的一种常见手法,也叫做跨网站脚本攻击。过滤输入的内容并使用Server.HTMLEncode和Server.URLEncode这两个方法会有助于防止你ASP应用程序里这类问题的发生。
Tags:
在ASP中过滤用户输入 提高安全性
'http://www.etoow.com/html/2007-08/1186200425.html
1
 
信息搜索
  
联系我们关于本站广告服务设为首页 收藏本站友情链接网站地图
Copyright © Etoow.com Inc. All Rights Reserved