
Tripwire是用于Linux的基于主机的入侵检测系统。 Tripwire监视Linux系统,以检测并报告对文件和目录的任何未经授权的更改。创建基准后,tripwire会监视并检测添加的文件,更改的文件,更改的内容,更改的人以及更改的时间。如果更改是合法的,则可以更新tripwire数据库以接受这些更改。
另外,有关监视解决方案,请参阅我们以前关于以下内容的所有文章: 纳吉奥斯
本逐步说明指南说明了如何安装和配置Tripwire的开源版本。
1.下载Tripwire
从下载最新的Tripwire开源版本 绊线 Sourceforget项目网站。如下所示将tripwire源代码提取到/ usr / src目录中。
# cd /usr/src # wget http://internap.dl.sourceforge.net/sourceforge/tripwire/tripwire-2.4.1.2-src.tar.bz2 # bzip2 -d 绊线-2.4.1.2-src.tar.bz2 # tar xvf 绊线-2.4.1.2-src.tar
2.安装Tripwire
使用如下所示的prefix选项来指定安装目录。在这个例子中,我’在/ opt / 绊线下安装了tripwire。在进行安装期间,它将提示您输入各种用户输入,下面以红色突出显示。
# cd 绊线-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 / 绊线"sysconfdir ="/ opt / 绊线/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 / 绊线/sbin TWMAN: / opt / 绊线/man TWPOLICY: / opt / 绊线/etc TWREPORT: / opt / 绊线/lib/tripwire/report TWDB: / opt / 绊线/lib/tripwire TWSITEKEYDIR: / opt / 绊线/etc TWLOCALKEYDIR: / opt / 绊线/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 / 绊线/etc/tw.cfg [Note: Enter the site passphrase.] Creating signed policy file... Please enter your site passphrase: Wrote policy file: / opt / 绊线/etc/tw.pol [Note: Enter the site passphrase] The installation succeeded.
- 网站密码 将保护tw.cfg 绊线配置文件
和tw.pol 绊线策略文件。您必须分配一个站点密码
即使是单个实例的绊网。 - 本地密码 将保护Tripwire数据库和报告文件。
3.初始化Tripwire数据库
初次使用时,应如下所示初始化tripwire数据库。
# cd / opt / 绊线/sbin/ # ./绊线--init 请输入您的本地密码: Parsing policy file: / opt / 绊线/etc/tw.pol 生成数据库... ***处理Unix文件系统*** The object: "/ sys"在不同的文件系统上...ignoring. ###警告:文件系统错误。 ### Filename: /cdrom ### 无此文件或目录 ### Continuing... ###警告:文件系统错误。 ### Filename: /floppy ### 无此文件或目录 ### Continuing... ###警告:文件系统错误。 ### Filename: /initrd ### 无此文件或目录 ### Continuing... ###警告:文件系统错误。 Wrote database file: / opt / 绊线/lib/tripwire/prod-db-srv.twd The database was successfully generated.
4.修改Tripwire策略文件
如上所示,在tripwire数据库初始化期间,它可能会显示“无此文件或目录”Tripwire策略文件中提到的某些默认文件的错误消息。如果您的系统没有’没有这些文件,请编辑策略文件并注释这些条目。
例如,修改 / opt / 绊线/etc/twpol.txt 绊线策略文件,并注释掉/ cdrom和/ floppy,如下所示。
( rulename = "OS Boot Files and Mount Points", ) { /boot -> $(ReadOnly) ; # /cdrom -> $(Dynamic) ; # /floppy -> $(Dynamic) ; /mnt -> $(Dynamic) ; }
使用tripwire策略文件,您可以定义需要监视更改的目录和文件。您还可以更精细地指定应该监视或忽略的文件属性。
以下是Tripwire监视的一些UNIX系统属性。
- 文件添加,删除和修改
- 文件权限和属性
- 访问时间戳
- 修改时间戳
- 文件类型和大小
- 所有者的用户标识和所有者的组标识
- 哈希检查:符合CRC-32,POSIX 1003.2的32位循环冗余校验; MD5,RSA安全消息摘要算法; SHA,是SHS / SHA算法的一部分; HAVAL,强大的128位签名算法
5.更新Tripwire策略文件
一旦您’如果已修改策略文件,则需要对其进行更新,如下所示。
# ./绊线--update-policy --安全模式低../etc/twpol.txt Parsing policy file: / opt / 绊线/etc/twpol.txt 请输入您的本地密码: Please enter your site passphrase: ======== Policy Update: Processing section Unix File System. ======== 步骤1:收集新政策的信息. The object: "/ sys"在不同的文件系统上...ignoring. ======== Step 2: Updating the database with new objects. ======== Step 3: Pruning unneeded objects from the database. Wrote policy file: / opt / 绊线/etc/tw.pol Wrote database file: / opt / 绊线/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设置完成后,您应该定期执行检查,以查找自上次Triptrip数据库更新以来添加或修改了哪些文件。您可以从命令行以交互方式执行此检查,如下所示。
# ./绊线--check --interactive Parsing policy file: / opt / 绊线/etc/tw.pol ***处理Unix文件系统*** Performing integrity check... Wrote report file: /opt/tripwire/lib/tripwire/report/prod-db-srv-20081204-114336.twr
这将自动在vi中打开以下Tripwire报告文件,您可以在其中查看已添加或修改到系统的所有文件。如下图所示“Added” and “Modified”文件前面将带有复选标记,表示您接受这些更改以更新为Tripwire数据库。
=============================================================================== Report Summary: =============================================================================== Host name: prod-db-srv Host IP address: 192.168.1.10 Host ID: None Policy file used: / opt / 绊线/etc/tw.pol Configuration file used: / opt / 绊线/etc/tw.cfg Database file used: / opt / 绊线/lib/tripwire/prod-db-srv.twd Command line used: ./绊线--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 链接s --- 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 链接s 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 请输入您的本地密码: Incorrect local passphrase. 请输入您的本地密码: Wrote database file: / opt / 绊线/lib/tripwire/prod-db-srv.twd
7.如何查看twr报告文件?
所有扩展名为* .twr的Tripwire报告文件都存储在/ opt / 绊线 / lib / 绊线 / report目录下。 绊线报告文件* .twr不是文本文件,您可以直接查看。为了查看报告,请使用twprint并将* .twr文件转换为可读文本格式,如下所示。
# ./twprint --print-report --twrfile \ /opt/tripwire/lib/tripwire/report/prod-db-srv-20081204-114336.twr > \ /tmp/readable-output.txt
8.定期监视Linux系统完整性
将绊线检查添加为cron作业,以持续监视和报告任何更改。例如,将以下行添加到您的crontab中,以每天凌晨4:00执行Tripwire检查。
# Tripwire Monitor process 00 4 * * * / opt / 绊线/sbin/tripwire --check
9. Tripwire配置和策略文件位置
使用twadmin查看当前的Tripwire策略文件。下面仅显示部分输出。
#./twadmin --print-polfile @@section GLOBAL TWDOCS="/ opt / 绊线/doc/tripwire"; TWBIN="/ opt / 绊线/sbin"; TWPOL="/ opt / 绊线/etc"; TWDB="/ opt / 绊线/lib/tripwire"; TWSKEY="/ opt / 绊线/etc"; TWLKEY="/ opt / 绊线/etc"; TWREPORT="/ opt / 绊线/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
如果您喜欢这篇文章,请在其上添加书签 美味,Digg和绊倒它.
如果您喜欢这篇文章,您可能还会喜欢..
![]() |
![]() |
![]() |
![]() |
很棒的教程!!非常感谢!!