![]() |
LINUX |
tripwireのインストール 4 Xen
*システムの変更をチェックし、管理者にメールを送ります
*tripwire-2.4.2をソースからインストールし、設定します
*ポリシーはfedora/epelのパッケージのものを参考にします
*サーバ構築の最終工程で設定を再確認します
*make はメンテナンスマシンで行っています
**以降はコメントです
*ソースの取得、削除は省略します
*エディタ、ファイラーの操作は省略します
* Enterキーを省略します
*ログイン端末で "#" はroot、"$" は一般ユーザのプロンプトの記号です
*設定ファイルで "#" で始まる行はコメントとして解釈されます
関連サイト| :tripwire-2.4.2-src.tar.bz2 | (http://sourceforge.net/projects/tripwire/) |
参照ファイル:パッケージの追加
:最初の設定 (Xen)
:opensslのインストール
インストール環境| :OS | CentOS 5.5 |
| :selinux | disabled |
| :インストール先 | /etc/tripwire /usr/local |
| :作業 | /usr/src /etc/tripwire |
| :言語 | LANG=en_US.UTF-8 |
| :ユーザー | rootで実行 |
tripwire-2.4.2
tripwireのインストール*openssl-develを必要とします
*8文字以上のパスフレーズを要求します
# cd /usr/src # tar jxvf tripwire-2.4.2-src.tar.bz2 # chown -R root:root tripwire-2.4.2-src # cd tripwire-2.4.2-src
*versionが2.4.1のままなのでpatchを当てます(下記参照)
*必須ではありません
# patch -p1 < ../tripwire-version.patch
# cp -a contrib install
# make distclean
# ./configure --sysconfdir=/etc/tripwire
# make
# make check
*install/install.cfgの修正(下記参照)
# vi install/install.cfg
# make install
*省略
Press ENTER to view the License Agreement.
*省略
[ do not accept]: accept
*省略
This program will copy Tripwire files to the following directories:
TWBIN: /usr/local/sbin
TWMAN: /usr/local/man
TWPOLICY: /etc/tripwire
TWREPORT: /var/lib/tripwire/report
TWDB: /var/lib/tripwire
TWSITEKEYDIR: /etc/tripwire
TWLOCALKEYDIR: /etc/tripwire
CLOBBER is false.
Continue with installation? [y/n] y
*省略
Enter the site keyfile passphrase:← サイトパスフレーズを入力 Verify the site keyfile passphrase:← 再入力 Generating key (this may take several minutes)...Key generation complete.
*省略
Enter the local keyfile passphrase:← ローカルパスフレーズを入力 Verify the local keyfile passphrase:← 再入力 Generating key (this may take several minutes)...Key generation complete.
*省略
Creating signed configuration file...
Please enter your site passphrase:← サイトパスフレーズを入力
Wrote configuration file: /etc/tripwire/tw.cfg
*省略
Creating signed policy file...
Please enter your site passphrase:← サイトパスフレーズを入力
Wrote policy file: /etc/tripwire/tw.pol
*省略
The installation succeeded.
*tripwire-checkスクリプトをコピーします
# cp contrib/tripwire-check /etc/cron.daily
# cd ..
# tar jcvf tripwire-2.4.2-100520.tar.bz2 tripwire-2.4.2-src/
*configure関連のファイルを修正するとMakefileの再構成を行うようです
*aclocal, automakeが呼び出されますが、設定が古いので修正しています
*CentOS5.5ではaclocal-1.9,automake-1.9が使われています
*manのversion設定は修正していません
:install/install.cfg
*既存のファイルを上書きしたい場合は CLOBBER=true にします
*省略
# If CLOBBER is true, then existing files are overwritten. CLOBBER=false
*省略
# Tripwire database files are stored in TWDB.
TWDB="/var/lib/tripwire"
*省略
# TWLOOSEDIRCHK selects whether the directory should be monitored for
# properties that change when files in the directory are monitored.
TWLOOSEDIRCHK=true
*省略
keyファイルの作成 (存在しない場合)*hostを変更した場合など
# cd /etc/tripwire # twadmin -m G -S site.key Enter the site keyfile passphrase:← サイトパスフレーズを入力 Verify the site keyfile passphrase:← 再入力 # twadmin -m G -L earth.528p.com-local.key Enter the local keyfile passphrase:← ローカルパスフレーズを入力 Verify the local keyfile passphrase:← 再入力
tw.cfgファイルの変更 (必要な場合):twcfg.txtを修正します
DBFILE=/var/lib/tripwire/$(HOSTNAME).twd REPORTFILE=/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr SITEKEYFILE =/etc/tripwire/site.key LOCALKEYFILE =/etc/tripwire/earth.528p.com-local.key LOOSEDIRECTORYCHECKING =true
*保存後
:新しいtw.cfgの作成
# cd /etc/tripwire
# twadmin -m F -S site.key twcfg.txt
Please enter your site passphrase:← サイトパスフレーズを入力
ポリシーファイルの作成:twpol.txtを修正します
"fedora/epel/5/tripwire*.rpm"のtwpol.txtを使います
@@section GLOBAL TWDOCS="/usr/local/doc/tripwire"; TWBIN=/usr/local/sbin; TWPOL="/etc/tripwire"; TWDB="/var/lib/tripwire"; TWSKEY="/etc/tripwire"; TWLKEY="/etc/tripwire"; TWREPORT="/var/lib/tripwire/report"; HOSTNAME=earth.528p.com;
:tw.polを作ります
*twpolmake.plを/etc/tripwireにおいて、ポリシーファイルを最適化します
*ポリシーファイル最適化スクリプト twpolmake.pl
*/dev,/proc,/var/lockのファイルを検査する場合、エディタで修正します
# cd /etc/tripwire # perl twpolmake.pl twpol.txt > twpol.txt.new
*差分をとって比較します
*検査するファイルをエディタで修正・追加します
# diff -ur twpol.txt twpol.txt.new > twpoltxt.diff # vi twpol.txt.new
*tw.polの作成
# twadmin -m P -S site.key twpol.txt.new
Please enter your site passphrase:← サイトパスフレーズを入力
データベースの更新*Errorログをファイルに出力します
# cd /etc/tripwire
# tripwire -m i 2> error.txt
Please enter your local passphrase:← ローカルパスフレーズを入力
:ポリシーファイルの更新
*error.txtをもとに、twpol.txt.newを修正し、tw.polを作成します
:再度、データベースの更新を実行します
*Errorがでなくなるまで繰り返します
定期的なチェック:/etc/cron.daily/tripwire-check (root root 700)
*紫色部分 インストールに合わせて変更
#!/bin/sh # # Tripwire cron script borrowed from Linux and modified for generic situations. # You should of course change path names to suit your environment. # # Contributed by Timothy K Ewing <Timothy.Ewing at celera.com> # HOST_NAME=`uname -n` TWCFG_PATH=/etc/tripwire TWDB_PATH=/var/lib/tripwire TWROOT_PATH=/usr/local/sbin MAILTO="root" # Email addresses that should recieve reports
#
# Define checks which alert user to misconfiguration or run the check
#
if [ ! -e ${TWDB_PATH}/${HOST_NAME}.twd ]; then
echo "**** Error: Tripwire database for ${HOST_NAME} not found. ****"
echo "**** Verify tripwire was installed and/or "tripwire --init". ****"
else
test -f ${TWCFG_PATH}/tw.cfg && ${TWROOT_PATH}/tripwire --check | \
mail -s "${HOST_NAME} tripwire-check" ${MAILTO}
fi
警告への対処の方法:変更に問題あり
*進入された形跡があり→問題が解明できない場合システムの再インストールが無難
:変更に問題なし (自分でファイルを編集した場合など)
*データベースを更新します
# tripwire -m u -r /var/lib/tripwire/report/**********.twr
**********は最新のファイル名を使う
*エディタviでファイルが開かれます
*[x]を[ ]にするとその項目だけ更新されません
ESCキー → :キー → :wq とキー入力します
Please enter your local passphrase:← ローカルパスフレーズを入力
:変更に問題なし (自分でファイルの場所を移動した場合など)
*ポリシーファイルを更新します
*update-policyの実行前にデータベースが変更されているとエラーがでます
*新しいファイル名を指定して実行します
# cd /etc/tripwire # tripwire -m p -S site.key newpolicy.txt Parsing policy file: /etc/tripwire/newpolicy.txt Please enter your local passphrase:← ローカルパスフレーズを入力 Please enter your site passphrase:← サイトパスフレーズを入力
参考*rpmパッケージから特定のファイルを取りだします
*コマンドのオプションは man で確認して下さい
# rpm2cpio tripwire* | cpio -it | less # rpm2cpio tripwire* | cpio -id ./etc/tripwire/twpol.txt
![]() |
Copyright(c) 528p.com All Rights Reserved. |

