过滤iframe
㈠ 怎么过滤html标签
过滤html标签代码如下:
public string checkStr(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);
System.Text.RegularExpressions.Regex regex6 = new System.Text.RegularExpressions.Regex(@"\<img[^\>]+\>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex7 = new System.Text.RegularExpressions.Regex(@"</p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex8 = new System.Text.RegularExpressions.Regex(@"<p>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
System.Text.RegularExpressions.Regex regex9 = new System.Text.RegularExpressions.Regex(@"<[^>]*>", 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
html = regex6.Replace(html, ""); //过滤frameset
html = regex7.Replace(html, ""); //过滤frameset
html = regex8.Replace(html, ""); //过滤frameset
html = regex9.Replace(html, "");
html = html.Replace(" ", "");
html = html.Replace("</strong>", "");
html = html.Replace("<strong>", "");
return html;
}
㈡ JSP登录的session在iframe里面过期之后,过滤器或者拦截器的作用会把登录页面显示在iframe的子窗口。
<script type="text/javascript">
// 登录页面若在框架内,则跳出框架
if (self != top) {
top.location = self.location;
};
</script>
㈢ 我的ASP网站被注入iframe,请问如何写过滤代码最好能给个例子!
过滤 过滤iframe 过滤on事件
public static String wipeScript(String html) {
String regex1 = "<script[\\s\\S]+</script *>";
String regex2 = " href *= *[\\s\\S]*script *:";
String regex3 = " on[\\s\\S]*=";
String regex4 = "<iframe[\\s\\S]+</iframe *>";
String regex5 = "<frameset[\\s\\S]+</frameset *>";
Pattern pat = Pattern.compile(regex1 + "|" + regex2 + "|" + regex3
+ "|" + regex4 + "|" + regex5, Pattern.CASE_INSENSITIVE);
Matcher m = pat.matcher(html);
html = m.replaceAll("");
html = html.replaceAll(regex2, ""); // 过滤href=javascript: (<A>) 属性
html = html.replaceAll(regex3, "_disibledevent=");// 过滤其它控件的on...事件
html = html.replaceAll(regex4, ""); // 过滤iframe
html = html.replaceAll(regex5, ""); // 过滤frameset
return html;
}
㈣ 急,如何去掉<iframe ></Iframe>标签和标签里面的动态内容
把里面动态联接地址给删除
㈤ 正则表达式 去掉 ifrAme
<ifRame src=_blank Width=0 Name='[0-9]{4}' height=0></iframe>
然后在替换里忽略大小写就可以了
学正则还可以上我网站,优文网络,共同交流..
㈥ java怎么过滤“<”“>”“script”“iframe”等危险标签
你是想防止脚本注入吗?
比较好的方法是把<和>替换成转义字符.
这样好处回(1)用户体验好,善意答的用户看来,输入的是什么显示的还是什么(2)可以防止多数脚本注入(3)工作量小,只用控制住<和>就可以了(4)可以解决一些纯过滤解决不了的问题,比如<sscriptcript>这种恶意脚本,去除了script之后反而成全了攻击者.而[转义<]sscriptcript[转义>]是没有问题的
㈦ uEditor编辑器怎么取消对 iframe标签的过滤
提交时用escape把字符抄串编码,输出时unescape再解码 自己网络html实体字符,进行替换 修改php 比较推荐1,而且编码之前可以自己把危险标签去掉,比如iframe和script 1,2用js在表单的onsubmit里完成
㈧ CuteEditor编辑器插入iframe被过滤
配置一下编辑器。一般编辑器出于安全起见,会过滤一些标签(比如iframe是一个经常被过滤的标回签,几乎所答有可视化编辑器都会默认过滤)。具体怎么配置来允许这个标签,查阅一下编辑器配置吧,这个CUteEditor我木有用过。
㈨ 用正则表达式排除javascript标签内容中含有iframe的字符串,iframe不区分大小写
<script>(?!(?:(?!</script>)[sS])*?iframe)(?:(?!</script>)[sS])*</script>
㈩ html中iframe的过滤问题
可以的。
你可以在A中编写Javascript脚本
top.***可以得到B的一些属性。比如top.location 可以得到地址
你可回以写一个答判断语句,根据不同的条件document.write()出不同的内容。