Tripwireセットアップ
提供:MDWiki
目次 |
インストール
# wget http://jaist.dl.sourceforge.net/sourceforge/tripwire/tripwire-2.4.2-src.tar.bz2 # tar xjf tripwire-2.4.2-src.tar.bz2 # cd tripwire-2.4.1.2-src # ./configure --prefix=/usr/local/tripwire sysconfdir=/etc/tripwire path_to_sendmail=/usr/sbin/sendmail | tee configure.log 2>&1 # make | tee make.log 2>&1 # make install | tee make-install.log 2>&1 ---------------------------------------------- Creating key files... Enter the site keyfile passphrase: Verify the site keyfile passphrase: Enter the local keyfile passphrase: Verify the local keyfile passphrase: Please enter your site passphrase: Please enter your site passphrase: ---------------------------------------------- The installation succeeded.
設定ファイルの編集
テキスト版の設定ファイルを編集してから、それを暗号化します。
# vi /etc/tripwire/twcfg.txt
設定ファイルの暗号化
# /usr/local/tripwire/sbin/twadmin --create-cfgfile -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt Please enter your site passphrase: Wrote configuration file: /etc/tripwire/tw.cfg # rm -f /etc/tripwire/twcfg.txt
テキスト版の設定ファイルは削除すること。暗号化されたファイルからテキスト版の設定ファイルを作成するには、
# /usr/local/tripwire/sbin/twadmin --print-cfgfile > /etc/tripwire/twcfg.txt
ポリシーファイルの編集
デフォルトのポリシーファイルは、存在しないディレクトリを探索したり、必要なディレクトリが探索されないため、ディストリビューションに合わせて設定内容を書き換えること。
# vi /etc/tripwire/twpol.txt
ポリシーファイルの暗号化
# /usr/local/tripwire/sbin/twadmin --create-polfile -S /etc/tripwire/site.key /etc/tripwire/twpol.txt Please enter your site passphrase: <= サイトパスフレーズ入力 Wrote policy file: /etc/tripwire/tw.pol # rm -f /etc/tripwire/twpol.txt
暗号化されたポリシーファイルからテキスト版のポリシーファイルを作成する場合は、
# /usr/local/tripwire/sbin/twadmin --print-polfile > /etc/tripwire/twpol.txt
データベースの作成
# LANG=C /usr/local/tripwire/sbin/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/[設定したファイル名].twd The database was successfully generated. === Tripwireチェック === <pre style="background-color: #2a2a2a; color: #ffffff;"> # LANG=C /usr/local/tripwire/sbin/tripwire --check Parsing policy file: /etc/tripwire/tw.pol *** Processing Unix File System *** Performing integrity check... Wrote report file: /var/lib/tripwire/report/[設定したファイル名].twr Tripwire(R) 2.4.1 Integrity Check Report Report generated by: root Report created on: LLL MMM DD HH:II:SS YYYY Database last updated on: Never =============================================================================== Report Summary: ===============================================================================
自動実行
cron登録する。ため、シェルスクリプト tripwire.sh を作成する。
# vi tripwire.sh
tripwire.sh の中身は、下記のとおり。
#!/bin/sh LANG=C TRIPWIRE=/usr/local/tripwire/sbin/tripwire TWADMIN=/usr/local/tripwire/sbin/twadmin TWPRINT=/usr/local/tripwire/sbin/twprint TRIPWIRE_POL=/etc/tripwire/tripwire_pol.pl SITEKEY=/etc/tripwire/site.key TWPOL_TXT=/etc/tripwire/twpol.txt TWPOL_TMP=/etc/tripwire/twpol.txt.tmp TWCFG=/etc/tripwire/tw.cfg LOG=/var/log/tripwire.log LOCALPASS=***************************** SITEPASS=****************************** $TRIPWIRE --check > $LOG $TWPRINT --print-report -c $TWCFG -t 4 $TWADMIN --print-polfile > $TWPOL_TXT $TRIPWIRE_POL $TWPOL_TXT > $TWPOL_TMP $TWADMIN --create-polfile -S $SITEKEY -Q $SITEPASS $TWPOL_TMP >> $LOG rm -f $TWPOL_TXT rm -f $TWPOL_TMP rm -f /usr/local/tripwire/lib/tripwire/*twd* $TRIPWIRE --init -P $LOCALPASS >> $LOG
tripwire.sh に実行権限を与える。
# chmod 700 /root/tripwire.sh
cronに登録する。
# crontab -e 05 * * * * /root/tripwire.sh
上記の内容だと、毎時5分に実行する。
リンク
- セキュリティ関連メモ のトップページへ
- メインページへ