I will show you the less hacky ones first. I.e. the ones where it is designed for you to remove them easily:
X-AspNet-Version
This can be removed simply using the enableVersionHeader attribute of the httpRuntime section of system.web section of your web.config:<system.web> <httpRuntime enableVersionHeader="false" /> <!-- other settings --> </system.web>
X-AspNetMvc-Version
In your Global.asax.cs you can add the following to your Application_Start method:protected void Application_Start(object sender, EventArgs e)
{
MvcHandler.DisableMvcResponseHeader = true;
// RegisterRoutes etc... and other stuff
}X-Powered-By
Instead of removing this I have decided to change it to something different so as not to cause suspicion to a potential hacker:<system.webServer>
<httpProtocol>
<customHeaders>
<remove name="X-Powered-By"/>
<add name="X-Powered-By" value="PHP 5.2 Ubuntu"/>
</customHeaders>
</httpProtocol>
<!-- other stuff -->
</system.webServer>Server
This one is harder since you can't actually do it anywhere else. Of course you could have changed all the other Headers here too but it feels messy doing it this way so I opted to change the others using the intended way.First, make an HttpModule (essentially a class inheriting from IHttpModule) like this:
namespace HttpModules
{
public class SecurityModule : IHttpModule
{
public void Dispose()
{
//intentionally do nothing
}
public void Init(HttpApplication context)
{
context.PreSendRequestHeaders += new EventHandler(context_PreSendRequestHeaders);
}
private void context_PreSendRequestHeaders(object sender, EventArgs e)
{
var context = ((HttpApplication)sender).Context;
context.Response.Headers.Set("Server", "Apache 2.0");
}
}
}Note: I have gone for lying about the server over removing it (which is also possible) since I'd rather fool hackers than annoy them.Next you just need to register that module in your web.config:
<system.webServer>
<modules>
<add name="SecurityModule" type="HttpModules.SecurityModule, HttpModules" />
</modules>
</system.webServer>
Now use Fiddler to have a look at your Response Headers. Hopefully wonderfully deceptive like this:If you have more to remove/change you can do it in much the same way as X-Powered-By (using web.config) or if not the Server one (using the Security HttpModule).




Yeah, you're probably right that pretending to be something else wouldn't fool anyone (but would fool any robots that are string matching these headers).
ReplyDeleteI've since changed them to remove the server name, give a brief description of the tech stack AND there's even a job ad in there too for such advanced devs ;) http://www.lovemoney.com
not working in IIS-6
ReplyDeleteThe security conscious developer knows that security through obfuscation isn't security, and instead they should keep IIS patched up regularly with Windows Update. ;)
ReplyDeletehttp://www.iis.net/learn/extensions/url-rewrite-module/modifying-http-response-headers
ReplyDeleteVery helpful post.Thanks for your information! Keep sharing.
ReplyDeleteerp software in chennai | erp providers in chennai | online events registration
nformative and impressive. Keep Updating
ReplyDeleteProgrammierung in Lüdenscheid
Very useful information and thanks for sharing. Call Of Mini: Zombies Mod Apk
ReplyDeleteFood is one of the most memorable parts of any wedding, so choosing the right catering service is important. Couples looking for reliable Caterers in Delhi can compare different options based on their menu, service quality, event size, and budget. Exploring the available choices in advance can make wedding planning much smoother.
ReplyDeleteA well-planned menu can make a wedding celebration even more enjoyable for guests. Those searching for experienced Caterers in Faridabad can explore different catering options and consider factors such as menu variety, presentation, service, and pricing before making a final decision.
ReplyDeleteSelecting a suitable caterer is an important part of organizing a successful wedding or special event. This guide can be useful for people looking for Caterers in Ghaziabad, as comparing menus, catering packages, guest capacity, and service options can help in finding a suitable choice for the occasion.
ReplyDeleteThe food and catering service can have a major impact on the overall wedding experience. Anyone planning an event and searching for Caterers in Gurgaon can explore different providers and compare their menus, specialties, presentation, and packages according to the requirements of the celebration.
ReplyDeleteGood food brings guests together and can make a wedding celebration more memorable. For those planning an event, this resource for Caterers in Noida can help in exploring catering options based on menu preferences, number of guests, budget, and the type of wedding event being organized.
ReplyDeleteSelecting a banquet hall is one of the key decisions when planning a wedding or special occasion. This guide to Banquet halls in Noida can help people explore different venue options and compare factors such as amenities, location, capacity, ambience, and catering arrangements.
ReplyDeleteDelhi offers a wide range of venues for weddings, receptions, and other celebrations. Those exploring Banquet halls in Delhi can consider factors such as guest capacity, location, décor, catering, parking, and event facilities to find a venue that fits their specific requirements.
ReplyDeleteWedding photography is an important part of preserving the special moments of a celebration. Couples searching for Wedding Photographers in Delhi can explore different professionals based on their photography style, experience, packages, and event requirements. Comparing portfolios beforehand can help in finding a suitable photographer.
ReplyDeletePlanning a private party becomes easier when you have a spacious venue with the right amenities and a comfortable setting. Those looking for Villas in Ghaziabad for Party can explore different options based on guest capacity, location, facilities, outdoor space, and budget. Comparing the available amenities beforehand can help in selecting a suitable venue.
ReplyDeleteA private villa can be a convenient option for celebrations, family gatherings, and small events where privacy and flexibility are important. People searching for Villas in Ghaziabad can compare properties based on their location, space, amenities, group size, and event requirements to find an option that suits their occasion.
ReplyDelete