过滤非法字符,防止注入式攻击等
2014-01-23 14:49
309 查看
/// <summary> /// 过滤字符 /// </summary> public static string Filter(string sInput) { if (sInput == null || sInput.Trim() == string.Empty) return null; string sInput1 = sInput.ToLower(); string output = sInput; string pattern = @"*|and|exec|insert|select|delete|update|count|master|truncate|declare|char(|mid(|chr(|'"; if (Regex.Match(sInput1, Regex.Escape(pattern), RegexOptions.Compiled | RegexOptions.IgnoreCase).Success) { throw new Exception("字符串中含有非法字符!"); } else { output = output.Replace("'", "''"); } return output; }
相关文章推荐
- 过滤非法字符,防止注入式攻击等
- 过滤非法字符,防止注入式攻击等
- 过滤sql中非法字符防注入式攻击方法
- 防止SQL注入,过滤非法字符的方法
- jsp过滤非法字符输入,防止XSS跨站攻击
- java过滤请求参数中的非法字符,防止XSS攻击、SQL盲注等
- jsp过滤非法字符输入,防止XSS跨站攻击
- 防止javascript 注入攻击 js过滤特殊字符
- jsp过滤非法字符输入,防止XSS跨站攻击
- jsp过滤非法字符输入 防止XSS跨站攻击
- php:输入值/表单提交参数过滤,防止sql注入或非法攻击的方法
- asp.net中过滤非法字符防止SQL注入
- asp.net中过滤非法字符防止SQL注入
- php&nbsp;过滤非法字符&nbsp;与过滤html&nbsp;js&nbsp;c…
- 在ASP.NET中防止注入式攻击
- asp 过滤非法字符函数
- 过滤非法字符(脏字)的类
- 过滤SQL非法字符
- ThinkPHP 3.2 开放 cache注缓存,过滤非法字符
- C#过滤非法字符