各サーバデーモンは、あるコマンドを与えられたりアクセスした場合にアクセス先にサーバ情報(デーモン名やバージョン等)を返却します。
悪意のある第三者(クラッカー)は、そのサーバ情報を基に脆弱性を狙い攻撃を仕掛けてきます。
(サーバ情報が表示されれば、そのサーバ情報(デーモン名)のありとあらゆるアタックをかけてきます。)
サーバ情報やバージョンを非表示にする事により第三者は一意に狙ったアタックがかけづらい為、少しは軽減できるかもしれません。
ここの設定は一意的な攻撃を少なくする為であり、防御する方法ではありません。
telnetでWebサーバのポート"80"にアクセス # telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. コマンド入力 ECHO <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>501 Method Not Implemented</title> </head><body> <h1>Method Not Implemented</h1> <p>ECHO to / not supported.<br /> </p> <hr /> サーバ情報が表示されている <address>Apache/2.2.3 (Fedora) Server at kajuhome.com Port 80</address> </body></html> Connection closed by foreign host. apache設定ファイルの編集 # vi /etc/httpd/conf/httpd.conf # # Don't give away too much information about all the subcomponents # we are running. Comment out this line if you don't mind remote sites # finding out what major optional modules you are running ServerTokens Prod # # Optionally add a line containing the server version and virtual host # name to server-generated pages (internal error documents, FTP directory # listings, mod_status and mod_info output etc., but not CGI generated # documents or custom error documents). # Set to "EMail" to also include a mailto: link to the ServerAdmin. # Set to one of: On | Off | EMail # ServerSignature Off Webサーバ(apache)の再起動 【FC1 から Fedora15 / CentOS4 / CentOS5 / CentOS6 の場合】 # /etc/rc.d/init.d/httpd restart 【Fedora16以降 の場合】 # systemctl restart httpd.service telnetでWebサーバのポート"80"にアクセス # telnet localhost 80 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. コマンド入力 ECHO <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>501 Method Not Implemented</title> </head><body> <h1>Method Not Implemented</h1> <p>ECHO to / not supported.<br /> </p> サーバ情報が非表示になった </body></html> Connection closed by foreign host. |
確認の為、事前にドキュメントルート「/var/www/html/」に適当な「test.php」を作成します。
telnetでWebサーバのポート"80"にアクセス
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
コマンド入力
HEAD /test.php HTTP/1.0
<-- もう一度、空エンター押下
HTTP/1.1 200 OK
Date: Mon, 19 Nov 2007 07:39:56 GMT
Server: Apache
phpのバージョン情報が表示されている
X-Powered-By: PHP/5.2.4
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/html
Connection closed by foreign host.
php設定ファイルの編集
# vi /etc/php.ini
;
; Misc
;
; 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.
expose_php = Off
Webサーバ(apache)の再起動
【FC1 から Fedora15 / CentOS4 / CentOS5 / CentOS6 の場合】
# /etc/rc.d/init.d/httpd restart
【Fedora16以降 の場合】
# systemctl restart httpd.service
telnetでWebサーバのポート"80"にアクセス
# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
コマンド入力
HEAD /test.php HTTP/1.0
<-- もう一度、空エンター押下
HTTP/1.1 200 OK
Date: Mon, 19 Nov 2007 07:40:44 GMT
Server: Apache
サーバ情報が非表示になった
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/html
Connection closed by foreign host.
|
telnetでMailサーバのsmtpポート"25"にアクセス # telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. サーバ情報が表示されている 220 kajuhome.com ESMTP Postfix (2.0.18) ctrl + "]"を押してターミナルを抜ける ^] telenetの終了 telnet> quit Connection closed. postfix設定ファイルの編集 # vi /etc/postfix/main.cf # SHOW SOFTWARE VERSION OR NOT # # The smtpd_banner parameter specifies the text that follows the 220 # code in the SMTP server's greeting banner. Some people like to see # the mail version advertised. By default, Postfix shows no version. # # You MUST specify $myhostname at the start of the text. That is an # RFC requirement. Postfix itself does not care. # #smtpd_banner = $myhostname ESMTP $mail_name #smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) smtpd_banner = $myhostname ESMTP Mailサーバ(postfix)の再起動 【FC1 から Fedora15 / CentOS4 / CentOS5 / CentOS6 の場合】 # /etc/rc.d/init.d/postfix restart 【Fedora16以降 の場合】 # systemctl restart postfix.service # telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. サーバ情報が非表示になった 220 kajuhome.com ESMTP ctrl + "]"を押してターミナルを抜ける ^] telenetの終了 telnet> quit Connection closed. |
DNSサーバ情報確認
# dig @localhost chaos txt version.bind
; <<>> DiG 9.2.3 <<>> @localhost chaos txt version.bind
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51352
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;version.bind. CH TXT
;; ANSWER SECTION:
サーバ情報が表示されている
version.bind. 0 CH TXT "9.2.3"
;; Query time: 34 msec
;; SERVER: 127.0.0.1#53(localhost)
;; WHEN: Thu Oct 28 12:09:48 2004
;; MSG SIZE rcvd: 48
bind設定ファイルの編集
# vi /etc/named.conf
// generated by named-bootconf.pl
options {
directory "/var/named";
以下の行を追加する
version "unknown";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
DNSサーバ(bind)の再起動
【FC1 から Fedora14 / CentOS4 / CentOS5 / CentOS6 の場合】
# /etc/rc.d/init.d/named restart
【Fedora15以降 の場合】
# systemctl restart named.service
DNSサーバ情報確認
# dig @localhost chaos txt version.bind
; <<>> DiG 9.2.3 <<>> @localhost chaos txt version.bind
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58074
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;version.bind. CH TXT
;; ANSWER SECTION:
サーバ情報が非表示になった
version.bind. 0 CH TXT "unknown"
;; Query time: 29 msec
;; SERVER: 127.0.0.1#53(localhost)
;; WHEN: Thu Oct 28 12:17:03 2004
;; MSG SIZE rcvd: 50
|