無料で使えるオープンソースの Web アプリケーションセキュリティスキャナーの Nikto を RHEL8 に導入したので、手順を記録しておく。
環境
- Red Hat Enterprise Linux release 8.5 (Ootpa)
※epel リポジトリは導入済み。まだの方は下記コマンドでインストール。
| 1 | # dnf -y install epel-release | 
導入手順
まずは普通に dnf でインストールできるか試行してみる。
| 1 2 3 4 5 6 | # dnf install nikto エラー:  問題: 競合するリクエスト   - perl(LW2) が提供されません nikto-1:2.1.6-8.el8.noarch に必要です (インストール不可のパッケージをスキップするには、'--skip-broken' を追加してみて ください または、'--nobest' を追加して、最適候補のパッケージのみを使用しないでください) | 
perl(LW2) が足りないという事でエラーになる。この perl(LW2) についてググったところ perl-libwhisker2 という Perl のモジュールらしい。
そして、この perl-libwhisker2 は Fedora 28 のリポジトリに登録されているとの事なので、 Fedora 28 リポジトリをインストール。
| 1 2 | # dnf -y install https://extras.getpagespeed.com/release-el8-latest.rpm # dnf -y install fed2el-release | 
Fedora 28 のリポジトリを導入できたので、次に perl-libwhisker2 をインストールする。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # dnf install perl-libwhisker2 ================================================================================  パッケージ         Arch     バージョン      リポジトリー                 サイズ ================================================================================ インストール:  perl-libwhisker2   noarch   2.5-29.el8      getpagespeed-extras-noarch    95 k トランザクションの概要 ================================================================================ インストール  1 パッケージ ダウンロードサイズの合計: 95 k インストール後のサイズ: 259 k これでよろしいですか? [y/N]: y パッケージのダウンロード: perl-libwhisker2-2.5-29.el8.noarch.rpm          118 kB/s |  95 kB     00:00 -------------------------------------------------------------------------------- 合計                                            118 kB/s |  95 kB     00:00 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中   準備             :                                                        1/1   インストール中   : perl-libwhisker2-2.5-29.el8.noarch                     1/1   scriptletの実行中: perl-libwhisker2-2.5-29.el8.noarch                     1/1   検証             : perl-libwhisker2-2.5-29.el8.noarch                     1/1 インストール済みの製品が更新されています。 インストール済み:   perl-libwhisker2-2.5-29.el8.noarch 完了しました! | 
最後に Nikto をインストールして完了。
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | # dnf info nikto ================================================================================  パッケージ      Arch   バージョン       リポジトリー                     サイズ ================================================================================ インストール:  nikto           noarch 1:2.1.6-8.el8    epel                             352 k 依存関係のインストール:  nmap            x86_64 2:7.70-6.el8     rhel-8-for-x86_64-appstream-rpms 5.8 M  nmap-ncat       x86_64 2:7.70-6.el8     rhel-8-for-x86_64-appstream-rpms 237 k  perl-JSON-PP    noarch 1:2.97.001-3.el8 rhel-8-for-x86_64-appstream-rpms  68 k  perl-Math-BigRat                  noarch 0.2614-1.el8     rhel-8-for-x86_64-appstream-rpms  40 k  perl-Time-HiRes x86_64 4:1.9758-2.el8   rhel-8-for-x86_64-appstream-rpms  61 k  perl-bignum     noarch 0.49-2.el8       rhel-8-for-x86_64-appstream-rpms  44 k トランザクションの概要 ================================================================================ インストール  7 パッケージ ダウンロードサイズの合計: 6.6 M インストール後のサイズ: 26 M これでよろしいですか? [y/N]: y パッケージのダウンロード: (1/7): nikto-2.1.6-8.el8.noarch.rpm             3.8 MB/s | 352 kB     00:00 (2/7): perl-JSON-PP-2.97.001-3.el8.noarch.rpm   262 kB/s |  68 kB     00:00 (3/7): perl-Time-HiRes-1.9758-2.el8.x86_64.rpm  302 kB/s |  61 kB     00:00 (4/7): perl-Math-BigRat-0.2614-1.el8.noarch.rpm  52 kB/s |  40 kB     00:00 (5/7): perl-bignum-0.49-2.el8.noarch.rpm         55 kB/s |  44 kB     00:00 (6/7): nmap-ncat-7.70-6.el8.x86_64.rpm          883 kB/s | 237 kB     00:00 (7/7): nmap-7.70-6.el8.x86_64.rpm               4.4 MB/s | 5.8 MB     00:01 -------------------------------------------------------------------------------- 合計                                            2.4 MB/s | 6.6 MB     00:02 トランザクションの確認を実行中 トランザクションの確認に成功しました。 トランザクションのテストを実行中 トランザクションのテストに成功しました。 トランザクションを実行中   準備             :                                                        1/1   インストール中   : nmap-ncat-2:7.70-6.el8.x86_64                          1/7   scriptletの実行中: nmap-ncat-2:7.70-6.el8.x86_64                          1/7   インストール中   : nmap-2:7.70-6.el8.x86_64                               2/7   インストール中   : perl-Time-HiRes-4:1.9758-2.el8.x86_64                  3/7   インストール中   : perl-JSON-PP-1:2.97.001-3.el8.noarch                   4/7   インストール中   : perl-Math-BigRat-0.2614-1.el8.noarch                   5/7   インストール中   : perl-bignum-0.49-2.el8.noarch                          6/7   インストール中   : nikto-1:2.1.6-8.el8.noarch                             7/7   scriptletの実行中: nikto-1:2.1.6-8.el8.noarch                             7/7   検証             : nikto-1:2.1.6-8.el8.noarch                             1/7   検証             : perl-Math-BigRat-0.2614-1.el8.noarch                   2/7   検証             : perl-bignum-0.49-2.el8.noarch                          3/7   検証             : perl-JSON-PP-1:2.97.001-3.el8.noarch                   4/7   検証             : perl-Time-HiRes-4:1.9758-2.el8.x86_64                  5/7   検証             : nmap-2:7.70-6.el8.x86_64                               6/7   検証             : nmap-ncat-2:7.70-6.el8.x86_64                          7/7 インストール済みの製品が更新されています。 インストール済み:   nikto-1:2.1.6-8.el8.noarch             nmap-2:7.70-6.el8.x86_64   nmap-ncat-2:7.70-6.el8.x86_64          perl-JSON-PP-1:2.97.001-3.el8.noarch   perl-Math-BigRat-0.2614-1.el8.noarch   perl-Time-HiRes-4:1.9758-2.el8.x86_64   perl-bignum-0.49-2.el8.noarch 完了しました! | 
脆弱性診断を実行
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # nikto -host localhost - ***** RFIURL is not defined in nikto.conf--no RFI tests will run ***** - Nikto v2.1.6 --------------------------------------------------------------------------- + Target IP:          127.0.0.1 + Target Hostname:    localhost + Target Port:        80 + Start Time:         2022-01-25 13:09:43 (GMT9) --------------------------------------------------------------------------- + Server: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k + Server leaks inodes via ETags, header found with file /, fields: 0x133f 0x5c6f23d09f000 + The anti-clickjacking X-Frame-Options header is not present. + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS + 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 + Retrieved x-powered-by header: PHP/7.4.27 + Allowed HTTP Methods: GET, POST, OPTIONS, HEAD, TRACE + OSVDB-3268: /icons/: Directory indexing found. + OSVDB-3268: /icons/: Directory indexing found. + OSVDB-3233: /icons/README: Apache default file found. + 5735 requests: 0 error(s) and 9 item(s) reported on remote host + End Time:           2022-01-25 13:09:49 (GMT9) (6 seconds) --------------------------------------------------------------------------- + 1 host(s) tested       *********************************************************************       Portions of the server's headers (Apache/2.4.37 OpenSSL/1.1.1k) are not in       the Nikto database or are newer than the known string. Would you like       to submit this information (*no server specific data*) to CIRT.net       for a Nikto update (or you may email to sullo@cirt.net) (y/n)? | 
ほぼ初期設定のため調整が必要なことが分かりました。
診断結果に基づく設定見直し
このサーバーでインデックス表示は不要なので、設定を読み込まないようにリネームする。
| 1 | # mv /etc/httpd/conf.d/autoindex.{conf,bak} | 
その他のセキュリティ設定をまとめて行う。
| 1 | # vi /etc/httpd/conf.d/security.conf | 
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # バージョン情報の隠蔽 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 を再起動する。
| 1 | # systemctl restart httpd | 
脆弱性診断を再実行
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # nikto -host localhost - ***** RFIURL is not defined in nikto.conf--no RFI tests will run ***** - Nikto v2.1.6 --------------------------------------------------------------------------- + Target IP:          127.0.0.1 + Target Hostname:    localhost + Target Port:        80 + Start Time:         2022-01-26 15:30:20 (GMT9) --------------------------------------------------------------------------- + Server: Apache + Allowed HTTP Methods: POST, OPTIONS, HEAD, GET + 5735 requests: 0 error(s) and 1 item(s) reported on remote host + End Time:           2022-01-26 15:30:26 (GMT9) (6 seconds) --------------------------------------------------------------------------- + 1 host(s) tested | 
引っかかった脆弱性を一通り潰せたので、一安心です。
リンク

 


コメント