资料来源:网络整理
时间:2023/2/14 0:54:17 共计:3625 浏览
//判断是否存在sql攻击
//input 用户提交的数据
//true-存在攻击规则 false-没有攻击规则
public bool CheckSqlHacker(string inputStr)
{
string SqlStr = @"and|or|exec|execute|insert|select|delete|update|alter|create|drop|count|\*|chr|char|asc|mid|substring|master|truncate|declare|xp_cmdshell|restore|backup|net +user|net +localgroup +administrators";
try
{
if (inputStr != null && inputStr != string.Empty)
{
string str_Regex = @"\b(" + SqlStr + @")\b";
Regex regex = new Regex(str_Regex, RegexOptions.IgnoreCase);
if (regex.IsMatch(inputStr))
{
return true;
}
}
}
catch
{
return true;
}
return false;
}

版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。