nginx の設定項目を見直していたのですが、診断ツールがあると便利だなっと思い探してみると、Nikto というツールに行き着きました。
今回は Nikto を紹介します。
Niktoのダウンロード
2012 年が最新版で公式サイトがエラーとなって表示できないので怖いのですが、このツール自体のダウンロードは可能です。
下記のディレクトリからお好みの圧縮フォーマットでダウンロードしてください。
Niktoのインストールと実行
早速、解凍して実行できる状態にします。
まずは、ダウンロードして解凍、そして実行ファイル nikto.pl のディレクトリへ移動します。
1 2 3 4 | $ cd /usr/local/src $ wget https://cirt.net/nikto/nikto-2.1.5.tar.gz $ tar xvfz nikto-2.1.5.tar.gz $ cd nikto-2.1.5 |
Niktoのヘルプを確認する
ヘルプを参照する場合は、以下のコマンドで可能です。
-H オプションを使うと詳細なヘルプが確認できますが、そこそこの量になるので、ここでは簡易版のヘルプを紹介しておきます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | $ perl nikto.pl -h Option host requires an argument -config+ Use this config file -Display+ Turn on/off display outputs -dbcheck check database and other key files for syntax errors -Format+ save file (-o) format -Help Extended help information -host+ target host -id+ Host authentication to use, format is id:pass or id:pass:realm -list-plugins List all available plugins -output+ Write output to this file -nossl Disables using SSL -no404 Disables 404 checks -Plugins+ List of plugins to run (default: ALL) -port+ Port to use (default 80) -root+ Prepend root value to all requests, format is /directory -ssl Force ssl mode on port -Tuning+ Scan tuning -timeout+ Timeout for requests (default 10 seconds) -update Update databases and plugins from CIRT.net -Version Print plugin and database versions -vhost+ Virtual host (for Host header) + requires a value Note: This is the short help output. Use -H for full help text. |
この中で使用するオプションは host が一般的になりそうですが、Basic 認証を掛けているテストサイトを診断したい場合は id オプションを使うことになります。
Basic認証を通過させる
単純に、Basic 認証を掛けている自身のサーバで試す場合は以下のコマンドになります。
ホストはループバックアドレスでも localhost でも問題ないですが、サーバの設定によっては localhost でアクセスできないケースもあるので、ループバックアドレスが無難でしょうか。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $ perl nikto.pl -id "user:password" -h 127.0.0.1 (結果は一部省略しています) - ***** SSL support not available (see docs for SSL install) ***** - Nikto v2.1.5 --------------------------------------------------------------------------- + Target IP: 127.0.0.1 + Target Hostname: localhost + Target Port: 80 --------------------------------------------------------------------------- + Server: nginx + The anti-clickjacking X-Frame-Options header is not present. + No CGI Directories found (use '-C all' to force check all possible dirs) + Uncommon header 'x-frame-options' found, with contents: SAMEORIGIN + Cookie PHPSESSID created without the httponly flag + 6545 items checked: 0 error(s) and 7 item(s) reported on remote host --------------------------------------------------------------------------- + 1 host(s) tested |
Niktoを使ってみた結果
結果はリクエストヘッダの一部の項目の扱いや、URL のディレクトリパス、ファイル名など細かいものが多いのと、ログなのか警告なのか分かりにくい表示であまり好感は持てませんでした。
クリックジャッキング対策用に x-frame-options 付けてるのに警告が出るのは何だろう・・・。
今回、セットアップしたばかりのサーバに簡易的にやってしまったので、ドメイン振ってリモートから試してみた方が良さそうですね。
あと、今は http ですが、これから SSL の設定をして https でのアクセスも許可するので、その場合、Nikto で SSL に対応するために perl の SSL 用のライブラリなどが別途必要になるかもしれません。
Kali Linuxを診断ツールとして利用してみる
先日、脆弱性の診断に特化した Linux ディストリビューションがあると聞いたので、Kali Linux を Vagrant 上で動かして、リモートから診断できないかと試みました。
下記のサイトからボックスファイルを探して vagrant コマンドで設定が開始できます。
1 | $ vagrant init starflame/kali2_linux4.0.0_amd64; vagrant up --provider virtualbox |
別途、vagrant のボックスイメージで有名な www.vagrantbox.es のリストにある Kali Linux のイメージは 404 でダウンロードできませんでした・・・。