zoukankan      html  css  js  c++  java
  • XSS漏洞字符串过滤 狼

            public string wipescript(string html)
            {
              
                System.Text.RegularExpressions.Regex regex1 = new System.Text.RegularExpressions.Regex(@"<script[\s\s]+</script *>",  System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                System.Text.RegularExpressions.Regex regex2 = new System.Text.RegularExpressions.Regex(@" href *= *[\s\s]*script *:",  System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                System.Text.RegularExpressions.Regex regex3 = new System.Text.RegularExpressions.Regex(@" on[\s\s]*=",  System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                System.Text.RegularExpressions.Regex regex4 = new System.Text.RegularExpressions.Regex(@"<iframe[\s\s]+</iframe *>",  System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                System.Text.RegularExpressions.Regex regex5 = new System.Text.RegularExpressions.Regex(@"<frameset[\s\s]+</frameset *>",  System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                html = regex1.Replace(html, ""); //过滤<script></script>标记
                html = regex2.Replace(html, ""); //过滤href=javascript: (<a>) 属性
                html = regex3.Replace(html, " _disibledevent="); //过滤其它控件的on...事件
                html = regex4.Replace(html, ""); //过滤iframe
                html = regex5.Replace(html, ""); //过滤frameset
                return html;
            }
  • 相关阅读:
    QinQ基础知识
    mysql执行sql脚本时--force的作用
    docker的thin pool 和 ulimit问题
    使用MAT来进行java内存问题的简单分析
    自己对DHCP的理解
    根据类名找jar包和maven坐标
    curl在windows下和linux中使用的一个区别
    JAVA实现LRU算法
    经典买票并发
    AQS学习
  • 原文地址:https://www.cnblogs.com/gowhy/p/2089208.html
Copyright © 2011-2022 走看看