Tripwire は、Linux 用のホスト ベースの侵入検知システムです。 Tripwire は Linux システムを監視して、ファイルやディレクトリへの不正な変更を検出して報告します。ベースラインが作成されると、Tripwire は、どのファイルが追加され、どのファイルが変更され、何が変更され、誰が変更し、いつ変更されたかを監視および検出します。変更が正当なものであれば、tripwire データベースを更新してこれらの変更を受け入れることができます。
また、監視ソリューションについては、Nagios に関する以前のすべての記事を参照してください
この手順ガイドでは、オープン ソース バージョンの tripwire をインストールして構成する方法について説明します。
1. Tripwire をダウンロード
最新の tripwire オープン ソース バージョンを tripwire sourceforget プロジェクト Web サイトからダウンロードします。以下に示すように、tripwire ソース コードを /usr/src ディレクトリに抽出します。
# cd /usr/src # wget http://internap.dl.sourceforge.net/sourceforge/tripwire/tripwire-2.4.1.2-src.tar.bz2 # bzip2 -d tripwire-2.4.1.2-src.tar.bz2 # tar xvf tripwire-2.4.1.2-src.tar
2.トリップワイヤーをインストール
以下に示すように、プレフィックス オプションを使用して、インストール ディレクトリを指定します。この例では、tripwire を /opt/tripwire の下にインストールしました。 make install の間、以下の赤で強調表示されているさまざまなユーザー入力を求めるプロンプトが表示されます。
# cd tripwire-2.4.1.2-src # ./configure --prefix=/opt/tripwire # make # make install make[3]: Entering directory `/usr/src/tripwire-2.4.1.2-src' prefix="/opt/tripwire" sysconfdir="/opt/tripwire/etc" \ path_to_vi="/bin/vi" path_to_sendmail="/usr/sbin/sendmail" \ ./install/install.sh Installer program for: Tripwire(R) 2.4 Open Source LICENSE AGREEMENT for Tripwire(R) 2.4 Open Source Please read the following license agreement. You must accept the agreement to continue installing Tripwire. Press ENTER to view the License Agreement. [Note: Press enter key as instructed to view the license] Please type "accept" to indicate your acceptance of this license agreement. [do not accept] accept [Note: Type accept to accept the license] This program will copy Tripwire files to the following directories: TWBIN: /opt/tripwire/sbin TWMAN: /opt/tripwire/man TWPOLICY: /opt/tripwire/etc TWREPORT: /opt/tripwire/lib/tripwire/report TWDB: /opt/tripwire/lib/tripwire TWSITEKEYDIR: /opt/tripwire/etc TWLOCALKEYDIR: /opt/tripwire/etc CLOBBER is false. Continue with installation? [y/n] y [Note: Press y to continue the installation] The Tripwire site and local passphrases are used to sign a variety of files, such as the configuration, policy, and database files. (When selecting a passphrase, keep in mind that good passphrases typically have upper and lower case letters, digits and punctuation marks, and are at least 8 characters in length.) Enter the site keyfile passphrase: Verify the site keyfile passphrase: [Note: Assign a passphrase for site keyfile.] Generating key (this may take several minutes)...Key generation complete. (When selecting a passphrase, keep in mind that good passphrases typically have upper and lower case letters, digits and punctuation marks, and are at least 8 characters in length.) Enter the local keyfile passphrase: Verify the local keyfile passphrase: [Note: Assign a passphrase for local keyfile.] Creating signed configuration file... Please enter your site passphrase: Wrote configuration file: /opt/tripwire/etc/tw.cfg [Note: Enter the site passphrase.] Creating signed policy file... Please enter your site passphrase: Wrote policy file: /opt/tripwire/etc/tw.pol [Note: Enter the site passphrase] The installation succeeded.
- サイトのパスフレーズ tw.cfg tripwire 構成ファイル
および tw.pol tripwire ポリシー ファイルを保護します。
単一インスタンスのトリップワイヤーであっても、サイト パスフレーズを割り当てる必要があります。 - ローカル パスフレーズ tripwire データベースとレポート ファイルを保護します。
3. Tripwire データベースの初期化
初めて使用する場合は、以下に示すように tripwire データベースを初期化する必要があります。
# cd /opt/tripwire/sbin/ # ./tripwire --init Please enter your local passphrase: Parsing policy file: /opt/tripwire/etc/tw.pol Generating the database... *** Processing Unix File System *** The object: "/sys" is on a different file system...ignoring. ### Warning: File system error. ### Filename: /cdrom ### No such file or directory ### Continuing... ### Warning: File system error. ### Filename: /floppy ### No such file or directory ### Continuing... ### Warning: File system error. ### Filename: /initrd ### No such file or directory ### Continuing... ### Warning: File system error. Wrote database file: /opt/tripwire/lib/tripwire/prod-db-srv.twd The database was successfully generated.
4. Tripwire ポリシー ファイルの変更
上記のように、tripwire データベースの初期化中に、tripwire ポリシー ファイルに記載されているデフォルト ファイルの一部について、「No such file or directory」というエラー メッセージが表示される場合があります。システムにこれらのファイルがない場合は、ポリシー ファイルを編集し、それらのエントリにコメントを付けてください。
たとえば、/opt/tripwire/etc/twpol.txt を変更します。 以下に示すように、tripwire ポリシー ファイルを開き、/cdrom と /floppy をコメント アウトします。
( rulename = "OS Boot Files and Mount Points", ) { /boot -> $(ReadOnly) ; # /cdrom -> $(Dynamic) ; # /floppy -> $(Dynamic) ; /mnt -> $(Dynamic) ; }
tripwire ポリシー ファイルを使用して、変更を監視する必要があるディレクトリとファイルを定義できます。また、監視または無視するファイル属性をより細かく指定することもできます。
以下は、tripwire によって監視される UNIX システム プロパティの一部です。
- ファイルの追加、削除、修正
- ファイルのパーミッションとプロパティ
- アクセス タイムスタンプ
- 変更のタイムスタンプ
- ファイルの種類とファイル サイズ
- 所有者のユーザー ID と所有者のグループ ID
- ハッシュ チェック:CRC-32、POSIX 1003.2 準拠の 32 ビット巡回冗長検査。 MD5、RSA セキュリティ メッセージ ダイジェスト アルゴリズム。 SHA、SHS/SHA アルゴリズムの一部。 HAVAL、強力な 128 ビット署名アルゴリズム
5. Tripwire ポリシー ファイルの更新
ポリシー ファイルを変更したら、以下に示すように更新する必要があります。
# ./tripwire --update-policy --secure-mode low ../etc/twpol.txt Parsing policy file: /opt/tripwire/etc/twpol.txt Please enter your local passphrase: Please enter your site passphrase: ======== Policy Update: Processing section Unix File System. ======== Step 1: Gathering information for the new policy. The object: "/sys" is on a different file system...ignoring. ======== Step 2: Updating the database with new objects. ======== Step 3: Pruning unneeded objects from the database. Wrote policy file: /opt/tripwire/etc/tw.pol Wrote database file: /opt/tripwire/lib/tripwire/prod-db-srv.twd
注: tripwire の初期化を行ってから tripwire のポリシーを更新するまでに変更されたファイルがある場合、それらは上記のコマンドの「ステップ 1:新しいポリシーの情報を収集する」出力の下に一覧表示されます。
### Warning: Policy Update Changed Object. ### An object has been changed since the database was last updated. ### Object name: Conflicting properties for object ### /u01/app/oracle/oradata/dbfiles/prod01.dbf ### > Modify Time ### > CRC32 ### > MD5
6.ファイルへの変更を確認し、tripwire データベースを更新してください。
トリップワイヤーのセットアップが完了したら、トリップワイヤー データベースが最後に更新されてから追加または変更されたファイルを確認するために、定期的にチェックを実行する必要があります。以下に示すように、コマンド ラインから対話的にこのチェックを実行できます。
# ./tripwire --check --interactive Parsing policy file: /opt/tripwire/etc/tw.pol *** Processing Unix File System *** Performing integrity check... Wrote report file: /opt/tripwire/lib/tripwire/report/prod-db-srv-20081204-114336.twr
これにより、次の tripwire レポート ファイルが vi で自動的に開き、システムに追加または変更されたすべてのファイルを確認できます。以下に示すように、「追加済み」および「変更済み」ファイルの前にチェック マークが表示され、これらの変更を承認して tripwire データベースに更新することを示します。
=============================================================================== Report Summary: =============================================================================== Host name: prod-db-srv Host IP address: 192.168.1.10 Host ID: None Policy file used: /opt/tripwire/etc/tw.pol Configuration file used: /opt/tripwire/etc/tw.cfg Database file used: /opt/tripwire/lib/tripwire/prod-db-srv.twd Command line used: ./tripwire --check --interactive Remove the "x" from the adjacent box to prevent updating the database with the new values for this object. Added: [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/trace/proddb_m000_11376.trc" [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/trace/proddb_m000_11376.trm" Modified: [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/metadata/INC_METER_CONFIG.ams" [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/metadata/INC_METER_INFO.ams" Added object name: /u01/app/oracle/diag/rdbms/proddb/proddb/trace/proddb_m000_11376.trc Property: Expected Observed ------------- ----------- ----------- * Object Type --- Regular File * Device Number --- 2049 * Inode Number --- 12026017 * Mode --- -rw-r----- * Num Links --- 1 * UID --- oracle (1082) * GID --- oinstall (1083) * Size --- 837 * Modify Time --- Sat 06 Dec 2008 10:01:51 AM PST * Blocks --- 8 * CRC32 --- AYxMeo * MD5 --- AXSkOul8R/np0fQP4q3QLv Modified object name: /u01/app/oracle/diag/tnslsnr/proddb/listener/trace/listener.log Property: Expected Observed ------------- ----------- ----------- Object Type Regular File Regular File Device Number 2049 2049 Inode Number 2295281 2295281 Mode -rw-r----- -rw-r----- Num Links 1 1 UID oracle (1082) oracle (1082) GID oinstall (1083) oinstall (1083) * Size 5851880 5858608 * Modify Time Sat 06 Dec 2008 09:58:53 AM PST Sat 06 Dec 2008 11:39:56 AM PST * Blocks 11456 11472 * CRC32 ANdM8R CK+bWM * MD5 DCW84lCuD2YJOhQd/EuVsn CV8BMvZNJB9KQBXAf5yRDY Please enter your local passphrase: Incorrect local passphrase. Please enter your local passphrase: Wrote database file: /opt/tripwire/lib/tripwire/prod-db-srv.twd
7. TWR レポート ファイルの表示方法
拡張子が *.twr の Tripwire レポート ファイルはすべて、/opt/tripwire/lib/tripwire/report ディレクトリに保存されます。 tripwire レポート ファイル *.twr は、直接表示できるテキスト ファイルではありません。レポートを表示するには、twprint を使用して、以下に示すように *.twr ファイルを読み取り可能なテキスト形式に変換します。
# ./twprint --print-report --twrfile \ /opt/tripwire/lib/tripwire/report/prod-db-srv-20081204-114336.twr > \ /tmp/readable-output.txt
8. Linux システムの整合性を定期的に監視する
tripwire チェックを cron ジョブとして追加して、継続的に変更を監視および報告します。たとえば、crontab に次の行を追加して、毎日午前 4:00 に tripwire チェックを実行します。
# Tripwire Monitor process 00 4 * * * /opt/tripwire/sbin/tripwire --check
9. Tripwire の設定とポリシー ファイルの場所
twadmin を使用して、現在の tripwire ポリシー ファイルを表示します。部分的な出力のみを以下に示します。
#./twadmin --print-polfile @@section GLOBAL TWDOCS="/opt/tripwire/doc/tripwire"; TWBIN="/opt/tripwire/sbin"; TWPOL="/opt/tripwire/etc"; TWDB="/opt/tripwire/lib/tripwire"; TWSKEY="/opt/tripwire/etc"; TWLKEY="/opt/tripwire/etc"; TWREPORT="/opt/tripwire/lib/tripwire/report"; HOSTNAME=prod-db-srv;
以下に示すように、twadmin を使用して、すべての tripwire 構成ファイルに関する情報を取得します。
# ./twadmin --print-cfgfile ROOT =/opt/tripwire/sbin POLFILE =/opt/tripwire/etc/tw.pol DBFILE =/opt/tripwire/lib/tripwire/$(HOSTNAME).twd REPORTFILE =/opt/tripwire/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr SITEKEYFILE =/opt/tripwire/etc/site.key LOCALKEYFILE =/opt/tripwire/etc/prod-db-srv-local.key EDITOR =/bin/vi LATEPROMPTING =false LOOSEDIRECTORYCHECKING =false MAILNOVIOLATIONS =true EMAILREPORTLEVEL =3 REPORTLEVEL =3 MAILMETHOD =SENDMAIL SYSLOGREPORTING =false MAILPROGRAM =/usr/sbin/sendmail -oi -t
この記事が気に入ったら、デリシャス、ディグ、つまずくにブックマークしてください .