This guide documents how to install and configure Tripwire on a brand new system. This guide is based on installing Tripwire onto a Fedora system.
Description of tripwire “Open Source Tripwire software is a security and data integrity tool useful for monitoring and alerting on specific file change(s) on a range of systems”
-
Install Tripwire
Install tripwire from the yum repositories.
[root@server ~]# yum install tripwire
-
Backup Original Configuration
Backup original Tripwire configuration files before we make any changes.
[root@server ~]# mkdir /home/user/tripwire_backup [root@server ~]# cp /etc/tripwire/twcfg.txt /home/user/tripwire_backup/twcfg.txt [root@server ~]# cp /etc/tripwire/twpol.txt /home/user/tripwire_backup/twpol.txt
-
Directory Checking
Set Loose Directory Checking to true.
[root@server ~]# vi /etc/tripwire/twcfg.txt
Change
LOOSEDIRECTORYCHECKING =false
to
LOOSEDIRECTORYCHECKING =true
-
Create Keys
Create the keys for securing Tripwire.
[root@server ~]# /usr/sbin/tripwire-setup-keyfiles
---------------------------------------------- The Tripwire site and local passphrases are used to sign a variety of files, such as the configuration, policy, and database files. Passphrases should be at least 8 characters in length and contain both letters and numbers. See the Tripwire manual for more information. ---------------------------------------------- Creating key 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: <***secret-site-password***> Verify the site keyfile passphrase: <***secret-site-password***> 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: <***secret-local-password***> Verify the local keyfile passphrase: <***secret-local-password***> Generating key (this may take several minutes)…Key generation complete. ---------------------------------------------- Signing configuration file… Please enter your site passphrase: <***secret-site-password***> Wrote configuration file: /etc/tripwire/tw.cfg A clear-text version of the Tripwire configuration file: /etc/tripwire/twcfg.txt has been preserved for your inspection. It is recommended that you move this file to a secure location and/or encrypt it in place (using a tool such as GPG, for example) after you have examined it. ---------------------------------------------- Signing policy file… Please enter your site passphrase: <***secret-site-password***> Wrote policy file: /etc/tripwire/tw.pol A clear-text version of the Tripwire policy file: /etc/tripwire/twpol.txt has been preserved for your inspection. This implements a minimal policy, intended only to test essential Tripwire functionality. You should edit the policy file to describe your system, and then use twadmin to generate a new signed copy of the Tripwire policy. Once you have a satisfactory Tripwire policy file, you should move the clear-text version to a secure location and/or encrypt it in place (using a tool such as GPG, for example). Now run "tripwire --init" to enter Database Initialization Mode. This reads the policy file, generates a database based on its contents, and then cryptographically signs the resulting database. Options can be entered on the command line to specify which policy, configuration, and key files are used to create the database. The filename for the database can be specified as well. If no options are specified, the default values from the current configuration file are used.
-
Initialise DB
Initialize the Tripwire database. (A list of errors will be displayed these will be fixed later on)
[root@server ~]# tripwire --init
Please enter your local passphrase: <***secret-site-password***> Parsing policy file: /etc/tripwire/tw.pol Generating the database… *** Processing Unix File System *** ### Warning: File system error. ### Filename: /dev/kmem ### No such file or directory ### Continuing… ### Warning: File system error. ### Filename: /proc/ksyms ### No such file or directory ### Continuing… ### Warning: File system error. ### Filename: /dev/initctl ### No such file or directory ### Continuing… Wrote database file: /var/lib/tripwire/server.twd The database was successfully generated.
-
Fix Errors
Fix the Tripwire database errors.
Create a folder for the update process and change into that directory.
[root@server ~]# mkdir /home/user/tripwire_update [root@server ~]# cd /home/user/tripwire_update
This command will get all of the files that are causing problems because they dont exist and add them to a file which we will use to edit the policy file.
[root@server ~]# tripwire --check | grep "Filename:" | awk {'print $2'} >> ./tripwire_errorsCopy the policy file
[root@server ~]# cp /etc/tripwire/twpol.txt /home/user/tripwire_update/twpol.txt
Create the script that will automatically fix the errors listed in the tripwire_errors file created earlier and comment out the specific lines in the tripwire policy file.
[root@server ~]# vi ./tripwire_fix_script.sh
#!/bin/sh TWERR="./tripwire_errors" TWPOL="./twpol.txt" export IFS=$'\n' for i in $(cat $TWERR); do if grep $i $TWPOL then sed -i "s!$i!# $i!g" $TWPOL fi done
Run the script.
[root@server ~]# sh ./tripwire_fix_script.sh
Now copy the update policy file back to the original location.
[root@server ~]# cp /home/user/tripwire_update/twpol.txt /etc/tripwire/twpol.txt
Update the tripwire database from the tripwire policy we have created.
[root@server ~]# tripwire --update-policy -Z low /etc/tripwire/twpol.txt
Parsing policy file: /etc/tripwire/twpol.txt Please enter your local passphrase: <***secret-local-password***> Please enter your site passphrase: <***secret-site-password***> ======== Policy Update: Processing section Unix File System. ======== Step 1: Gathering information for the new policy. ======== Step 2: Updating the database with new objects. ======== Step 3: Pruning unneeded objects from the database. Wrote policy file: /etc/tripwire/tw.pol Wrote database file: /var/lib/tripwire/server.twd
Run a tripwire check.
[root@server ~]# tripwire --check
Parsing policy file: /etc/tripwire/tw.pol *** Processing Unix File System *** Performing integrity check… Wrote report file: /var/lib/tripwire/report/server-20090818-131022.twr Open Source Tripwire® 2.4.1 Integrity Check Report Report generated by: root Report created on: Tue 18 Aug 2009 13:10:22 BST Database last updated on: Tue 18 Aug 2009 13:08:30 BST =============================================================================== Report Summary: =============================================================================== Host name: server Host IP address: 127.0.0.1 Host ID: None Policy file used: /etc/tripwire/tw.pol Configuration file used: /etc/tripwire/tw.cfg Database file used: /var/lib/tripwire/server.twd Command line used: tripwire --check =============================================================================== Rule Summary: =============================================================================== ------------------------------------------------------------------------------- Section: Unix File System ------------------------------------------------------------------------------- Rule Name Severity Level Added Removed Modified --------- -------------- ----- ------- -------- Invariant Directories 66 0 0 0 Temporary directories 33 0 0 0 * Tripwire Data Files 100 0 0 1 Critical devices 100 0 0 0 User binaries 66 0 0 0 Tripwire Binaries 100 0 0 0 Libraries 66 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 Application Information Programs 100 0 0 0 (/sbin/rtmon) Shell Related Programs 100 0 0 0 Operating System Utilities 100 0 0 0 Critical Utility Sym-Links 100 0 0 0 Shell Binaries 100 0 0 0 Critical system boot files 100 0 0 0 System boot changes 100 0 0 0 OS executables and libraries 100 0 0 0 Critical configuration files 100 0 0 0 Security Control 100 0 0 0 Login Scripts 100 0 0 0 Root config files 100 0 0 0 Total objects scanned: 14663 Total violations found: 1 =============================================================================== Object Summary: =============================================================================== ------------------------------------------------------------------------------- # Section: Unix File System ------------------------------------------------------------------------------- ------------------------------------------------------------------------------- Rule Name: Tripwire Data Files (/etc/tripwire/tw.pol) Severity Level: 100 ------------------------------------------------------------------------------- Modified: "/etc/tripwire/tw.pol" =============================================================================== Error Report: =============================================================================== No Errors ------------------------------------------------------------------------------- *** End of report *** Open Source Tripwire 2.4 Portions copyright 2000 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. Integrity check complete.
-
Run a check
[root@server ~]# /etc/cron.daily/tripwire-check
-
Update (Again)
Update again to fix the error that will be displayed because we have updated the policy file. Change YYYYMMDD & HHMMSS to the date and time that you ran the first check. To find the latest one just do an ls-la on /var/lib/tripwire/report/
tripwire --update --twrfile /var/lib/tripwire/report/server-YYYMMDD-HHMMSS.twr
-
Email Reports
[root@server ~]# vi /etc/cron.daily/tripwire-check
Change:
test -f /etc/tripwire/tw.cfg && /usr/sbin/tripwire --check
to
test -f /etc/tripwire/tw.cfg && /usr/sbin/tripwire --check | /bin/mail -s "File Integrity Report (Tripwire) - servername" user@domain.tld
-
Directory Checking (Revert)
Set Loose Directory Checking to false.
[root@server ~]# vi /etc/tripwire/twcfg.txt
Change
LOOSEDIRECTORYCHECKING =true
to
LOOSEDIRECTORYCHECKING =false
-
Testing
This will run the cron.daily tripwire check script and email out a report to the email address you have specified.
[root@server ~]# /etc/cron.daily/tripwire-check
You now have a working tripwire setup, if any changes are made to your file system you will see them in the report that gets emailed out to you everyday. If you have made the changes dont forget to update, otherwise you will just see loads of errors and wont be able to tell if something is actually wrong.
Post a Comment