多语言展示
当前在线:587今日阅读:103今日分享:49

漏洞扫描去除服务器信息头

IIS删除http header信息,Server版本信息、X-Powered-By和X-AspNet-Version
工具/原料
1

Windows系统、IIS管理器

2

Visual Studio 2012

方法/步骤
1

一、去除Server版本信息(1)集成模式新建一个类文件,文件请求加载时,去除Server信息,代码如下:using System;using System.Web;using BeidaSoft.ezWeb.Action;using BeidaSoft.ezWeb.Extentions;namespace MyWeb{    public class RemoveServerInfoModule : IHttpModule    {        #region IHttpModule Members        public void Dispose()        {            //no code nescessary        }        public void Init(HttpApplication context)        {            context.PreSendRequestHeaders += new  EventHandler(context_PreSendRequestHeaders);        }        void context_PreSendRequestHeaders(object sender, EventArgs e)        {            // strip the 'Server' header from the current Response            try            {                HttpApplication app = sender as HttpApplication;                if (null != app && null != app.Request && !app.Request.IsLocal &&  null != app.Context && null != app.Context.Response)                {                    var headers = app.Context.Response.Headers;                    if (null != headers)                    {                        headers.Remove('Server');                    }                }            }            catch (Exception ex)            {                //Log.HandleException(ex);            }        }        #endregion    }}

2

然后配置web.config文件,代码如下:   

3

(2)经典模式①安装URLscan,安装成功后,打开iis,点击对应网站,选择ISAPI筛选器,保证出现一条URLscan的记录

4

②打开目录C:\Windows\System32\inetsrv\urlscan,编辑UrlScan.ini文件;    a.AllowHighBitCharacters=1    b.AllowDotInPath=1    c.RemoveServerHeader=1

5

二、修改X-Powered-By      打开IIS,点一个站点,再点HTTP响应标头.双击你要修改的如“X-Powered-By”双击,修改成你想要的数据,也可以直接删除。

6

三、修改X-AspNet-Version      在站点的web.config文件下的结点下添加:,如果已经有此节点,那么添加属性:enableVersionHeader='false' 即可

注意事项

修改URLscan文件时,可根据个人系统网站文件命名等,修改文件内容,具体属性解释,查看相关文档即可

推荐信息