zoukankan      html  css  js  c++  java
  • C# 特殊字符过滤拦截

     public static string ReplaceSQLChar(string str)
            {
                if (str == String.Empty)
                    return String.Empty;
                str = str.Replace("'", "");
                str = str.Replace(";", "");
                str = str.Replace(",", "");
                str = str.Replace("?", "");
                str = str.Replace("<", "");
                str = str.Replace(">", "");
                str = str.Replace("(", "");
                str = str.Replace(")", "");
                str = str.Replace("=", "");
                str = str.Replace("+", "");
                str = str.Replace("*", "");
                str = str.Replace("&", "");
                str = str.Replace("#", "");
                str = str.Replace("%", "");
                str = str.Replace("$", "");
                //删除与数据库相关的词
                str = Regex.Replace(str, "select", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "insert", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "delete from", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "count", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "drop table", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "truncate", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "asc", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "mid", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "char", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "xp_cmdshell", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "exec master", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "net localgroup administrators", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "and", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "net user", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "or", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "net", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "delete", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "drop", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "script", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "update", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "and", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "chr", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "master", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "truncate", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "declare", "", RegexOptions.IgnoreCase);
                str = Regex.Replace(str, "mid", "", RegexOptions.IgnoreCase);
                return str;
            }
  • 相关阅读:
    【彩彩只能变身队】后端工作总结
    彩彩只能变身队团队项目进展记录by后端
    一周工作+会议汇报(6.3)
    【彩彩只能变身队】第七次会议
    【彩彩只能变身队】第六次会议
    这个博客正式废用了!!!!搬家了!!!!
    [软件工程]一些不错的学习网站
    NWERC 2015 Problem H: Hole in One
    HDU 5970 CCPC2016合肥 求等差数列整除整数下取整求和
    [软件工程]python 发送邮件网易邮箱163示范
  • 原文地址:https://www.cnblogs.com/BlackAgg/p/13255453.html
Copyright © 2011-2022 走看看