參考地址:https://jingyan.baidu.com/article/77b8dc7fa657c26174eab631.htmlhtml
概述:站點信息偵測漏洞會檢測到用的版本信息等,而後藉此進行一些攻擊。web
解決方案app
1、隱藏MVC版本信息(節點:X-AspNetMvc-Version:)asp.net
1.在Global.asax.cs文件中添加以下代碼:spa
//隱藏MVC版本信息(節點:X-AspNetMvc-Version:) MvcHandler.DisableMvcResponseHeader = true;
再次運行,就不顯示節點:X-AspNetMvc-Version了.net
2、隱藏asp.net 版本信息(節點:X-AspNet-Version)3d
1.在配置文件中找到節點httpRuntime,添加屬性enableVersionHeader="false"code
<httpRuntime targetFramework="4.5.2" enableVersionHeader="false" />
再次運行,就不顯示節點X-AspNet-Version了htm
3、隱藏X-Powered-By節點blog
1.配置文件中找到節點httpRuntime,添加以下代碼:(若有就修改,沒有就新增)
<system.webServer> <httpProtocol> <customHeaders> <remove name="X-Powered-By" /> </customHeaders> </httpProtocol> </system.webServer>
再次運行,就不顯示節點X-AspNet-Version了
4、隱藏Server信息
在在Global.asax.cs文件中添加以下代碼:
1 /// <summary> 2 /// 隱藏/修改 Response Header 中的Server節點(IIS版本信息) 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 protected void Application_PreSendRequestHeaders(object sender, EventArgs e) 7 { 8 HttpApplication application = sender as HttpApplication; 9 if (application != null && application.Context != null) 10 { 11 //移除Server 12 application.Context.Response.Headers.Remove("Server"); 13 //修改Server的顯示信息 14 //application.Context.Response.Headers.Set("Server", "MyServer"); 15 16 //移除X-AspNet-Version,和上面效果相同 17 //application.Context.Response.Headers.Remove("X-AspNet-Version"); 18 //移除X-AspNetMvc-Version,和上面效果相同 19 //application.Context.Response.Headers.Remove("X-AspNetMvc-Version"); 20 } 21 22 }
再次運行,就不顯示節點Server了