zoukankan      html  css  js  c++  java
  • 防止SQL注入

     1   /// <summary>
     2    /// 过滤SQL注入
     3    /// </summary>
     4    /// <param name="strSQL"></param>
     5    /// <returns></returns>

     6    public static bool CheckSQLInjection(string strSQL)
     7    {
     8        if (string.IsNullOrEmpty(strSQL))
     9        {
    10            return true;
    11        }

    12        else
    13        {
    14            Regex RegExpression = new Regex(@"\s");
    15            strSQL = RegExpression.Replace(strSQL.Trim().Trim().ToLower().Replace("%20"" "), " ");
    16            string Pattern = @"select |insert |delete from |count\(|drop table|update |truncate |asc\(|mid\(|char\(|xp_cmdshell|exec master|net localgroup administrators|:|net user|""|\'| or ";
    17
    18            if (Regex.IsMatch(strSQL, Pattern))
    19            {
    20                return false;
    21            }

    22            else
    23            {
    24                return true;
    25            }

    26        }

    27    }
  • 相关阅读:
    google 以图搜图
    一个idear
    负责
    腾讯笔试
    迅雷笔试题
    如何删除表中重复的字段
    sed的使用
    C++ Html解析器HtmlCxx用户手册和源代码解析
    makefile从无到有
    深入理解函数指针
  • 原文地址:https://www.cnblogs.com/zijinguang/p/1120820.html
Copyright © 2011-2022 走看看