GNU/Linux >> Linux の 問題 >  >> Debian

RkhunterでルートキットのDebianサーバーをスキャンする方法

Rkhunterは「RootkitHunter」の略で、Linuxオペレーティングシステム用の無料のオープンソース脆弱性スキャナーです。ルートキット、および隠しファイル、バイナリに設定された誤った権限など、その他の考えられる脆弱性をスキャンします。 、カーネル内の疑わしい文字列など。ローカルシステム内のすべてのファイルのSHA-1ハッシュを、オンラインデータベース内の既知の適切なハッシュと比較します。また、ローカルシステムコマンド、スタートアップファイル、およびリスニングサービスとアプリケーションのネットワークインターフェイスをチェックします。 。

このチュートリアルでは、Debian10サーバーにRkhunterをインストールして使用する方法を説明します。

前提条件

  • Debian10を実行しているサーバー。
  • ルートパスワードはサーバーで構成されています。

Rkhunterのインストールと構成

デフォルトでは、RkhunterパッケージはDebian10のデフォルトリポジトリで利用できます。次のコマンドを実行するだけでインストールできます:

apt-get install rkhunter -y

インストールが完了したら、システムをスキャンする前にRkhunterを構成する必要があります。 /etc/rkhunter.confファイルを編集して設定できます。

nano /etc/rkhunter.conf

次の行を変更します:

#Enable the mirror checks.
UPDATE_MIRRORS=1

#Tells rkhunter to use any mirror.
MIRRORS_MODE=0

#Specify a command which rkhunter will use when downloading files from the Internet
WEB_CMD=""

終了したら、ファイルを保存して閉じます。次に、次のコマンドを使用して、構成構文エラーがないかRkhunterを確認します。

rkhunter -C

Rkhunterを更新してセキュリティベースラインを設定する

次に、インターネットミラーからデータファイルを更新する必要があります。次のコマンドで更新できます:

rkhunter --update

次の出力が得られるはずです:

[ Rootkit Hunter version 1.4.6 ]

Checking rkhunter data files...
  Checking file mirrors.dat                                  [ Updated ]
  Checking file programs_bad.dat                             [ No update ]
  Checking file backdoorports.dat                            [ No update ]
  Checking file suspscan.dat                                 [ No update ]
  Checking file i18n/cn                                      [ Skipped ]
  Checking file i18n/de                                      [ Skipped ]
  Checking file i18n/en                                      [ No update ]
  Checking file i18n/tr                                      [ Skipped ]
  Checking file i18n/tr.utf8                                 [ Skipped ]
  Checking file i18n/zh                                      [ Skipped ]
  Checking file i18n/zh.utf8                                 [ Skipped ]
  Checking file i18n/ja                                      [ Skipped ]

次に、次のコマンドを使用してRkhunterのバージョン情報を確認します。

rkhunter --versioncheck

次の出力が得られるはずです:

[ Rootkit Hunter version 1.4.6 ]

Checking rkhunter version...
  This version  : 1.4.6
  Latest version: 1.4.6

次に、次のコマンドを使用してセキュリティベースラインを設定します。

rkhunter --propupd

次の出力が得られるはずです:

[ Rootkit Hunter version 1.4.6 ]
File updated: searched for 180 files, found 140

テスト実行を実行

この時点で、Rkhunterがインストールおよび構成されています。次に、システムに対してセキュリティスキャンを実行します。次のコマンドを実行して実行します:

rkhunter --check

以下に示すように、セキュリティチェックごとにEnterキーを押す必要があります。

System checks summary
=====================

File properties checks...
    Files checked: 140
    Suspect files: 3

Rootkit checks...
    Rootkits checked : 497
    Possible rootkits: 0

Applications checks...
    All checks skipped

The system checks took: 2 minutes and 10 seconds

All results have been written to the log file: /var/log/rkhunter.log

One or more warnings have been found while checking the system.
Please check the log file (/var/log/rkhunter.log)

以下に示すように、オプション–skを使用してEnterキーを押さないようにし、オプション–rwoを使用して警告のみを表示することができます。

rkhunter --check --rwo --sk

次の出力が得られるはずです:

Warning: The command '/usr/bin/egrep' has been replaced by a script: /usr/bin/egrep: POSIX shell script, ASCII text executable
Warning: The command '/usr/bin/fgrep' has been replaced by a script: /usr/bin/fgrep: POSIX shell script, ASCII text executable
Warning: The command '/usr/bin/which' has been replaced by a script: /usr/bin/which: POSIX shell script, ASCII text executable
Warning: The SSH and rkhunter configuration options should be the same:
         SSH configuration option 'PermitRootLogin': yes
         Rkhunter configuration option 'ALLOW_SSH_ROOT_USER': no

次のコマンドを使用して、Rkhunterログを確認することもできます。

tail -f /var/log/rkhunter.log

cronを使用した定期スキャンのスケジュール

システムを定期的にスキャンするようにRkhunterを構成することをお勧めします。ファイル/etc/ default / rkhunterを編集して構成できます:

nano /etc/default/rkhunter

次の行を変更します:

#Perform security check daily
CRON_DAILY_RUN="true"

#Enable weekly database updates.
CRON_DB_UPDATE="true"

#Enable automatic database updates
APT_AUTOGEN="true"

終了したら、ファイルを保存して閉じます。

結論

おめでとう!これで、Debian10サーバーにRkhunterが正常にインストールおよび構成されました。 Rkhunterを定期的に使用して、サーバーをマルウェアから保護できるようになりました。


Debian
  1. Linuxシステムをスキャンして、ルートキット、ワーム、トロイの木馬などを探すにはどうすればよいですか?

  2. Debian10でDockerを使用してダイナミックDNSサーバーをデプロイする方法

  3. Debian9でCSFを使用してファイアウォールを構成する方法

  1. Debian9にGoをインストールする方法

  2. Debian9でVSFTPDを使用してFTPサーバーをセットアップする方法

  3. Debian11にNginxを使用してHTTPGitサーバーをインストールする方法

  1. Debian10でChrootを使用してSFTPサーバーを構成する方法

  2. Debian 10(Buster)にNFSサーバーをインストールする方法

  3. Debian8でIncronを使用してファイル/ディレクトリの変更でコマンドをトリガーする方法