在Global.asax文件中加入如下方法即可:#region SQL注入式攻击代码分析
  /// <summary>  
  /// 处理用户提交的请求  
  /// </summary>  
  private void StartProcessRequest()
  {
  try
  {
  string getkeys = "";  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.Write("<h3>不能包含执行语句</h3>");
  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]))
  {
  jcFAQApp.FAQ_Util.Log.WriteMessage("<font color:red>注入攻击</red>", System.Web.HttpContext.Current.Request.UserHostAddress.ToString());
  System.Web.HttpContext.Current.Response.Write("<h3>不能包含执行语句</h3>");
  System.Web.HttpContext.Current.Response.End();
  }
  }
  }
  }
  catch
  {  }
  }
  /// <summary>  
  /// 分析用户请求是否正常  
  /// </summary>  
  /// <param name="Str">传入用户提交数据 </param>  
  /// <returns>返回是否含有SQL注入式攻击代码 </returns>  
  private bool ProcessSqlStr(string Str)
  {
  bool ReturnValue = true;
  try
  {
  if (Str.Trim() != "")
  {
  //string SqlStr = "and |exec |insert |select |delete |update |count |* |chr |mid |master |truncate |char |declare";
  string SqlStr = "exec |insert |select |delete |update |mid |master |truncate |declare";
  string[] anySqlStr = SqlStr.Split('|');
  foreach (string ss in anySqlStr)
  {
  if (Str.ToLower().IndexOf(ss) >= 0)
  {
  ReturnValue = false;
  break;
  }
  }
  }
  }
  catch
  {
  ReturnValue = false;
  }
  return ReturnValue;
  }
  #endregion
http://topic.csdn.net/u/20090708/09/b78444ee-9081-4ff7-8aa5-ba6f9b1d9fdc.html

解决方案 »

  1.   

    我不是SQL被注入,是网页内容被改了
      

  2.   

    如果你是买的空间就没办法了,除了希望空间商有个好网管,你是一点办法都没有。要是自己的机器,你还是把没用的服务、账号全停了。不要给web文件夹everybody或users写权限。加防火墙仅提供80端口的出口。检查所有文件上传部分的代码是否有允许可执行文件或asp\aspx\asa等服务器可以运行的文件类型上传。如果使用了第三方的在线编辑器,要随时留意最新的漏洞消息和补丁消息。
      

  3.   

    网页被注入同sql注入不同,网页被修改需要取得服务器上文件的修改权限,这个跟你的服务器有关,也就是说你的服务器有漏洞,被人攻入取得文件的修改权了。
      

  4.   

    你这个应该不是 SQL注入应该是 服务器被挂马了
      

  5.   

    你在嘛??我看到你这有上海按摩的这个站。www.massagesh.info是你做的嘛?还是你朋友。我需要优化一个按摩网站。跟这个一样的。你能做的话联系我。1243247336或是直接打我手机18717729871