天天看點

一起談.NET技術,ASP.NET 安全漏洞臨時解決方案

  在ASP.NET 1.1 到 ASP.NET 3.5中,可以通過在Web.config中建立<customErrors>節點來解決,注意,ErrorMode必須設定為On,且對于所有的錯誤都轉向同一個錯誤頁,主要是防止攻擊者根據不同的錯誤也跳轉來猜測伺服器發生了什麼錯誤:

  在ASP.NET 3.5 SP1到ASP.NET 4.0中,在Web.config中建立<customErrors>節點,設定ErrorMode為On,設定RedirectMode模式為ResponseRewrite,對于所有的錯誤跳轉到同一個錯誤頁:

  并且ScottGu還建議在錯誤頁的Page_Load()事件中加上如下代碼:

prng.GetBytes(delay);

Thread.Sleep((int)delay[0]);

IDisposable disposable = prng as IDisposable;

if (disposable != null){ disposable.Dispose(); }

}

</script>

<html>

<head id="Head1" runat="server">

<title>Error</title>

</head>

<body>

<div>

An error occurred while processing your request.

</div>

</body>

</html>

  參考資訊:

繼續閱讀