4:tripwireの設定

先ずはインストールだがEPELを有効にしておく事(ここの最後を参照)
参考(https://centossrv.com/tripwire.shtml
# dnf -y install tripwire   インストール
# tripwire-setup-keyfiles  設定ファイルを作成
表示が出た後
Enter the site keyfile passphrase:  ここで自分で決めたサイトPWを入力
Verify the site keyfile passphrase:  再度入力
少しして
Enter the local keyfile passphrase:  ここで自分で決めたローカルPWを入力
Verify the local keyfile passphrase:  再度入力 する
少しして
Please enter your site passphrase:   
となるので、サイトPWを入力 再度聞いてくる、
Please enter your site passphrase:   となるので、サイトPWを入力 これで終了
# gedit /etc/tripwire/twcfg.txt     設定の修正
ROOT =/usr/sbin
POLFILE =/etc/tripwire/tw.pol
DBFILE =/var/lib/tripwire/$(HOSTNAME).twd
REPORTFILE =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr
SITEKEYFILE =/etc/tripwire/site.key
LOCALKEYFILE =/etc/tripwire/$(HOSTNAME)-local.key
EDITOR =/bin/vi LATEPROMPTING =false
LOOSEDIRECTORYCHECKING =true    trueに変更
MAILNOVIOLATIONS =true
EMAILREPORTLEVEL =3
REPORTLEVEL =4             4に変更
MAILMETHOD =SENDMAIL
SYSLOGREPORTING =false
MAILPROGRAM =/usr/sbin/sendmail -oi -t
で保存しておく、次にTripwire設定ファイル(暗号署名版)作成
# twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
site passphraseを聞いてくるので入力。その後設定ファイルを削除
# rm -f /etc/tripwire/twcfg.txt
ポリシーファイル最適化スクリプト作成
# gedit /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 ← ポリシーファイル最適化
# echo ! “/var/lib/tripwire/`hostname`.twd ;” >> /etc/tripwire/twpol.txt.new ← Tripwireデータベース自体をチェック対象外にする
# echo ! “/tmp/tripwire.log ;” >> /etc/tripwire/twpol.txt.new ← Tripwireログをチェック対象外にする
最適化済ポリシーファイルを元にポリシーファイル(暗号署名版)作成
# twadmin -m P -c /etc/tripwire/tw.cfg -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key /etc/tripwire/twpol.txt.new
site passphraseを聞いてくるので入力。そしてポリシーファイル(テキスト版)削除
# rm -f /etc/tripwire/twpol.txt*
Tripwireデータベース作成
# tripwire -m i -s -c /etc/tripwire/tw.cfg
local passphraseを聞いてくるので入力 Tripwireチェック実行
# tripwire -m c -s -c /etc/tripwire/tw.cfg

Open Source Tripwire(R) 2.4.3.7 Integrity Check Report

Report generated by:          root
Report created on:            2023年01月17日 05時40分21秒
Database last updated on:     Never

=========================================================================
Report Summary:
=========================================================================

Host name:                    kvm5.inpac.jp
Host IP address:              133.149.213.105
Host ID:                      None
Policy file used:             /etc/tripwire/tw.pol
Configuration file used:      /etc/tripwire/tw.cfg
Database file used:           /var/lib/tripwire/kvm5.inpac.jp.twd
Command line used:            tripwire -m c -s -c /etc/tripwire/tw.cfg 

=========================================================================
Rule Summary: 
=========================================================================

-------------------------------------------------------------------------
  Section: Unix File System
-------------------------------------------------------------------------

  Rule Name                   Severity Level    Added    Removed Modified 
  ---------                       --------------    -----    -------  ---
  User binaries                   66                0        0        0        
  Tripwire Binaries               100               0        0        0        
  Libraries                       66                0        0        0        
  Operating System Utilities      100               0        0        0        
  File System and Disk Administraton Programs
                                  100               0        0        0        
  Kernel Administration Programs  100               0        0        0        
  Networking Programs             100               0        0        0        
  System Administration Programs  100               0        0        0        
  Hardware and Device Control Programs
                                  100               0        0        0        
  System Information Programs     100               0        0        0        
  (/sbin/runlevel)
  Application Information Programs
                                  100               0        0        0        
  (/sbin/rtmon)
  Critical Utility Sym-Links      100               0        0        0        
  Shell Binaries                  100               0        0        0        
  Critical system boot files      100               0        0        0        
* Tripwire Data Files             100               1        0        0        
  System boot changes             100               0        0        0        
  OS executables and libraries    100               0        0        0        
  Security Control                100               0        0        0        
  Login Scripts                   100               0        0        0        
  Critical configuration files    100               0        0        0        
* Root config files               100               0        0        1        
  Invariant Directories           66                0        0        0        
  Temporary directories           33                0        0        0        
  Critical devices                100               0        0        0        
  (/proc/kcore)

Total objects scanned:  44064
Total violations found:  2

=========================================================================
Object Summary: 
=========================================================================
# Section: Unix File System
-------------------------------------------------------------------------

-------------------------------------------------------------------------
Rule Name: Tripwire Data Files (/var/lib/tripwire)
Severity Level: 100
-------------------------------------------------------------------------

Added:
"/var/lib/tripwire/kvm5.inpac.jp.twd"

-------------------------------------------------------------------------
Rule Name: Root config files (/root)
Severity Level: 100
-------------------------------------------------------------------------

Modified:
"/root/.local/share/gnome-shell/application_state"

=========================================================================
Error Report: 
=========================================================================

No Errors

-------------------------------------------------------------------------
*** End of report ***

Open Source Tripwire 2.4 Portions copyright 2000-2018 Tripwire, Inc.  Tripwire is a registered
trademark of Tripwire, Inc. This software comes with ABSOLUTELY NO WARRANTY;
for details use --version. This is free software which may be redistributed
or modified only under certain conditions; see COPYING for details.
All rights reserved.

フジマル について

1947年生れ、東京電機大学二部電気通信工学科卒、最後はスリランカ航空で営業だったのですが2018年に㈱インパック・ジャパンに再就職。趣味:登山、スキー、車いじり、コンピューター
カテゴリー: AlmaLinuxに挑戦 パーマリンク

コメントを残す

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

CAPTCHA


このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください