tripwireインストールメモ
作業レシピはこんな感じ
- Tripwireのインストール
- 設定ファイルの作成
- ポリシーファイルの作成
- ベースラインデータベースの作成
- 整合性チェック
- レポートのチェック
- ポリシーファイルの調整
wgetでソースを取得
wget http://downloads.sourceforge.net/project/tripwire/tripwire-src/tripwire-2.4.1.2-src/tripwire-2.4.1.2-src.tar.bz2?use_mirror=jaist
sendmailが入ってない場合等は予め
[ソースファイル]/install/install.cfgのTWMAILMETHODを、
TWMAILMETHOD=SMTP
としてやるとうまくいく。
#tar jxf tripwire-2.4.1.2-src.tar.bz2
# cd tripwire-2.4.1.2-src
# ./configure \
--prefix=/opt/softwares/tripwire-2.4.1.2 \
sysconfdir=/opt/softwares/tripwire-2.4.1.2/etc
# make
# make install
make installすると
Press ENTER to view the License Agreement
と出てwizardが開始される
(make install の最後にinstall.shが走るようになっている。)
wizardを進める。
Continue with installation? [y/n] y
----------------------------------------------
Creating directories...
/opt/softwares/tripwire-2.4.1.2/sbin: already exists
/opt/softwares/tripwire-2.4.1.2/etc: created
/opt/softwares/tripwire-2.4.1.2/lib/tripwire/report: created
/opt/softwares/tripwire-2.4.1.2/lib/tripwire: already exists
/opt/softwares/tripwire-2.4.1.2/etc: already exists
/opt/softwares/tripwire-2.4.1.2/etc: already exists
/opt/softwares/tripwire-2.4.1.2/man: created
/opt/softwares/tripwire-2.4.1.2/doc/tripwire: created
----------------------------------------------
Copying files...
/opt/softwares/tripwire-2.4.1.2/doc/tripwire/COPYING: copied
/opt/softwares/tripwire-2.4.1.2/doc/tripwire/TRADEMARK: copied
/opt/softwares/tripwire-2.4.1.2/doc/tripwire/policyguide.txt: copied
/opt/softwares/tripwire-2.4.1.2/etc/twpol-Linux.txt: copied
----------------------------------------------
The Tripwire site and local passphrases are used to
sign a variety of files, such as the configuration,
policy, and database files.
Passphrases should be at least 8 characters in length
and contain both letters and numbers.
See the Tripwire manual for more information.
----------------------------------------------
Creating key files...
(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)
Enter the site keyfile passphrase:
Verify the site keyfile passphrase:
Generating key (this may take several minutes)...Key generation complete.
(When selecting a passphrase, keep in mind that good passphrases typically
have upper and lower case letters, digits and punctuation marks, and are
at least 8 characters in length.)
Enter the local keyfile passphrase:
Verify the local keyfile passphrase:
Generating key (this may take several minutes)...Key generation complete.
----------------------------------------------
Generating Tripwire configuration file...
----------------------------------------------
Creating signed configuration file...
Please enter your site passphrase:
Wrote configuration file: /opt/softwares/tripwire-2.4.1.2/etc/tw.cfg
A clear-text version of the Tripwire configuration file
/opt/softwares/tripwire-2.4.1.2/etc/twcfg.txt
has been preserved for your inspection. It is recommended
that you delete this file manually after you have examined it.
----------------------------------------------
Customizing default policy file...
----------------------------------------------
Creating signed policy file...
Please enter your site passphrase:
Wrote policy file: /opt/softwares/tripwire-2.4.1.2/etc/tw.pol
A clear-text version of the Tripwire policy file
/opt/softwares/tripwire-2.4.1.2/etc/twpol.txt
has been preserved for your inspection. This implements
a minimal policy, intended only to test essential
Tripwire functionality. You should edit the policy file
to describe your system, and then use twadmin to generate
a new signed copy of the Tripwire policy.
----------------------------------------------
The installation succeeded.
Please refer to
for release information and to the printed user documentation
for further instructions on using Tripwire 2.4 Open Source.
make[3]: Leaving directory `/mnt/src/work/tripwire-2.4.1.2-src'
make[2]: Leaving directory `/mnt/src/work/tripwire-2.4.1.2-src'
make[1]: Leaving directory `/mnt/src/work/tripwire-2.4.1.2-src'
cd ../
rm -rf tripwire-2.4.1.2-src*
Pathの追加
/etc/profileにPATHを追加
PATH=$PATH:/opt/softwares/tripwire/sbin
confファイルの設定
# vi /etc/tripwire/twcfg.txt
#ファイル変更時に所属ディレクトリの変更を通知しないようにする
LOOSEDIRECTORYCHECKING =true
#リポートレベルを変更する
REPORTLEVEL = 4
各Tripwire設定ファイル(暗号署名版)作成
# twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
Please enter your site passphrase: ← サイトパスフレーズ応答
Wrote configuration file: /etc/tripwire/tw.cfg
Tripwire設定ファイル(テキスト版)を復元する場合
# twadmin -m f -c /etc/tripwire/tw.cfg > /etc/tripwire/twcfg.txt
DBの作成
Tripwireデータベース作成
# tripwire -m i -s -c /etc/tripwire/tw.cfg
#Please enter your local passphrase: (pass入力)
ポリシーファイルの暗号署名
twadmin -m P -S site.key twpol.txt
ポリシーファイルの暗号署名確認
twadmin -m p -c tw.cfg -p tw.pol
ベースラインデータベースの作成
# tripwire -m i
整合性チェック
# tripwire -m c
結果を標準出力に表示してくれる
実行テスト
チェック実行
# tripwire -m c -s -c /etc/tripwire/tw.cfg
レポートチェック
# twprint -m r -c tw.cfg -r "レポートファイル名" -L local.key -t 4
再チェック
# tripwire -m c -s -c /etc/tripwire/tw.cfg
Total violations found: 1
と出ていれば、更新された事を示す。
過去のチェック結果を参照する
twprint -m r -c /etc/tripwire/tw.cfg -r /usr/local/tripwire/lib/tripwire/report/example.com-20091201-180000.twr
レポートについて
tripwireコマンドで
Total violations found: *
というところが変化があったものの総数
この数があると、-Mした時にメールが飛ぶ
デフォルトのポリシーファイルを元にチューニングしていく方がセキュリティ的にも良いが
結構チューニングしないと、
ポリシーファイについて
第8回 Tripwireによるホスト型IDSの構築 殆どこちらからの転載です。
@@section
ポリシーファイルのセクションを指定します。「GLOBAL」はすべてに当てはまります。「FS」はUNIX(およびUNIX系OS)の場合に利用されるもので、Windows用ポリシーと区別するために用意されています。デフォルトでは、UNIXルールとして読み取られます。
属性
「()」でくくられている部分を「属性」と呼び、以下の4種類があります。
rulename
ルールブロックの名前を指定します。名前にスペースを入れるときは必ずダブルクオーテーションでくくる必要があります。rulenameで指定した名前で整合性チェックやレポートの作成が行われるので、分かりやすい名前にしておきましょう。
severity
重要度を0~1,000,000の範囲の値で設定します(デフォルトは0)。サンプルポリシーでは次のように定義されています。
SEC_LOW = 33;
SEC_MED = 66;
SEC_HI = 100;
例として挙げたポリシーの場合、Sample Policy1は「0」、Sample Policy2は「100」ということになります。
emailto
違反が発見されたときに通知するメールアドレスを指定します。
recurse
「true」「false」あるいは-1~1,000,000の範囲の数値でディレクトリに対する再帰の階層を指定します。「true」(-1)であれば、サブディレクトリやその中のファイルまですべてが監査対象となります(注)。「false」(0)にすると、サブディレクトリ内のファイルは監査しません。
ショートカットプロパティ
# ReadOnly:読み取り専用ファイル
+pinugtsdbmCM-rlacSHと同じ
# Dynamic:変化するファイル
+pinugtd-srlbamcCMSHと同じ
# Growing:サイズが大きくなるが小さくならないファイル
+pinugtdl-srbamcCMSHと同じ
# IngnoreAll:すべての属性を無視する
-pinugtsdrlbamcCMSHと同じ
# IgnoreNone:すべての属性を監査する
+pinugtsdrbamcCMSH-lと同じ
# Device:デバイスファイル
+pugsdr-intlbamcCMSHと同じ
■トラブルシューティング
*** No sendmail found. Edit install.cfg and set
サーバにsendmailが入っていない場合、上記のエラーでinstall.shが停止する。
この場合は、[ソースファイル]/install/install.cfgのTWMAILMETHODを、
TWMAILMETHOD=SMTP
としてやるとうまくいく。
Error: configuration parameter $TWPOLICY undefined
configure時にsysconfdir=を加えていないと出るぽい。
./configureファイルを見る限り、${prefix}/etcを参照しているようなのだが・・。
install.cfgのsysconfdirを設定してやれば通過出来る。
・・が、その後もcfgのパラメータが抜けてるエラーが連続する。
./configure時にsysconfdir=を入れておくほうが良さそう。
参考URL
- tripwireソース
- 第8回 Tripwireによるホスト型IDSの構築
- 第9回 Tripwire運用の勘所
- エンタープライズ:セキュリティ How-To - 第1回 Tripwireを導入
- CentOS ファイル改竄検知システムを導入する(Tripwire) 2
- ファイル改竄検知システム導入(Tripwire)
- Tripwire のインストールと設定についてのメモ
http://kapi.jp/kapi_blog/258
2009年12月21日
関連カテゴリ etc