void Application_BeginRequest(object sender, EventArgs e)
{
bool result = false;
if (Request.RequestType.ToUpper() == "POST")
{
//post方式的我就不写了。
}
else
{
result = ValidUrlGetData();
}
if (result)
{
Response.Write("您提交的数据有恶意字符!");
Response.End();
}
}
/// <summary>
/// 获取QueryString中的数据
/// </summary>
public static bool ValidUrlGetData()
{
bool result = false;
for (int i = 0; i < HttpContext.Current.Request.QueryString.Count; i++)
{
result = Validate(HttpContext.Current.Request.QueryString[i].ToString());
if (result)
{
break;
}//如果检测存在漏洞
}
return result;
}
public static string []strs = new string[] {"select","drop","exists","exec","insert","delete","update","and","or","user" };//此处我随便加了几个,大家可以多加点哈。
public static bool Validate(string str)
{
for (int i = 0; i < strs.Length; i++)
{
if (str.IndexOf(strs[i]) != -1)
{
return true;
break;
}
}
return false;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有