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    }
  • 相关阅读:
    angularjs里对JS的lowercase和uppercase的完善
    UVA
    UVA
    MySQL 8.0X的安装与卸载命令
    回文树(模板+例题)
    UESTC
    UVALive
    BZOJ
    ACM-ICPC 2018 南京赛区网络预赛 I Skr (马拉车+hash去重)或(回文树)
    ACM-ICPC 2018 南京赛区网络预赛 E AC Challenge(状压dp)
  • 原文地址:https://www.cnblogs.com/zijinguang/p/1120820.html
Copyright © 2011-2022 走看看