微软ASP.NET 最新漏洞的解决方案
2010-09-21 11:03 音乐让我说 阅读(354) 评论(0) 收藏 举报在web.config 中配置:
<configuration>
   <system.web>
     <customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/error.aspx" />
   </system.web>
</configuration>
其中 ASP.NET V3.5SP1 以下版本没有 属性“redirectMode”,所以可以不用配置。
error.aspx 页面代码如下:
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<%@ Import Namespace="System.Threading" %>
<script runat="server">
   void Page_Load() {
      byte[] delay = new byte[1];
      RandomNumberGenerator prng = new RNGCryptoServiceProvider();
      prng.GetBytes(delay);
      Thread.Sleep((int)delay[0]);
        
      IDisposable disposable = prng as IDisposable;
      if (disposable != null) { disposable.Dispose(); }
    }
</script>
<html>
<head runat="server">
    <title>Error</title>
</head>
<body>
    <div>
        抱歉,访问出错!
    </div>
</body>
</html>
直接放在网站根目录,可以不用编译。
参考了 http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx
谢谢浏览!
    作者:音乐让我说(音乐让我说 - 博客园)
    
    出处:http://music.cnblogs.com/
    文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
                
            
        
浙公网安备 33010602011771号