ASP.net防SQL注入(简单)
来源:互联网 发布:淘宝买亚航行李托运 编辑:程序博客网 时间:2024/05/29 08:17
一,验证方法
/// <summary>
///SQL注入过滤
/// </summary>
/// <param name="InText">要过滤的字符串</param>
/// <returns>如果参数存在不安全字符,则返回true</returns>
public static bool SqlFilter2(string InText)
{
string word="and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join";
if(InText==null)
return false;
foreach(string i in word.Split('|'))
{
if((InText.ToLower().IndexOf(i+" ")>-1)||(InText.ToLower().IndexOf(" "+i)>-1))
{
return true;
}
}
return false;
}
二,Global.asax 事件
/// <summary>
/// 当有数据时交时,触发事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_BeginRequest(Object sender, EventArgs e)
{
//遍历Post参数,隐藏域除外
foreach(string i in this.Request.Form)
{
if(i=="__VIEWSTATE")continue;
this.goErr(this.Request.Form[i].ToString());
}
//遍历Get参数。
foreach(string i in this.Request.QueryString)
{
this.goErr(this.Request.QueryString[i].ToString());
}
}
三,Global中的一个方法
/// <summary>
/// 校验参数是否存在SQL字符
/// </summary>
/// <param name="tm"></param>
private void goErr(string tm)
{
if(WLCW.Extend.CValidity.SqlFilter2(tm))
this.Response.Redirect("/error.html");
}
- ASP.net防SQL注入(简单)
- ASP.net防SQL注入(简单)
- 简单的ASP.net防SQL注入
- 简单的ASP.net防SQL注入
- 简单的ASP.net防SQL注入
- 简单的ASP.net防SQL注入
- ASP.net防SQL注入(简单)
- ASP.net防SQL注入(简单)
- ASP.net防SQL注入
- ASP.net防SQL注入
- asp.net 防SQL注入
- ASP.net简单的防SQL注入代码
- ASP.net简单的防SQL注入代码
- ASP.net简单的防SQL注入代码
- (转)asp.net 防sql注入 .net防sql
- asp.net防SQL注入的安全措施
- ASP.NET防SQL注入脚本程序
- asp.net的sql防注入
- 文件上传
- NET防SQL注入方法
- souapp搜应用网:放弃IE浏览器的用户,你的网站能做到吗?
- JBPM中部署到SSH框架中
- C语言 GDI绘图学习目标设定
- ASP.net防SQL注入(简单)
- Axis WebService服务端发布
- linux下的socket编程
- MS-SQL 2005 组建和服务及工具介绍
- 学习Oracle
- 从程序员的角度来看DNA
- c++ 中的fill 和memset
- @import url,css
- VMware 下 Linux 利用虚拟光驱安装 VMware Tools 详解