■Tripwireによるファイル改ざんの検知
第3回:レポートの参照とデータベースのアップデート  前回は、ポリシーファイルの記述方法について簡単に紹介したが、今回はそれを元に簡単なサンプルのポリシーファイルを作成し、実際に整合性のチェックを行いながらレポートファイルの参照や、整合性チェック後のデーターベースのアップデートやポリシーファイルのアップデートを行ってみよう

レポートファイルの参照とデーターベースのアップデート

 今回は、サンプルとなるポリシーファイルを元に、整合性のチェックを行いながらレポートファイルの参照を行うとともに、データーベースおよびポリシーファイルのアップデートについて解説していく。もちろんここで使用するポリシーファイルはサンプルであるため、参考として見てほしい。

 では、通常の流れと同じように、ポリシーファイルの作成を行い、暗号署名ファイルとしてから整合性のチェックを行ってみよう。今回はインストールしたばかりの状態(つまりデータベースがまだ作成されていない状態)を仮定している。

ポリシーファイルの作成

 まずサンプルとして、下記のようなひとつのルールを記述したポリシーファイルを作成した。このサンプルはWebサイト公開用のディレクトリである「/var/www/html」のディレクトリおよびファイルをTripwireのチェック対象とし、検査内容を「$(ReadOnly)」としている。

 属性に「recurse=1」と指定しているので、チェックの対象となるのは/var/www/html上のindex.htmlやguest.htmlなどのファイルと、そこに作られたディレクトリまでということになる。つまり、その下のディレクトリにあるファイル、たとえば「/var/www/html/hoge/hoge.html」などは、変更、削除されても違反としては報告されない。また、ストップポイント「!」を利用して、頻繁に変更されるファイルと想定した「/var/www/html/news.html」はチェック対象からはずしている。このルールにより、/var/www/htmlディレクトリ上のnews.html以外は監視対象となり、変更が発見されれば違反として報告されることになる。

■ポリシーファイルのクリアテキストを作成

 まずは、ポリシーファイルをテキストエディタで作成しよう。

# vi testpol.txt

※以下の内容を記述して保存
(
rulename = "web-sample",※ルールブロック名を「web-sample」とする
severity = 33,※重要度は33に指定
emailto = hoge@hoge.com,※違反が発生した場合は「hoge@hoge.com」にメールする
recurse=1※ディレクトリの再帰を制御
)
{
/var/www/html->$(ReadOnly) ;
!/var/www/html/news.html ;
}

■ポリシーファイルの暗号署名

 ポリシーファイルを作成したら、twadminコマンドを利用して、ポリシーファイルを暗号署名付きのファイルとする。

twadmin --create-polfile [作成もしくは編集したポリシーファイルのクリアテキストファイル名]

のように入力すればよい。

# twadmin --create-polfile testpol.txt

Please enter your site passphrase:(サイトパスフレーズを入力)
Wrote policy file: /etc/tripwire/tw.pol

■データベースの初期化

 データベースを初期化する場合は、

tripwire --init

と入力する。

# tripwire --init

Please enter your local passphrase:(ローカルパスフレーズの入力)
Parsing policy file: /etc/tripwire/tw.pol
Generating the database...
*** Processing Unix File System ***
Wrote database file: /var/lib/tripwire/linux.twd
The database was successfully generated.

■整合性のチェック

 データーベースの初期化が完了したら、整合性のチェックを行う。なにも変更を加えていなければレポートに「No violations.」と記述され、違反は報告されない。

tripwire --check

とすれば、整合性のチェックが可能だ。

# tripwire --check Parsing policy file: /etc/tripwire/tw.pol
*** Processing Unix File System ***
Performing integrity check...
Wrote report file: /var/lib/tripwire/report/linux-20021007-103731.twr


Tripwire(R) 2.3.0 Integrity Check Report

Report generated by:root
Report created on:2002年10月07日 10時37分31秒
Database last updated on: Never

===================================================================
Report Summary:
===================================================================

Host name:linux
Host IP address:127.0.0.1
Host ID:None
Policy file used: /etc/tripwire/tw.pol
Configuration file used:/etc/tripwire/tw.cfg
Database file used: /var/lib/tripwire/linux.twd
Command line used:tripwire --check

===================================================================
Rule Summary:
===================================================================

-------------------------------------------------------------------
Section: Unix File System
-------------------------------------------------------------------

Rule Name       Severity Level  Added  Removed Modified
---------       --------------  -----  ------- --------
web-sample      33        0    0    0
(/var/www/html)

Total objects scanned:9
Total violations found:0

===================================================================
Object Summary:
===================================================================

-------------------------------------------------------------------
# Section: Unix File System
-------------------------------------------------------------------

No violations.

===================================================================
Error Report:
===================================================================

No Errors

-------------------------------------------------------------------
*** End of report ***

Tripwire 2.3 Portions copyright 2000 Tripwire, Inc. Tripwire is a registered
trademark of Tripwire, Inc. This software comes with ABSOLUTELY NO WARRANTY;
for details use --version. This is free software which may be redistributed
or modified only under certain conditions; see COPYING for details.
All rights reserved.
Integrity check complete.

1/4 NEXT