隐藏apache的版本信息

装逼爱好者
2013-10-13 / 0 评论 / 13 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2020年09月03日,已超过1323天没有更新,若内容或图片失效,请留言反馈。

apache的http header和错误页面或多或少的会透露一些软件和系统的版本信息,对于生产服务来说这些东西是毫无用处的并且还有可能会被人利用分析.

#curl -I 127.0.0.1
HTTP/1.1 200 OK
Date: Sun, 13 Oct 2013 13:03:18 GMT
Server: Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips DAV/2
Last-Modified: Wed, 14 Nov 2012 07:16:01 GMT
X-Powered-By: PHP/5.3.24
ETag: "32006-10-4ce6f4e86ee40"
Accept-Ranges: bytes
Content-Length: 16
Content-Type: text/html

通过修改apache的配置可以不显示它们

cat >>/etc/httpd/conf/httpd.conf<<EOF
ServerTokens ProductOnly
ServerSignature Off
EOF

ServerTokens缺省值OS名称,ServerSignature缺省值是apache的版本号。
解决了apache的问题顺道干掉php版本的输出显示

sed -i 's#expose_php = On#expose_php = Off#' /etc/php.ini

expose_php默认值是On将其关闭http header就不会输出php版本了。
调整完参数重启httpd就生效了。

调整参数生效后的http header信息

curl -I 127.0.0.1
HTTP/1.1 200 OK
Date: Sun, 13 Oct 2013 13:28:25 GMT
Server: Apache
Last-Modified: Wed, 14 Nov 2012 07:16:01 GMT
ETag: "32006-10-4ce6f4e86ee40"
Accept-Ranges: bytes
Content-Length: 16
Content-Type: text/html

PS:以上apache和php的配置文件均为常规配置路径,如果您是自定义安装请注意更换路径。

0

评论 (0)

取消