最近做了一个网站,数据库采用SQL2000,也被(<script src=http://3b3.org/c.js></script>)多次注入功击.
估计是数据库密码被人盗了,后来进行了连接串加密,还是被功击,
后来又有DELPHI写DLL文件来加加密连接串,一样被功击。现在用加密文件来保存连接串,并且文件路在传参时已进行加密,解密是用DELPHI写的DLL来处理的,还是被功击,小弟无语了,望高手支招。谢谢!

解决方案 »

  1.   

    跟链接字符串无关,
    参数化SQL
      

  2.   

    建议看下SQL注入专题
    http://topic.csdn.net/u/20081205/09/3dd06076-bcbe-45d4-998c-8999fdbe6fae.html?75869
      

  3.   

    在global 里添加判断,防止SQL注入
    操作数据库用存储过程
     void Application_BeginRequest(Object sender, EventArgs e)
        {
            StartProcessRequest();    }
        private void StartProcessRequest()
        {
            try
            {
                string getkeys = "";
                string sqlErrorPage = "index.aspx";
                if (System.Web.HttpContext.Current.Request.QueryString != null)
                {                for (int i = 0; i < System.Web.HttpContext.Current.Request.QueryString.Count; i++)
                    {
                        getkeys = System.Web.HttpContext.Current.Request.QueryString.Keys[i];
                        if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.QueryString[getkeys]))
                        {
                            System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage);
                            System.Web.HttpContext.Current.Response.End();
                        }
                    }
                }
                if (System.Web.HttpContext.Current.Request.Form != null)
                {
                    for (int i = 0; i < System.Web.HttpContext.Current.Request.Form.Count; i++)
                    {
                        getkeys = System.Web.HttpContext.Current.Request.Form.Keys[i];
                        if (getkeys == "__VIEWSTATE") continue;
                        if (!ProcessSqlStr(System.Web.HttpContext.Current.Request.Form[getkeys]))
                        {
                            System.Web.HttpContext.Current.Response.Redirect(sqlErrorPage);
                            System.Web.HttpContext.Current.Response.End();
                        }
                    }
                }
            }
            catch
            {        }
        }
        private bool ProcessSqlStr(string Str)
        {
            bool ReturnValue = true;
            try
            {
                if (Str.Trim() != "")
                {
                    string SqlStr = "exec¦insert¦select¦delete¦master¦update¦truncate¦declare";
                    string[] anySqlStr = SqlStr.Split('¦');
                    foreach (string ss in anySqlStr)
                    {
                       if(!Str.ToLower().Contains("updatepanel"))
                       {
                        if (Str.ToLower().IndexOf(ss) >= 0)
                        {
                            ReturnValue = false;
                            break;
                        }
                       }
                    }
                }
            }
            catch
            {
                ReturnValue = false;
            }
            return ReturnValue;
        }
      

  4.   

    是sql注入? 
    把sql放到存储过程
      

  5.   

    我把SQL语句进行过滤处理过。但还是不行。
    难道就一定要写存储过程来处理吗?
      

  6.   

    你的sql注入,是因为程序中存在拼接sql的sql语句吧...