web 安全技术首次发布
跨站脚本攻击防御
This commit is contained in:
39
XSSAttachs/TestXSSAttacksFilterSite/Test.aspx.cs
Normal file
39
XSSAttachs/TestXSSAttacksFilterSite/Test.aspx.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
//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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user