脆弱性診断ツールの Nikto を Red Hat Enterprise Linux 8 にインストールする

Nikto Linux
このサイトはアフィリエイト広告(Amazonアソシエイト含む)を掲載しています。
スポンサーリンク

無料で使えるオープンソースの Web アプリケーションセキュリティスキャナーの Nikto を RHEL8 に導入したので、手順を記録しておく。

環境

  • Red Hat Enterprise Linux release 8.5 (Ootpa)

※epel リポジトリは導入済み。まだの方は下記コマンドでインストール。

dnf -y install epel-release

導入手順

まずは普通に dnf でインストールできるか試行してみる。

dnf install nikto
(out) 
(out) エラー:
(out)  問題: 競合するリクエスト
(out)   - perl(LW2) が提供されません nikto-1:2.1.6-8.el8.noarch に必要です
(out) (インストール不可のパッケージをスキップするには、'--skip-broken' を追加してみて ください または、'--nobest' を追加して、最適候補のパッケージのみを使用しないでください)

perl(LW2) が足りないという事でエラーになる。この perl(LW2) についてググったところ perl-libwhisker2 という Perl のモジュールらしい。

そして、この perl-libwhisker2 は Fedora 28 のリポジトリに登録されているとの事なので、 Fedora 28 リポジトリをインストール。

dnf -y install https://extras.getpagespeed.com/release-el8-latest.rpm
dnf -y install fed2el-release

Fedora 28 のリポジトリを導入できたので、次に perl-libwhisker2 をインストールする。

dnf install perl-libwhisker2
(out) 
(out) ================================================================================
(out)  パッケージ         Arch     バージョン      リポジトリー                 サイズ
(out) ================================================================================
(out) インストール:
(out)  perl-libwhisker2   noarch   2.5-29.el8      getpagespeed-extras-noarch    95 k
(out) 
(out) トランザクションの概要
(out) ================================================================================
(out) インストール  1 パッケージ
(out) 
(out) ダウンロードサイズの合計: 95 k
(out) インストール後のサイズ: 259 k
(out) これでよろしいですか? [y/N]: y
(out) パッケージのダウンロード:
(out) perl-libwhisker2-2.5-29.el8.noarch.rpm          118 kB/s |  95 kB     00:00
(out) --------------------------------------------------------------------------------
(out) 合計                                            118 kB/s |  95 kB     00:00
(out) トランザクションの確認を実行中
(out) トランザクションの確認に成功しました。
(out) トランザクションのテストを実行中
(out) トランザクションのテストに成功しました。
(out) トランザクションを実行中
(out)   準備             :                                                        1/1
(out)   インストール中   : perl-libwhisker2-2.5-29.el8.noarch                     1/1
(out)   scriptletの実行中: perl-libwhisker2-2.5-29.el8.noarch                     1/1
(out)   検証             : perl-libwhisker2-2.5-29.el8.noarch                     1/1
(out) インストール済みの製品が更新されています。
(out) 
(out) インストール済み:
(out)   perl-libwhisker2-2.5-29.el8.noarch
(out) 
(out) 完了しました!

最後に Nikto をインストールして完了。

dnf info nikto
(out) 
(out) ================================================================================
(out)  パッケージ      Arch   バージョン       リポジトリー                     サイズ
(out) ================================================================================
(out) インストール:
(out)  nikto           noarch 1:2.1.6-8.el8    epel                             352 k
(out) 依存関係のインストール:
(out)  nmap            x86_64 2:7.70-6.el8     rhel-8-for-x86_64-appstream-rpms 5.8 M
(out)  nmap-ncat       x86_64 2:7.70-6.el8     rhel-8-for-x86_64-appstream-rpms 237 k
(out)  perl-JSON-PP    noarch 1:2.97.001-3.el8 rhel-8-for-x86_64-appstream-rpms  68 k
(out)  perl-Math-BigRat
(out)                  noarch 0.2614-1.el8     rhel-8-for-x86_64-appstream-rpms  40 k
(out)  perl-Time-HiRes x86_64 4:1.9758-2.el8   rhel-8-for-x86_64-appstream-rpms  61 k
(out)  perl-bignum     noarch 0.49-2.el8       rhel-8-for-x86_64-appstream-rpms  44 k
(out) 
(out) トランザクションの概要
(out) ================================================================================
(out) インストール  7 パッケージ
(out) 
(out) ダウンロードサイズの合計: 6.6 M
(out) インストール後のサイズ: 26 M
(out) これでよろしいですか? [y/N]: y
(out) パッケージのダウンロード:
(out) (1/7): nikto-2.1.6-8.el8.noarch.rpm             3.8 MB/s | 352 kB     00:00
(out) (2/7): perl-JSON-PP-2.97.001-3.el8.noarch.rpm   262 kB/s |  68 kB     00:00
(out) (3/7): perl-Time-HiRes-1.9758-2.el8.x86_64.rpm  302 kB/s |  61 kB     00:00
(out) (4/7): perl-Math-BigRat-0.2614-1.el8.noarch.rpm  52 kB/s |  40 kB     00:00
(out) (5/7): perl-bignum-0.49-2.el8.noarch.rpm         55 kB/s |  44 kB     00:00
(out) (6/7): nmap-ncat-7.70-6.el8.x86_64.rpm          883 kB/s | 237 kB     00:00
(out) (7/7): nmap-7.70-6.el8.x86_64.rpm               4.4 MB/s | 5.8 MB     00:01
(out) --------------------------------------------------------------------------------
(out) 合計                                            2.4 MB/s | 6.6 MB     00:02
(out) トランザクションの確認を実行中
(out) トランザクションの確認に成功しました。
(out) トランザクションのテストを実行中
(out) トランザクションのテストに成功しました。
(out) トランザクションを実行中
(out)   準備             :                                                        1/1
(out)   インストール中   : nmap-ncat-2:7.70-6.el8.x86_64                          1/7
(out)   scriptletの実行中: nmap-ncat-2:7.70-6.el8.x86_64                          1/7
(out)   インストール中   : nmap-2:7.70-6.el8.x86_64                               2/7
(out)   インストール中   : perl-Time-HiRes-4:1.9758-2.el8.x86_64                  3/7
(out)   インストール中   : perl-JSON-PP-1:2.97.001-3.el8.noarch                   4/7
(out)   インストール中   : perl-Math-BigRat-0.2614-1.el8.noarch                   5/7
(out)   インストール中   : perl-bignum-0.49-2.el8.noarch                          6/7
(out)   インストール中   : nikto-1:2.1.6-8.el8.noarch                             7/7
(out)   scriptletの実行中: nikto-1:2.1.6-8.el8.noarch                             7/7
(out)   検証             : nikto-1:2.1.6-8.el8.noarch                             1/7
(out)   検証             : perl-Math-BigRat-0.2614-1.el8.noarch                   2/7
(out)   検証             : perl-bignum-0.49-2.el8.noarch                          3/7
(out)   検証             : perl-JSON-PP-1:2.97.001-3.el8.noarch                   4/7
(out)   検証             : perl-Time-HiRes-4:1.9758-2.el8.x86_64                  5/7
(out)   検証             : nmap-2:7.70-6.el8.x86_64                               6/7
(out)   検証             : nmap-ncat-2:7.70-6.el8.x86_64                          7/7
(out) インストール済みの製品が更新されています。
(out) 
(out) インストール済み:
(out)   nikto-1:2.1.6-8.el8.noarch             nmap-2:7.70-6.el8.x86_64
(out)   nmap-ncat-2:7.70-6.el8.x86_64          perl-JSON-PP-1:2.97.001-3.el8.noarch
(out)   perl-Math-BigRat-0.2614-1.el8.noarch   perl-Time-HiRes-4:1.9758-2.el8.x86_64
(out)   perl-bignum-0.49-2.el8.noarch
(out) 
(out) 完了しました!

脆弱性診断を実行

nikto -host localhost
(out) - ***** RFIURL is not defined in nikto.conf--no RFI tests will run *****
(out) - Nikto v2.1.6
(out) ---------------------------------------------------------------------------
(out) + Target IP:          127.0.0.1
(out) + Target Hostname:    localhost
(out) + Target Port:        80
(out) + Start Time:         2022-01-25 13:09:43 (GMT9)
(out) ---------------------------------------------------------------------------
(out) + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k
(out) + Server leaks inodes via ETags, header found with file /, fields: 0x133f 0x5c6f23d09f000
(out) + The anti-clickjacking X-Frame-Options header is not present.
(out) + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS
(out) + The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type
(out) + Retrieved x-powered-by header: PHP/7.4.27
(out) + Allowed HTTP Methods: GET, POST, OPTIONS, HEAD, TRACE
(out) + OSVDB-3268: /icons/: Directory indexing found.
(out) + OSVDB-3268: /icons/: Directory indexing found.
(out) + OSVDB-3233: /icons/README: Apache default file found.
(out) + 5735 requests: 0 error(s) and 9 item(s) reported on remote host
(out) + End Time:           2022-01-25 13:09:49 (GMT9) (6 seconds)
(out) ---------------------------------------------------------------------------
(out) + 1 host(s) tested
(out) 
(out) 
(out)       *********************************************************************
(out)       Portions of the server's headers (Apache/2.4.37 OpenSSL/1.1.1k) are not in
(out)       the Nikto database or are newer than the known string. Would you like
(out)       to submit this information (*no server specific data*) to CIRT.net
(out)       for a Nikto update (or you may email to sullo@cirt.net) (y/n)?

ほぼ初期設定のため調整が必要なことが分かりました。

診断結果に基づく設定見直し

このサーバーでインデックス表示は不要なので、設定を読み込まないようにリネームする。

mv /etc/httpd/conf.d/autoindex.{conf,bak}

その他のセキュリティ設定をまとめて行う。

vi /etc/httpd/conf.d/security.conf
# バージョン情報の隠蔽
ServerTokens ProductOnly
Header always unset "x-powered-by"

# エンティティタグの出力制御
FileETag None

# クリックジャッキング対策
Header set X-Frame-Options SAMEORIGIN

# XSS対策
Header set X-XSS-Protection "1; mode=block"
Header set X-Content-Type-Options nosniff

# XST対策
TraceEnable Off

Apache を再起動する。

systemctl restart httpd

脆弱性診断を再実行

nikto -host localhost
(out) - ***** RFIURL is not defined in nikto.conf--no RFI tests will run *****
(out) - Nikto v2.1.6
(out) ---------------------------------------------------------------------------
(out) + Target IP:          127.0.0.1
(out) + Target Hostname:    localhost
(out) + Target Port:        80
(out) + Start Time:         2022-01-26 15:30:20 (GMT9)
(out) ---------------------------------------------------------------------------
(out) + Server: Apache
(out) + Allowed HTTP Methods: POST, OPTIONS, HEAD, GET
(out) + 5735 requests: 0 error(s) and 1 item(s) reported on remote host
(out) + End Time:           2022-01-26 15:30:26 (GMT9) (6 seconds)
(out) ---------------------------------------------------------------------------
(out) + 1 host(s) tested

引っかかった脆弱性を一通り潰せたので、一安心です。

コメント

タイトルとURLをコピーしました