1、隐藏服务器系统信息
当登陆到linux系统时,会显示该linux发行版的名称、版本、内核版本、服务器的名称。为了不让这些默认的信息显示出来,我们设置它只显示一个”login:”提示符。
删除/etc/issue和/etc/issue.net这两个文件。
本地登陆输入用户名和密码前显示的信息写在/etc/issue,当然,在这个文件你也可以写入其它的信息。
而/etc/issue.net是供telnet远端登入显示的信息,内容与/etc/issue是一样的。
issue文件中的参数
\d 本地端时间的日期;
\l 显示第几个终端机介面;
\m 显示硬体的等级 (i386/i486/i586/i686…);
\n 显示主机的网路名称;
\o 显示 domain name;
\r 作业系统的版本 (相当于 uname -r)
\t 显示本地端时间的时间;
\s 作业系统的名称;
\v 作业系统的版本。
登陆系统后的显示信息是保存在/etc/motd文件中,默认为空。
2、服务软件版本信息屏蔽
通过 curl 命令 查看服务器提供HTTP服务的相关信息,可以显示出服务器的HTTP是什么程序,哪个版本,如:
[root@r1 ~]# curl -I 192.168.0.103
HTTP/1.1 200 OK
Date: Sat, 21 May 2011 13:26:56 GMT
Server: Apache/2.2.3 (Red Hat)
X-Powered-By: PHP/5.1.6
Set-Cookie: PHPSESSID=uoe9ar9mc470njdlp1litrjr37; path=/
Connection: close
Content-Type: text/html; charset=utf-8
根据提示显示用了apache 2.2.3版本,系统是redhat,php版本为5.1.6。
隐藏apache版本信息:
编辑 httpd.conf:
ServerTokens ProductOnly (默认为OS,显示操作系统信息)
ServerSignature Off (一般在页面出现问题时,底部显示的信息)
比如404错误信息:
Not Found
The requested URL /a.html was not found on this server.
Apache/2.2.3 (Red Hat) Server at 192.168.0.103 Port 80
修改后再次测试:
[root@r1 conf]# curl -I 192.168.0.103
HTTP/1.1 200 OK
Date: Sat, 21 May 2011 13:51:30 GMT
Server: Apache //web服务器版本号系统厂商隐藏
X-Powered-By: PHP/5.1.6
Set-Cookie: PHPSESSID=rs4q0jm73ph17llmppn99kb3k0; path=/
Connection: close
Content-Type: text/html; charset=utf-8
404错误页错误提示:
Not Found
The requested URL /a.html was not found on this server.
如果想隐藏橙色部分 Server: Apache,需要修改源代码,将ap_release.h文件中浅绿色部分修改:
#define AP_SERVER_BASEVENDOR “Apache Software Foundation”
#define AP_SERVER_BASEPROJECT “Apache HTTP Server”
#define AP_SERVER_BASEPRODUCT “VENUS”
#define AP_SERVER_MAJORVERSION_NUMBER 2 //版本号
#define AP_SERVER_MINORVERSION_NUMBER 2
#define AP_SERVER_PATCHLEVEL_NUMBER 22
#define AP_SERVER_DEVBUILD_BOOLEAN 0
隐藏Nginx版本信息:
开启 nginx.conf,在http { }里加上:
server_tokens off;
隐藏php-fpm版本信息(未测):
编辑php-fpm配置文件:
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改为:
fastcgi_param SERVER_SOFTWARE nginx0.0.0; #(这个nginx0.0.0就是显示的内容)
隐藏PHP版本信息:
编辑php.ini :
expose_php = Off //重新启动 Apache或者php-fpm即可。
测试:
[root@r1 conf]# curl -I 192.168.0.103
HTTP/1.1 200 OK
Date: Sat, 21 May 2011 13:54:15 GMT
Server: Apache
Set-Cookie: PHPSESSID=hgt5rq69ftu0sg1s0lg5tni620; path=/
Connection: close
Content-Type: text/html; charset=utf-8
我们看到X-Powered-By: PHP/5.1.6信息隐藏了。
原创文章,转载请注明。本文链接地址: https://www.rootop.org/pages/474.html