用户名: 密码: 免费注册 忘记密码? 网站地图 | 加入收藏 | 设为首页
首页 | 新闻 | 工具 | 系统 | 办公 | 聊天 | 多媒体 | 网页 | 运营 | 平面 | 欣赏 | 数据库 | 程序 | 服务器 | 组网
网页 | 3dmax | Ghost | Windows Xp| Dreamweaver | photoshop | Flash | office | Alexa | Css | QQ | Asp | PHP | Jsp | Access
Flash MX 2004入门 | 网站推广策略 | CorelDRAW入门 | ASP学习 | 网站建设大师功 | Word入门
  iTbulo.com > 学院 > 网页制作教程 > 网页制作技巧 > 文章正文
网页脚本攻击防范全攻略
iTbulo.COM 2005-8-31 原野()

程序体(1)

另外,值得我们注意的是,很多站点在用户注册,或者是用户资料修改的页面上也缺少脚本的过滤,或者是只在其中之一进行过滤,注册进入后修改资料仍然可以进行脚本攻击。对用户提交的数据进行检测和过滤,程序体(2) 如下:

‘以下是过滤函数

If Instr(request("username"),"=")>0 or
Instr(request("username"),"%")>0 or
Instr(request("username"),chr(32))>0 or
Instr(request("username"),"?")>0 or
Instr(request("username"),"&")>0 or
Instr(request("username"),";")>0 or
Instr(request("username"),",")>0 or
Instr(request("username"),"'")>0 or
Instr(request("username"),"?")>0 or
Instr(request("username"),chr(34))>0 or
Instr(request("username"),chr(9))>0 or
Instr(request("username"),"?K")>0 or
Instr(request("username"),"$")>0 or
Instr(request("username"),">")>0 or
Instr(request("username"),"<")>0 or
Instr(request("username"),"""")>0 then
response.write "朋友,你的提交用户名含有非法字符,请更改,谢谢合作 <a href='****:window.history.go(-1);'>返回</a>"
response.end
end if

程序体(2)

为了提供工作效率我们再将过滤内容程序化,这样对多个参数的过滤效率将有很大程度上的提高:如

程序体(3)

‘以下为程序主体

dim Bword(18)
Bword(0)="?"
Bword(1)=";"
Bword(2)=">"
Bword(3)="<"
Bword(4)="-"
Bword(5)="’"
Bword(6)="””"
Bword(7)="&"
Bword(8)="%"
Bword(9)="$"
Bword(10)="'"
Bword(11)=":"
Bword(12)=" "
Bword(13)="("
Bword(14)=")"
Bword(15)="--"
Bword(16)=" chr(9)"
Bword(17)=" chr(34)"
Bword(18)=" chr(32)"
errc=false

‘以下是应用实例部分

for i= 0 to ubound(Bword)
if instr(FQYs,Bword(i))<>0 then
errc=true
end if
next
if errc then
response.write "<script language=""****"">"
response.write "parent.alert('很抱歉!您的操作违法了);"
response.write "history,back();"
response.write "</script>"
response.end
end if

上一页  [1] [2] [3] [4] [5] [6] 下一页

文章搜索
相关资讯
相关文章 相关下载
没有相关文章
焦点信息