伊图教程网[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应用程序里这类问题的发生。
在ASP中过滤用户输入 提高安全性
'http://www.etoow.com/html/2007-08/1186200425.html