- 帖子
- 3852
- 积分
- 13044
- 威望
- 16780
- 金钱
- 36761
- 在线时间
- 1139 小时
|
实施修复,方法有很多在这里介绍两种,咱们使用第2种
方法1: Replace过滤字符
解决方法:查找login.asp下的<from找到下边的类似
username=request.Form("name")
pass=request.Form("pass")
修改为:
username=Replace(request.Form("name"), "’", "’’")
pass=Replace(request.Form("pass"), "’", "’’")
语法是屏蔽’和’’字符来达到效果.
方法2:在conn.asp 内加入<!--#include file="safe.asp"-->
注:(前提 登陆页面有<!--#include file="conn.asp"-->)
把以下代码保存为safe.asp
下面是程序代码********************************************************
<%
Dim Query_Badword,Form_Badword,i,Err_Message,Err_Web,name
Err_Message = 3
Err_Web = "safe.htm"
’出错时转向的页面
Query_Badword="’|and|select|update|chr|delete|%20from|;|insert|mid|master.|set|chr(37)|="
’在这部份定义get非法参数,使用"|"号间隔
Form_Badword="’|(|)|;|="
’在这部份定义post非法参数,使用"|"号间隔
On Error Resume Next
if request.QueryString<>"" then
Chk_badword=split(Query_Badword,"|")
FOR EACH Query_Name IN Request.QueryString
for i=0 to ubound(Chk_badword)
If Instr(LCase(request.QueryString(Query_Name)),Chk_badword(i))<>0 Then
Select Case Err_Message
Case "1"
Response.Write "<Script Language=JavaScript>alert(’传参错误!参数 "&name&" 的值中包含非法字符串!\n\n请不要在参数中出现:and update delete ; insert mid master 等非法字符!’);window.close();</Script>"
Case "2"
Response.Write "<Script Language=JavaScript>location.href=’"&Err_Web&"’</Script>"
Case "3"
Response.Write "<Script Language=JavaScript>alert(’传参错误!参数 "&name&"的值中包含非法字符串!\n\n请不要在参数中出现:and update delete ; insert mid master 等非法字符!’);location.href=’"&Err_Web&"’;</Script>"
End Select
Response.End
End If
NEXT
NEXT
End if
if request.form<>"" then
Chk_badword=split(Form_Badword,"|")
FOR EACH name IN Request.Form
for i=0 to ubound(Chk_badword)
If Instr(LCase(request.form(name)),Chk_badword(i))<>0 Then
Select Case Err_Message
Case "1"
Response.Write "<Script Language=JavaScript>alert(’出错了!表单 "&name&" 的值中包含非法字符串!\n\n你的非法操作已记录,请马上停止非法行为!’);window.close();</Script>"
Case "2"
Response.Write "<Script Language=JavaScript>location.href=’"&Err_Web&"’</Script>"
Case "3"
Response.Write "<Script Language=JavaScript>alert(’唐山味儿不浓 告诉您出错了!参数 "&name&"的值中包含非法字符串!\n\谢谢您光临!,请停止非法行为!’);location.href=’"&Err_Web&"’;</Script>"
End Select
Response.End
End If
NEXT
NEXT
end if
%> |
|