3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rkhunter に好きなディレクトリorファイルを監視してもらう

Last updated at Posted at 2016-02-01

2016年になりましたが rkhunter の話です。

経緯

/bin/ls とかもいいけど /home/gongo/hiden-no-config も監視して欲しい!!

環境

CentOS 6.7

他ディストリビューションでも、ディレクトリの差異はあるかもしれませんが、下記手順で問題ないと思います。

方法

/etc/sysconfig/rkhunter.confUSER_FILEPROP_FILES_DIRS を追加:

USER_FILEPROP_FILES_DIRS=/home/gongo/hiden-no-config

# 他にも
# USER_FILEPROP_FILES_DIRS=/path/to/dir2/*            # dir2 内のファイル全部
# EXCLUDE_USER_FILEPROP_FILES_DIRS=/path/to/dir2/conf # dir2/conf だけは除外

適当にファイルを作成してみる:

$ echo pizza > /home/gongo/hiden-no-config

rkhunter が持つデータベースを更新する:

$ sudo rkhunter --propupd

監視対象ファイルとして追加されているのを確認:

$ sudo grep gongo /var/lib/rkhunter/db/rkhunter_prop_list.dat
/home/gongo/hiden-no-config

ここでファイルを変更してみる:

$ echo curry > /home/gongo/hiden-no-config

ファイルチェック:

$ sudo rkhunter --check --skip-keypress --report-warnings-only
Warning: The file properties have changed:
         File: /home/gongo/hiden-no-config
         Current hash: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
         Stored hash : YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
         Current file modification time: 1454302839 (01- 2月-2016 14:00:39)
         Stored file modification time : 1454302776 (01- 2月-2016 13:59:36)

「ファイルが変更されてますよ」という Warning が出ています。

再度 rkhunter --propupd を実行すると
home/gongo/hiden-no-config = :curry: がデータベースに登録されるので
rkhunter --check をしても Warning にはなりません。

まとめ

  • 大事なコマンドも
  • malware も
  • そうでもない普通のファイルも

とりあえず rkhunter に見てもらいたいという世界があれば USER_FILEPROP_FILES_DIRS をご利用ください

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?