Home > Debian | UNIX > [Debian]Debian lennyで1からサーバーを作ってみる – tripwireをインストール

[Debian]Debian lennyで1からサーバーを作ってみる – tripwireをインストール

  • tripwireをインストール。サイトパスフレーズ、ローカルパスフレーズなどを作成するか?と聞いてくるので全て「Yes」と答えて設定する。
    # aptitude install tripwire
    # aptitude clean
  • Tripwire設定
    # 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
  • Tripwire設定ファイル削除
    # rm -f /etc/tripwire/twcfg.txt

    ※Tripwire設定ファイルを復元する場合

    # twadmin -m f -c /etc/tripwire/tw.cfg > /etc/tripwire/twcfg.txt
  • ポリシーファイル設定
    # vi /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*

    ※ポリシーファイルを復元する場合

    # twadmin -m p -c /etc/tripwire/tw.cfg -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key > /etc/tripwire/twpol.txt
  • データベース作成
    # tripwire -m i -s -c /etc/tripwire/tw.cfg
  • Tripwire実行確認
    # tripwire -m c -s -c /etc/tripwire/tw.cfg
  • Tripwire Cron設定
    # vi tripwire.sh
    #!/bin/bash
    
    LANG=C
    
    PATH=/usr/sbin:/usr/bin:/bin
    
    # パスフレーズ設定
    LOCALPASS=****** # ローカルパスフレーズ
    SITEPASS=******  # サイトパスフレーズ  
    
    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 /var/lib/tripwire/*.twd*
    tripwire -m i -s -c tw.cfg -P $LOCALPASS
    # chmod 700 tripwire.sh
    # crontab -e
    0 3 * * * /root/tripwire.sh ← 追記(毎日午前3時に実行)
  • 標準で/etc/cron.daily/に配置されるtripwireから実行権を無くしてcronから実行されなくする。
    # chmod -x /etc/cron.daily/tripwire

Comments:3

add to hatena hatena.comment (1) add to del.icio.us (0) add to livedoor.clip (0) add to Yahoo!Bookmark (0) Total: 1

hira 09-10-28 (水) 23:23

参考になる記事、ありがとうございます。
ポリシーファイル設定のwhile()の部分、無限ループになってませんか?
おそらく<POL>が抜けていると思います。

bubbkis 09-10-29 (木) 0:13

ご指摘ありがとうございます。
どうもwordpressプラグインのwp-syntaxが悪さしてるみたいです。
<POL>を不正なHTMLタグとして誤認識するようで、表示時に消してしまうようです。

wp-syntaxのFAQページ通り、

ビジュアルエディター使わない。
設定>投稿設定>不正にネスト化した XHTML を自動的に修正する のチェックを外す

をやってみたんですけど変わらないorz

多分、あちこちのページでこういう事になってると思います。すみません。
wp-syntax以外で何か探すか・・・

bubbkis 09-10-29 (木) 0:37

治りました。

<pre>タグにescaped=”true”を指定してあげる大丈夫なようです。
メモしておこう。

Comment Form
Remember personal info

Trackbacks:1

Trackback URL for this entry
http://ore.saizensen.net/archives/279/trackback
Listed below are links to weblogs that reference
[Debian]Debian lennyで1からサーバーを作ってみる – tripwireをインストール from おれ最前線ねっと
pingback from サーバーのセキュリティを強化する→その2:各種パッケージの導入 « SkyGarden出張所 10-05-17 (月) 21:42

[...] tripwireをインストール [...]

Home > Debian | UNIX > [Debian]Debian lennyで1からサーバーを作ってみる – tripwireをインストール

Search
Feeds
Meta

Return to page top