Files
web-security/XSSAttachs/TestXSSAttacksFilterSite/Test.aspx.cs
JacksonBruce 868088c104 web 安全技术首次发布
跨站脚本攻击防御
2015-02-20 13:02:57 +08:00

39 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//using org.owasp.validator.html;
using StyleSheetsParser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XSSAttacksFilter;
namespace TestXSSAttacksFilterSite
{
public partial class Test : System.Web.UI.Page
{
//HtmlFilter antisamy;
//Policy policy = null;
//string filename = @"/resources/antisamy.xml";
public StringBuilder html;
protected void Page_Load(object sender, EventArgs e)
{
}
void FilterAttacks(string str, Func<string, bool> fn=null,[CallerMemberName] string propertyName = null)
{
html.Append("\n== in == "+propertyName+" ==================================================\n原文:\n" + str + "\n");
//html.Append("====================================================================================================");
html.Append("JavaScript\n" + ((RichText)str).JavascriptEncode);
html.Append("\n过滤:\n" + ((RichText)str));
html.Append((fn == null ? null : "\n状态" + (fn(str) ? "成功!" : "失败")));
}
protected void btn_Click(object sender, EventArgs e)
{
html = new StringBuilder();
FilterAttacks(txt.Text);
}
}
}