在服务器上发现很多攻击历史,可以看到黑客在不断尝试攻击,难怪现在肉鸡泛滥。由于网站没有时间及时更新web server到最新版本,你又不知道哪天有什么安全漏洞,比较好的办法是把web服务器类型隐藏,增加黑客攻击的难度。正如Web服务器对比分析(Apache、Lighttpd、Nginx)中的第四部分-各大网站WEB服务器资源列表中看到的,google的web
server是gws,baidu的web server是bws,土豆的web server是tws。我们来看一下google和百度的:
执行以下命令:curl -I www.google.com,你会看到如下输出:
HTTP/1.1 302 Found Location: http://www.google.com.hk/url?sa=p&hl=zh-CN&cki=PREF%3DID%3Dee1a72a85f94958c:FF%3D2:LD%3Dzh-CN:NW%3D1:TM%3D1285224594:LM%3D1285224594:S%3D3sp0lsofWJzalAF_&q=http://www.google.com.hk/&ust=1285224624460296&usg=AFQjCNHMm-ZEpahCT9zqeSspJosMij_KMg Cache-Control: private Content-Type: text/html; charset=UTF-8 Set-Cookie: PREF=ID=ee1a72a85f94958c:NW=1:TM=1285224594:LM=1285224594:S=rT2KjFqfVLT_wsd1; expires=Sat, 22-Sep-2012 06:49:54 GMT; path=/; domain=.google.com Set-Cookie: NID=39=lc9ZcHtyHvzoklMqHetgd5xfmU-Rn6oHdZCKMayCh2i2RyTIT02LtTyGwyNrtFps3hregnJoIyDNTDXBQu2fj6EmyS1m0Pn6xuyP05Sc_BLNlwXFmEdjSL6jRSMVwSYZ; expires=Fri, 25-Mar-2011 06:49:54 GMT; path=/; domain=.google.com; HttpOnly Date: Thu, 23 Sep 2010 06:49:54 GMT Server: gws Content-Length: 458 X-XSS-Protection: 1; mode=block
百度的Web服务器伪装:
HTTP/1.1 200 OK Date: Thu, 23 Sep 2010 06:52:47 GMT Server: BWS/1.0 Content-Length: 6218 Content-Type: text/html;charset=gb2312 Cache-Control: private Expires: Thu, 23 Sep 2010 06:52:47 GMT Set-Cookie: BAIDUID=3027C9CDFBA3439A124DA4A90962BB12:FG=1; expires=Thu, 23-Sep-40 06:52:47 GMT; path=/; domain=.baidu.com P3P: CP=" OTI DSP COR IVA OUR IND COM " Connection: Keep-Alive
要进行web服务器的伪装,通常来说需要重新编译web服务器。下面介绍一下nginx如何进行操作。
重新编译nginx的服务器响应:
vi src/core/nginx.h,修改该文件如下所示:
#ifndef _NGINX_H_INCLUDED_ #define _NGINX_H_INCLUDED_ #define NGINX_VERSION "1.3" #define NGINX_VER "XWS/" NGINX_VERSION #define NGINX_VAR "XWS" #define NGX_OLDPID_EXT ".oldbin" #endif /* _NGINX_H_INCLUDED_ */
然后重新编译、安装即可。
HTTP/1.1 200 OK Server: XWS/1.3 Date: Thu, 23 Sep 2010 06:58:42 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive Set-Cookie: _jiaxiao365_session=bbab9e1d74cb53eedf64bba92320bb70; path=/ ETag: "d88f9d49382f4a49cf0c0662581ffa4a" P3P: CP="NOI DSP COR NID ADMa OPTa OUR NOR" X-Runtime: 28ms Content-Length: 34811 Cache-Control: private, max-age=0, must-revalidate