开心123 发表于 2018-11-25 12:30:44

隐藏或改变web服务器的apache的版本

  # curl --head 127.0.0.1
  HTTP/1.1 404 Not Found
  Date: Mon, 08 Oct 2012 02:00:48 GMT
  Server: Apache
  Content-Type: text/plain
  


[*]在默认情况下,系统会把Apache版本模块都显示出来(http返回头信息)。如果列举目录的话,会显示域名信息(文件列表正文)、隐藏Apache版本号的方法是修改Apache的配置文件
[*]
[*]# 这个指令控制了服务器回应给客户端的"Server:"应答头是否包含关于服务器操作系统类型和编译进的模块描述信息
[*]# 一般可用模式有以下几种默认的是 Full方式返回给客户端的头信息

[*]# curl --head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:23:19 GMT
[*]Server: Apache/2.2.3 (CentOS)
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]修改servertokens 为ServerTokens productonly的返回结果
[*]# curl --head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:26:34 GMT
[*]Server: Apache
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]
[*]修改为major返回结果
[*]# curl--head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:29:57 GMT
[*]Server: Apache/2
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]修改为minor的返回结果
[*]# curl--head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:31:13 GMT
[*]Server: Apache/2.2
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]修改为minlmal的返回结果
[*]# curl--head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:32:13 GMT
[*]Server: Apache/2.2.3
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]修改为full的返回结果
[*]# curl--head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:33:27 GMT
[*]Server: Apache/2.2.3 (CentOS) DAV/2
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]同时修改servertokens和serversinnature为off返回结果
[*]# curl--head 127.0.0.1
[*]HTTP/1.1 403 Forbidden
[*]Date: Mon, 06 Feb 2012 04:36:31 GMT
[*]Server: Apache
[*]Accept-Ranges: bytes
[*]Content-Length: 5043
[*]Connection: close
[*]Content-Type: text/html; charset=UTF-8
[*]
[*]
[*]到这点,我们还可以改变apache的版本,这就要修改apache的源代码了
[*],在apache的源码包中找到ap_release.h将
[*]#define AP_SERVER_BASEPRODUCT "Apache"
[*]
[*]修改为
[*]#define AP_SERVER_BASEPRODUCT "Microsoft-IIS/5.0”
[*]
[*]或者
[*]#define AP_SERVER_BASEPRODUCT "Microsoft-IIS/6.0”
[*]
[*]
[*]
[*]然后找到os/unix下的os.h文件,将其
[*]#define PLATFORM "Unix"
[*]
[*]修改为
[*]#define PLATFORM "Win32“
[*]
[*]然后重新编译,安装apache。
[*]最后修改httpd.conf配置文件,添加两行
[*]
[*]ServerTokens Prod
[*]ServerSignature Off
[*]
[*]在发送头请求,会有什么,就不用我说了吧,嘿嘿,这叫偷天换日,
[*]从这点来说,php也是一样,同样可以通过这种方式改变一些系统信息,不过根据
[*]GPL开源的精神,这样做貌似不太好,还是保留apache和php版权信息吧。
[*]
[*]附:
[*]ServerSignature 三个选项
[*]On|Off|EMai 主要起开关作用
[*]
[*]ServerTokens 四个选项
[*]Minimal|ProductOnly|OS|Full 四个选项隐藏信息依次增加
[*]
[*]下面对php的配置文件php.ini进行配置
[*]默认情况下
[*]expose_php = On
[*]
[*]将其改为
[*]expose_php = Off
  



页: [1]
查看完整版本: 隐藏或改变web服务器的apache的版本