网站推广-网站优化-合肥久飞SEO论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 130|回复: 0

ASP网站跨站脚本攻击漏洞解决方法

[复制链接]
发表于 2013-4-6 02:04:23 | 显示全部楼层 |阅读模式
'Dim Query_Badword,Form_Badword,i,Err_Message,Err_Web,name

'------定义部份  头----------------------------------------------------------------------

Err_Message = 1 '处理方式:1=提示信息,2=转向页面,3=先提示再转向

Err_Web = "/main/Index.Asp" '出错时转向的页面

Query_Badword="'∥and∥<∥alert∥select∥update∥chr∥delete∥ from∥;∥insert∥mid∥master.∥set∥chr(37)∥="   

'在这部份定义get非法参数,使用"∥"号间隔   

Form_Badword="'∥%∥&∥*∥#∥="     '在这部份定义post非法参数,使用"∥"号间隔

'------定义部份  尾-----------------------------------------------------------------------
'
'On Error Resume Next
'----- 对 get query 值 的过滤.
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

'-----对 post 表 单值的过滤.

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\n请不要在表单中出现: % & * # ( )  等非法字符!');location.href='"&Err_Web&"';</Script>"
End Select
Response.End
End If
NEXT
NEXT
end if

本文地址: https://jiufei.net/bbs/thread-10016-1-1.html
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|合肥网站优化,合肥百度优化,合肥网络推广,合肥SEO优化论坛 ( 皖ICP备2022014487号-2 )

GMT+8, 2025-1-31 10:38 , Processed in 0.054259 second(s), 15 queries , File On.

Powered by jiufei X3.4

© 2008-2020 www.jiufei.net

快速回复 返回顶部 返回列表