재우니의 블로그

 

HTTP Header 에 Sever 명 제거하기

 

asp.net 으로 개발하다보면 http header 태그에 server 의 환경이 대략 보인다.

사실 해킹 하시는 분들에게 아주 좋은 가이드를 주는 것과 동일하다.

사실 요즘 asp.net 도 mvc 기술을 제공하기 때문에 url 경로를 보고 asp.net 인지 jsp, php 인지  미리 확정지을 수 없게 만들기도 한다.

 

 

 

이를 삭제하기 위해서 이것저것 찾아봤는데... iis 6 에는 스스로 이를 수정하는 방법이 없다. 마소에서 제공하는 무료 UrlScan 유틸리티를 사용해야 가능하다고 한다.

 

 

URLScan  설치하고 나서  ISAPI Filters 에 등록해야 작동된다. 경로는 %windir%\system32\inetsrv\urlscan\urlscan.dll 이며, 해당 dll 을 add 버튼을 통해 추가 하면 된다. 그리고 UrlScan.ini 파일을 메모장으로 열어서 RemoveServerHeader 을 찾아, 값을 1 로 설정한다. (1은 활성화를 의미함)

 

URLScan tool is easy to install. Don’t forget to enable it by adding it in the ISAPI Filters (the dll is usually located at %windir%\system32\inetsrv\urlscan\urlscan.dll).

You should also make sure that you enable the RemoveServerHeader option in the UrlScan.ini file that is located next to the dll file by setting this options value to 1.

 

 

 

iis 7 입장에서 보면, asp.net 을 가동할 때 pool 환경을 통합 및 클래식으로 나눠서 관리하고 있다. 여기서 통합으로 파이프라인을 설정하고 운용할 경우, asp.net 소스 중에 global.asax.cs 단 에서 통제가 가능하다. 삭제를 할려면 remove 함수, 또는 변경을 하고자 한다면 set 함수를 사용하면 된다. 클래식은 안된단다 ㅡㅡ;

 

 

protected void Application_PreSendRequestHeaders()
{
  // Response.Headers.Remove("Server");
  Response.Headers.Set("Server","My Server");
  Response.Headers.Remove("X-AspNet-Version");
  Response.Headers.Remove("X-AspNetMvc-Version");
}

 

 

참고자료

 

https://www.saotn.org/remove-iis-server-version-http-response-header/

http://serverfault.com/questions/24885/how-to-remove-iis-asp-net-response-headers

 

 


 The Server header is automatically added to the outgoing response by IIS. To remove this header from IIS 6 or IIS 7 you can use Microsoft's free UrlScan utility.
If you are using IIS 7's integrated pipeline, you can alternatively remove the Server header programmatically by means of an HTTP Module. Stefan Grobner's blog entry, IIS 7 - How To Send A Custom "Server" HTTP Header, shows code that modifies the Server header. In a nutshell, you need to create an HTTP Module that creates an event handler for the PreSendRequestHeaders event. In that event handler you'd write code similar to the following to remove the Server header:


HttpContext.Current.Response.Headers.Remove("Server"); 


Howard von Rooijen has a similar, more in-depth account of removing the Server HTTP Header (and other identifying headers) via an HTTP Module when using IIS 7 and its integrated pipeline mode. See Cloaking your ASP.NET MVC Web Application on IIS 7 for more details.