• web服务器伪装

    Posted on 三月 5th, 2009 inetdemon No comments

    在服务器上发现很多攻击历史,可以看到黑客在不断尝试攻击,难怪现在肉鸡泛滥。由于个人网站没有时间及时更新web server到最新版本,你又不知道哪天有什么安全漏洞,比较好的办法是把web服务器类型隐藏,增加黑客攻击的难度。我们先看一下goolge和百度是怎么做的:

    # curl -I www.google.com
    HTTP/1.1 200 OK
    Cache-Control: private, max-age=0
    Date: Thu, 05 Mar 2009 04:01:06 GMT
    Expires: -1
    Content-Type: text/html; charset=ISO-8859-1
    Set-Cookie: PREF=ID=7087ebea8c3fcab5:NW=1:TM=1236225666:LM=1236225666:S=HYYAZJyJT7O4PLIO; expires=Sat, 05-Mar-2011 04:01:06 GMT; path=/; domain=.google.com
    Server: gws
    Transfer-Encoding: chunked

    百度的Web服务器伪装:

    #curl -I www.baidu.com
    HTTP/1.1 200 OK
    Date: Thu, 05 Mar 2009 04:03:09 GMT
    BWS/1.0
    Content-Length: 3932
    Content-Type: text/html
    Cache-Control: private
    Expires: Thu, 05 Mar 2009 04:03:09 GMT
    Set-Cookie: BAIDUID=57AC33DC9E472FADDB6DAE6815FCBFC6:FG=1; expires=Thu, 05-Mar-39 04:03:09 GMT; path=/; domain=.baidu.com
    P3P: CP=" OTI DSP COR IVA OUR IND COM "

    要进行web服务器伪装通常来说需要重新便宜web服务器,下面介绍一下nginx和apache如何进行操作
    重新编译nginx的服务器响应:
    # cd nginx-0.6.34
    # vi src/core/nginx.h

    #ifndef _NGINX_H_INCLUDED_
    #define _NGINX_H_INCLUDED_
    #define NGINX_VERSION      "1.3"
    #define NGINX_VER          "SaSaWS/" NGINX_VERSION
    #define NGINX_VAR          "SaSaWS"
    #define NGX_OLDPID_EXT     ".oldbin"
    #endif /* _NGINX_H_INCLUDED_ */

    Apache可以修改以下文件
    include/ap_release.h

    #define AP_SERVER_BASEVENDOR    IBM
    #define AP_SERVER_BASEPRODUCT   Websphere
    #define AP_SERVER_MAJORVERSION  5 //主版本
    #define AP_SERVER_MINORVERSION  0 //次版本
    #define AP_SERVER_PATCHLEVEL     13 //修正版本

    file: os/os2/os.h

    #define PLATFORM  //OS的名称,例如:Solaris"

    如果不是伪装,而只是不显示是apache,可以在apache配置文件中添加以下两行
    ServerTokens ProductOnly
    ServerSignature Off

    既然谈到了服务器,也就再谈一点php的安全措施,可以关闭显示服务器端为php,具体做法是在/etc/php.ini添加:
    expose_php = Off
    在php的生产环境下建议做一些额外的安全措施:
    enable_dl = Off
    disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show_source
    如果你建立的是虚拟主机那么你需要一份更长的函数列表:
    disable_functions = escapeshellarg, escapeshellcmd, exec, passthru, proc_close, proc_get_status, proc_open, proc_nice, proc_terminate, shell_exec, system, ini_restore, popen, dl, disk_free_space, diskfreespace, set_time_limit, tmpfile, fopen, readfile, fpassthru, fsockopen, mail, ini_alter, highlight_file, openlog, show_source, symlink, apache_child_terminate, apache_get_modules, apache_get_version, apache_getenv, apache_note, apache_setenv, parse_ini_file

    Leave a reply