检验危险字符串 防止SQL注入
来源:互联网 发布:sql必知必会 pdf 编辑:程序博客网 时间:2024/05/24 02:37
#region 检查危险字符
/// <summary>
/// 检查危险字符
/// </summary>
/// <param name="Input"></param>
/// <returns></returns>
public static string Filter(string sInput)
{
if (sInput == null || sInput == "")
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;
}
#endregion
/// <summary>
/// 检查危险字符
/// </summary>
/// <param name="Input"></param>
/// <returns></returns>
public static string Filter(string sInput)
{
if (sInput == null || sInput == "")
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;
}
#endregion
- 检验危险字符串 防止SQL注入
- php过滤html字符串,防止SQL注入
- php防止sql注入,字符串变量检查
- java 防止SQL注入 字符串过滤
- 如何有效的防止SQL连接字符串注入
- PHP中通过转义字符串防止SQL注入攻击
- 浅析php过滤html字符串,防止SQL注入的方法
- 浅析php过滤html字符串,防止SQL注入的方法
- PHP防止数据库字符串登录SQL注入攻击
- 防止sql注入
- asp 防止SQL注入
- sql注入防止办法
- sql注入防止办法
- 怎么防止[SQL注入
- 如何防止SQL注入
- 防止sql注入
- SQL注入防止攻击
- 防止sql注入攻击
- Courses in Bioinformatics
- 用POI HSSF处理EXCEL表格
- Android 压力测试
- Oracle 启动监听命令
- Linux开发工具和Windows开发工具对比
- 检验危险字符串 防止SQL注入
- 《支撑处理器的技术——永无止境地追求速度的世界》图书信息
- C语言中mktime函数功能及用法
- 西南石油大学第三届信息安全大赛-破解1-easy
- 关于reverse_iterator
- inet_aton和inet_network和inet_addr三者比较
- plsql developer打开字段值出现无效的窗口句柄解决方法
- android之handler 传送非原生类数据
- java多线程 sleep()和wait()的区别