CentOS 8
Sponsored Link

AIDE : インストール2019/12/16

 
ホスト型 IDS (Intrusion Detection System), AIDE (Advanced Intrusion Detection Environment) のインストールと設定です。
[1] AIDE をインストールします。
[root@dlp ~]#
dnf -y install aide
[2] AIDE を設定してデータベースを初期化します。設定はデフォルトのままでも利用できますが、監視対象を調整する場合は設定ファイルを変更します。 設定ルールについては、設定ファイルの 26-84 行目あたりで説明してあります。
[root@dlp ~]#
vi /etc/aide.conf
# 26行目から : 設定ルールの説明

# These are the default rules.
#
#p:      permissions
#i:      inode:
#n:      number of links
#u:      user
#g:      group
#s:      size
#b:      block count
#m:      mtime
#a:      atime
#c:      ctime
#S:      check for growing size
#acl:           Access Control Lists
#selinux        SELinux security context
#xattrs:        Extended file attributes
#md5:    md5 checksum
#sha1:   sha1 checksum
#sha256:        sha256 checksum

# データベース初期化

[root@dlp ~]#
aide --init

Start timestamp: 2019-12-15 19:20:52 +0900 (AIDE 0.16)
AIDE initialized database at /var/lib/aide/aide.db.new.gz

Number of entries:      39208

---------------------------------------------------
The attributes of the (uncompressed) database(s):
---------------------------------------------------

/var/lib/aide/aide.db.new.gz
.....
.....
# 生成された DB をマスター DB へコピー

[root@dlp ~]#
cp -p /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
[3] チェックを実行します。
# チェック実行

[root@dlp ~]#
aide --check
# DB との差分がない場合は以下のように [Looks okay] と表示される

Start timestamp: 2019-12-15 19:22:29 +0900 (AIDE 0.16)
AIDE found NO differences between database and filesystem. Looks okay!!

Number of entries:      39208

---------------------------------------------------
The attributes of the (uncompressed) database(s):
---------------------------------------------------

/var/lib/aide/aide.db.gz
.....
.....

# 任意のファイルを変更して再度チェック実行

[root@dlp ~]#
chmod 640 /root/anaconda-ks.cfg

[root@dlp ~]#
aide --check
# 以下のように差分が検出される

Start timestamp: 2019-12-15 19:24:31 +0900 (AIDE 0.16)
AIDE found differences between database and filesystem!!

Summary:
  Total number of entries:      39208
  Added entries:                0
  Removed entries:              0
  Changed entries:              1

---------------------------------------------------
Changed entries:
---------------------------------------------------

f = p.. .c...A.. : /root/anaconda-ks.cfg

---------------------------------------------------
Detailed information about changes:
---------------------------------------------------

File: /root/anaconda-ks.cfg
  Perm     : -rw-------                       | -rw-r-----
  Ctime    : 2019-10-12 22:40:01 +0900        | 2019-12-15 19:24:23 +0900
  ACL      : A: user::rw-                     | A: user::rw-
             A: group::---                    | A: group::r--
             A: other::---                    | A: other::---


---------------------------------------------------
The attributes of the (uncompressed) database(s):
---------------------------------------------------

/var/lib/aide/aide.db.gz
.....
.....
[4] チェック実行と、変更が検出されたが内容に問題ない場合にデータベースの更新を行う場合は以下のようにします。
[root@dlp ~]#
aide --update
Start timestamp: 2019-12-15 19:25:59 +0900 (AIDE 0.16)
AIDE found differences between database and filesystem!!
New AIDE database written to /var/lib/aide/aide.db.new.gz

Summary:
  Total number of entries:      39208
  Added entries:                0
  Removed entries:              0
  Changed entries:              1

---------------------------------------------------
Changed entries:
---------------------------------------------------
.....
.....

# データベース更新

[root@dlp ~]#
cp -p /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz
[5] 定期的にチェックするよう Cron に登録します。 チェック結果のログファイル [/var/log/aide/aide.log] はチェックの都度上書きされるため、 チェック結果を毎回保存しておきたい場合は、シェルスクリプトで対応するか、毎回メールで結果を送信する等の工夫が必要です。
# 例として、毎日午前一時にチェック実行し、結果を root 宛にメールで送信

[root@dlp ~]#
vi /etc/cron.d/aide
00 01 * * * root /usr/sbin/aide --update | mail -s 'Daily Check by AIDE' root
関連コンテンツ