关闭X-Powered-By 信息(隐藏PHP版本信息)

会暴露服务器运行的是php

修改 php.ini 文件 设置 expose_php = Off

官方给出的说明

Decides whether PHP may expose the fact that it is installed on the server
(e.g. by adding its signature to the Web server header). It is no security
threat in any way, but it makes it possible to determine whether you use PHP
on your server or not.

决定服务器上是否暴露安装有PHP,
(例如:把这些信息加到Web服务器头响应)。这是不安全的。
但能确定你的服务器时候运行着PHP。

意思就是打开的话可以告诉其他人这台服务器可以运行PHP,但不一定安全,可以关掉

隐藏或者混淆nginx返回的Server信息

1.隐藏版本号:

vi nginx.conf

在http 加上 server_tokens off;

如下:

http {
……省略配置
server_tokens off; ->即可隐藏版本号
…….省略配置
}

重启nginx后,我们返回的Server头格式为Server:nginx ,而且nginx自己的404页面也没有版本号的信息

2.返回自定义的server

混淆Server信息

我是不太愿意告诉别人我是使用什么Server的,但没有找到相关文献去隐藏它,所以我们可以混淆她,如把Server返回GFW之类的,吓唬吓唬那些脚本小子

大部分情况下,脚本的小子的扫描工具是扫描我们response返回的header中的server信息.我们可以采用编译源码的方法来改变返回的Server,笔者的版本是nginx1.7.0,我们修改src/http/ngx_http_header_filter_module.c 中的48行

static char ngx_http_server_string[] = "Server: nginx" CRLF;

把其中的nginx改为我们自己想要的文字即可,笔者就改为了GFW. 笔者输出的Server:GFW.(这个前提是你进行了第一个步句的操作,关闭了版本号)

如果你的版本号是开着的,你又想调戏下脚本小子.比如Server:billgate/1.9.0

我们修改src/core/nginx.h 定位到13-14行

#define NGINX_VERSION "1.7.0"

#define NGINX_VER "nginx/" NGINX_VERSION

Server返回的就是常量NGINX_VER, 我们把NGINX_VERSION大小定义为1.9.0,nginx改为billgate就能达到我们的目的了

标签: none

添加新评论