天涯之外

导航

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

最近很多网站数据库被挂马,出现类似 "> </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;
                        }
                }
        }

posted on 2009-03-27 14:12  天涯之外  阅读(372)  评论(0编辑  收藏  举报