PCにそのままCentOS6.2をインスト(3)

1.ファイル改竄検知システム導入(Tripwire)をインスト
http://sourceforge.net/projects/tripwire/files/OldFiles/ で最新版をチェックすると、
Download tripwire-2.4.2.2-src.tar.bz2 (716.6 kB) となっていた。
ダウンロードして、
> wget   http://sourceforge.net/projects/tripwire/files/latest/download?source=files
> tar jxvf tripwire-2.4.2.2-src.tar.bz2
> cd tripwire-2.4.2.2-src
インスト開始。

> ./configure --prefix=/usr/local/tripwire sysconfdir=/etc/tripwire && make && make install
Press ENTER to view the License Agreement. [ENTER]
license agreement. [do not accept] [accept]
※ここでDELキーで修正したりするとエラーでインスト中止になる。
Continue with installation? [y/n] [y]
Enter the site keyfile passphrase: [xxxxxxxx]
Verify the site keyfile passphrase:
・・・
The installation succeeded.
後始末
> cd
> rm -rf tripwire-2.4.2.2-src
> rm -rf tripwire-2.4.2.2-src.tar.bz2
パスを通す
> echo PATH=$PATH:/usr/local/tripwire/sbin >> .bashrc ; source .bashrc
/etc/tripwire/twcfg.txt を修正
REPORTLEVEL   =  3 => 4
Tripwire設定ファイル(暗号署名版)作成
> twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
Tripwire設定ファイル(テキスト版)削除
> rm -f /etc/tripwire/twcfg.txt
ポリシーファイルを作る
/etc/tripwire/twpolmake.pl
---ココから---
#!/usr/bin/perl
# Tripwire Policy File customize tool
# ----------------------------------------------------------------
# Copyright (C) 2003 Hiroaki Izumi
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
# ----------------------------------------------------------------
# Usage:
#    perl twpolmake.pl {Pol file}
# ----------------------------------------------------------------
#
$POLFILE=$ARGV[0];
open(POL,"$POLFILE") or die "open error: $POLFILE" ;
my($myhost,$thost) ;
my($sharp,$tpath,$cond) ;
my($INRULE) = 0 ;
while (<POL>) {
    chomp;
    if (($thost) = /^HOSTNAME\s*=\s*(.*)\s*;/) {
        $myhost = `hostname` ; chomp($myhost) ;
        if ($thost ne $myhost) {
            $_="HOSTNAME=\"$myhost\";" ;
        }
    }
    elsif ( /^{/ ) {
        $INRULE=1 ;
    }
    elsif ( /^}/ ) {
        $INRULE=0 ;
    }
    elsif ($INRULE == 1 and ($sharp,$tpath,$cond) = /^(\s*\#?\s*)(\/\S+)\b(\s+->\s+.+)$/) {
        $ret = ($sharp =~ s/\#//g) ;
        if ($tpath eq '/sbin/e2fsadm' ) {
            $cond =~ s/;\s+(tune2fs.*)$/; \#$1/ ;
        }
        if (! -s $tpath) {
            $_ = "$sharp#$tpath$cond" if ($ret == 0) ;
        }
        else {
            $_ = "$sharp$tpath$cond" ;
        }
    }
    print "$_\n" ;
}
close(POL) ;
---ココまで---
最適化する
perl /etc/tripwire/twpolmake.pl /etc/tripwire/twpol.txt > /etc/tripwire/twpol.txt.new
(暗号署名版)作成
twadmin -m P -c /etc/tripwire/tw.cfg -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key /etc/tripwire/twpol.txt.new
後始末
rm -f /etc/tripwire/twpol.txt*
データベース作成
tripwire -m i -s -c /etc/tripwire/tw.cfg
動作確認
tripwire -m c -s -c /etc/tripwire/tw.cfg
定期自動実行スクリプト作成
tripwire.sh
---ココから---
#!/bin/bash
PATH=/usr/sbin:/usr/bin:/bin:/usr/local/tripwire/sbin
# パスフレーズ設定
LOCALPASS=xxxxxxxx # ローカルパスフレーズ
SITEPASS=xxxxxxxx  # サイトパスフレーズ
cd /etc/tripwire
# Tripwireチェック実行
tripwire -m c -s -c tw.cfg|mail -s "Tripwire(R) Integrity Check Report in `hostname`" root
# ポリシーファイル最新化
twadmin -m p -c tw.cfg -p tw.pol -S site.key > twpol.txt
perl twpolmake.pl twpol.txt > twpol.txt.new
twadmin -m P -c tw.cfg -p tw.pol -S site.key -Q $SITEPASS twpol.txt.new > /dev/null
rm -f twpol.txt* *.bak
# データベース最新化
rm -f /usr/local/tripwire/lib/tripwire/*.twd*
tripwire -m i -s -c tw.cfg -P $LOCALPASS
---ココまで---
実行設定&CRON登録
chmod 700 tripwire.sh
echo "0 3 * * * root /root/tripwire.sh" > /etc/cron.d/tripwire




コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA