当前位置: 首页 > 图文教程 > 网络安全 > 安全基础 > 网页脚本攻击防范全攻略(2)

安全基础
网管技术:常见BIOS报错信息及解决方法
分布式拒绝服务(DDOS)攻击及防范研究
四种宽带接入方式及其传输速率
网管必读 解读无线网络的七大安全困惑
经验:识别系统的非法进程及剿杀
全面清除系统垃圾的方法
QQ、网游等账号防盗防骗的实用小经验
上网前保证Windows XP系统安全的办法
七种DDoS攻击技术方法简介
硬盘与内存检测 四种查毒绝招
当网站注册时输入验证码总是不正确解决方法
不让自己的秘密留在别人的电脑中
IE崩溃遭难不求人 快速简单处理方法
损招 让应用程序莫名其妙地失效
不再弹广告 破除隐身僵尸木马的隐身妖术
利用QQ传播 网络欺骗“绑架”奥运会
渗透测试的攻与守 认清网络面临的问题
手动剿杀“上兴远程控制”木马
个人电脑防黑客入侵八准则
关注Windows系统服务中的安全隐患

安全基础 中的 网页脚本攻击防范全攻略(2)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-28   浏览: 30 ::
收藏到网摘: n/a

 程序体(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