码迷,mamicode.com
首页 > 数据库 > 详细

sql注入过滤的公共方法

时间:2015-10-30 00:45:02      阅读:527      评论:0      收藏:0      [点我收藏+]

标签:

/// <summary>

       ///SQL注入过滤

       /// </summary>

       /// <param name="InText">要过滤的字符串</param>

       /// <returns>如果参数存在不安全字符,则返回true</returns>

       public static bool SqlFilter(string InText)

        {

           string word = "and|exec|insert|select|delete|update|chr|mid|master|or|truncate|char|declare|join|drop|table";

           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;

        }

 

sql注入过滤的公共方法

标签:

原文地址:http://www.cnblogs.com/myblogslh/p/4922209.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!