Last-modified: 2013-03-17 (日) 01:44:46
tripwire/Debianへのインストール

概要

変更監視ツール tripwireをインストールする。

手順

  1. tripwireをインストールする。
    Everything is expanded.Everything is shortened.
      1
    
     
    
    apt-get install tripwire
  2. [はい]で続行。
    01.png
  3. [はい]で続行。
    02.png
  4. [はい]で続行。
    03.png
  5. [はい]で続行。
    04.png
  6. サイトパスフレーズを入力&再入力。
    05.png
  7. ローカルパスフレーズを入力&再入力。
    06.png
  8. [了解]で続行。
    07.png
  9. ポリシーファイルを調整するための確認を行う。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
    
    -
    !
    -
    !
    -
    !
     
    -
    |
    
    # DB初期化
    tripwire --init
    # チェック結果をresult.txtへリダイレクト
    tripwire --check > result.txt 2>&1
    # 失敗したパスを一覧表示する
    grep Filename result.txt
     
    # 失敗している原因は、ポリシーファイルに書かれたパスが存在しないため。
    # このエラーはチェック時にも毎回表示されて見にくいので、ポリシーファイルを調整する。
    
  10. /etc/tripwire/twpol.txtを編集する。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
    
    -
    |
    |
    |
    
    # twpol.txtは平文状態のポリシーファイル。実際に使用されるのはtw.pol。
    # 同じくtwcfg.txtは平文状態の設定ファイルで、使用されるのはtw.cfg。
    # 先ほどエラーとなったパスを探してコメントアウトする。
    # 監視したいパスがあれば追加する。
    
  11. /etc/tripwire/twcfg.txtを編集する。
    Everything is expanded.Everything is shortened.
      1
      2
    
    -
    !
    
    # ファイルの変更で親ディレクトリの変更を報告しない
    LOOSEDIRECTORYCHECKING =true
  12. 設定を反映する。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
    
    -
    !
    -
    !
    
    # twpol.txtからtw.polを作成
    twadmin -m P -S site.key twpol.txt
    # twcfg.txtからtw.cfgを作成
    twadmin -m F -S site.key twcfg.txt
  13. 再確認後、チェックを実行する。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
    
    -
    !
    -
    !
    
    # DB初期化
    tripwire --init
    # チェック
    tripwire --check
  14. 不要ファイル(*.txt、*.bak)を削除
    Everything is expanded.Everything is shortened.
      1
      2
    
     
     
    
    rm *.txt
    rm *.bak
  15. 私の環境ではtripwire_d.shを使用して定期実行を行っている。

補足

  1. /etc/tripwire/twpol.txtを編集。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
    
    -
    |
    !
    -
    !
     
     
    -
    |
    !
    -
    !
     
     
    -
    |
    |
    !
     
     
     
     
    -
    !
     
    
    # レポート送信先のメールアドレスを設定する。
    # アドレスをemailtoで設定し、括弧で適用範囲(ここでは全てを対象とする)を囲む。
     
    # 例.
    ファイル先頭
    ・・・
    SIG_HI        = 100 ;                # Critical files that are
    # significant points of
    # vulnerability
     
    # メール送信設定
    ( emailto = [email protected] )
    {
     
    #
    # Tripwire Binaries
    #
    (
        rulename = "Tripwire Binaries",
        severity = $(SIG_HI)
    )
    ・・・
    # メール送信設定閉じ括弧
    }
    ファイル末尾
  2. 設定を反映する。
    Everything is expanded.Everything is shortened.
      1
      2
    
    -
    !
    
    # twpol.txtからtw.polを作成
    twadmin -m P -S site.key twpol.txt
  3. /etc/cron.daily/tripwireを開く。
    毎日メールでレポートを飛ばすので、以前の結果はノイズでしかなく、都度除外ファイルを手動で選別するのも現実的ではないので、DB初期化処理を追加する。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
    
    -
    !
     
     
     
     
     
     
    -
    !
    -
    !
    
    #!/bin/sh
     
    tripwire=/usr/sbin/tripwire
     
    [ -x $tripwire ] || exit 0
     
    umask 027
     
    # チェック実行
    tripwire --check --quiet --email-report
    # DB初期化
    tripwire --init -P [ローカルパスフレーズ]
  4. /etc/cron.daily/tripwireにローカルパスフレーズを直書きするので、アクセス権限を変更
    Everything is expanded.Everything is shortened.
      1
    
     
    
    chmod 700 /etc/cron.daily/tripwire

検証時の環境