Home > Articles > Home & Office Computing > The Web/Virtual Worlds/Social Networking

  • Print
  • + Share This
This chapter is from the book

Exercise 3: Tripwire

Description

The first objective of an attacker is to obtain access to your system. The second objective is to retain that access, even if you close the hole she entered. To accomplish this, an attacker will often install a rootkit.

A rootkit is a collection of modified system binaries that are designed to hide the attacker's activities on your system. Often, a modified login program is installed with a backdoor account for gaining access. A hacked version of ls is installed to hide the attacker's files from view. The ps routine can also be altered to prevent you from seeing the attacker's processes running on your system.

In this scenario, the question becomes, "How do you know if you can trust the information your system is giving you?" You need to be able to prove that critical programs are unaltered. It is the objective of host-based intrusion detection systems, such as Tripwire, to provide that proof.

Tripwire creates a database of advanced mathematical checksums to take a snapshot of a system's file properties and contents. A checksum is nothing more than the result of a complex mathematical calculation that uses the file's properties and contents as input. The calculations are designed so that even the smallest change of a single bit results in a vastly different result. Tripwire uses MD5, which is currently considered one of the strongest algorithms, to calculate checksums.

The key to using Tripwire successfully is to install it and calculate the checksums on the system before it is put into production or connected to the network. Otherwise, you could be calculating checksums for previously hacked files, which would render Tripwire useless. It is also imperative to regularly update the checksum database. Changes will be legitimately made to critical files, such as the password file. In order for Tripwire to maintain its value, it must reflect these changes. It is also vital that the database be secured in such a way that an attacker cannot alter it. CD-R drives or removable, write-disabled discs are often used for this task.

Starting with Red Hat 7.0, Tripwire has been included as part of the Linux license.

Objective

The objective of this exercise is to introduce you to the installation, configuration, and use of Tripwire as a host-based intrusion detection system.

Requirements

  • Hardware
    Intel-based PC running Red Hat Linux 7.2

  • Software
    Tripwire v2.3.1-5, available on CD 1 of the Red Hat Linux 7.2 distribution

Challenge Procedure

For this exercise you are going to perform the following steps:

  1. Install Tripwire.

  2. Complete the Tripwire installation and create Tripwire passwords.

  3. Configure Tripwire.

  4. Test Tripwire.

  5. Schedule a nightly Tripwire check.

Challenge Procedure Step-by-Step

The following are the detailed steps you are going to perform for this exercise:

  1. The first step is to install Tripwire. Log in to a Gnome session as root. Insert CD 1 of the Red Hat Linux 7.2 installation discs. Open a command prompt by clicking the Terminal Emulation icon, which is located on the Start bar. If you have not already done so, create a directory to hold the files that will be used by the exercises in this book:

  2. mkdir /usr/local/exercises

  3. Change the directory to the one you created in the previous step:

  4. cd /usr/local/exercises

    Figure 3.28

  5. Copy the Tripwire distribution to the exercises directory:

  6. cp /mnt/cdrom/RedHat/RPMS/tripwire-2.1.3-5.i386.rpm .

    Figure 3.29

  7. Install Tripwire with the following command:

  8. rpm –i tripwire-2.1.3-5.i386.rpm

    Figure 3.30

  9. Next, complete the Tripwire installation and create Tripwire passwords. Use the following command:

  10. /etc/tripwire/twinstall.sh

    Figure 3.31

  11. Create the site keyfile password.

  12. Figure 3.32

  13. Create the local keyfile password.

  14. Figure 3.33

  15. Sign the Tripware configuration file.

  16. Figure 3.34

  17. Sign the Tripware policy file.

  18. Figure 3.35

  19. Next, you'll configure Tripwire.

  20. Identify unnecessary system files that should not be validated with the following steps. This process is done to eliminate the false alarms that result from unnecessary file entries that are included with the default policy file.

  21. Install the default policy:

  22. /usr/sbin/twadmin -m P /etc/tripwire/twpol.txt

    Figure 3.36

  23. When prompted, enter your site password. Then, generate the initial checksum database:

  24. /usr/sbin/tripwire –m I

    Figure 3.37

  25. Create a list of files to remove from the policy file by running the following command:

  26. /usr/sbin/tripwire –m c | grep Filename > deletefiles

    Figure 3.38

  27. Open a second terminal emulation session. In it, list the files that need to be deleted from the policy file:

  28. vi deletefiles

    Figure 3.39

  29. In the original terminal emulation session, edit the default site policy file:

  30. vi /etc/tripwire/twpol.txt

    Figure 3.40

  31. Set the HOSTNAME variable to the system name. Find the HOSTNAME entry by pressing the forward slash (/) key and searching for localhost.

  32. Figure 3.41

  33. Enter cw to change localhost to Linux-Lab or the name of your system.

  34. Figure 3.42

  35. Press Esc to exit change mode. Lock files can change with every reboot, thus, comment out their entries with the following command:

  36. :g/\/var\/lock/s//\#\/var\/lock

    Figure 3.43

  37. Search for the remaining file entries to delete by pressing the forward slash key. Your cursor moves to the bottom-left corner of the screen. Type in the filename. Put a backslash (\) in front of the forward slashes in the filename. You can save keystrokes by just entering the filename. If you are not taken to the correct entry, just press n until you are.

  38. Figure 3.44

  39. Position the cursor on the first character and press i to enter insert mode. Comment out the entry by inserting the # symbol. Press Esc to exit insert mode.

  40. Figure 3.45

  41. Repeat steps 19–20 for each entry in the delete files.

  42. After the unnecessary files have been commented out, press ZZ to save the changes and exit vi. Repeat these steps until the unnecessary files have been eliminated from the policy.

  43. Now, you'll test Tripwire. Create a new root user with the following command:

  44. echo "badguy:x:0:0:Bad Guy:/bin/bash" >> /etc/passwd

    Figure 3.46

    WARNING

    Make sure that you enter both > symbols, or you will eliminate every other entry in the password file.

  45. Run a Tripwire check:

  46. /usr/sbin/tripwire –m c

    Figure 3.47

    Tripwire should detect that the /etc/passwd file has been changed.

    Figure 3.48

  47. Knowing a root account has been added, edit the passwd file:

  48. vi /etc/passwd

    Figure 3.49

  49. Press G to go to the end of the file. The last entry should begin with badguy.

  50. Figure 3.50

  51. Press dd to delete the badguy account. Then, press ZZ to save the changes and exit vi.

  52. Next, you need to schedule a nightly Tripwire check. Start the crontab editor:

  53. crontab –e

    Figure 3.51

  54. Press the a key to add an entry to root's crontab file. Add the following entry:

  55. 0 1 * * * /usr/sbin/tripwire –m c | mail root

    Figure 3.52

    NOTE

    This entry tells the scheduling function, cron, to run the Tripwire check every day at 1 a.m. By default, the output will be mailed to root. You can test the scheduling by changing the time it should run to a couple of minutes in the future. In the previous entry, the 0 corresponds to the minute, and the 1 is the hour the command should run. Change these values to change the time when cron should execute the check.

  56. Press ZZ to save the entry and quit the crontab editor. Verify that the job is scheduled with the following entry:

  57. crontab –l

    Figure 3.53

  58. If you set cron to test the check, after sufficient time check your mail:

  59. mail

    Finally, check the report that is generated.

    Figure 3.54

Additional Reading

Stancin, Aleksander. "Installing and Running Tripwire," Help Net Security, http://www.netsecurity.org/text/articles/tripwire.shtml.

Wreski, Dave. "Tripwire in the Enterprise: Integrating Tripwire into Big Brother," SysAdminThe Journal for UNIX Administrators, Volume 10, Number 8. August, 2001, http://www.samag.com/documents/s=1147/sam0108a/0108a.htm.

Summary

Tripwire is an example of host-based intrusion detection software that should be installed on every system.

Using a database of calculated checksums, Tripwire is capable of detecting when a critical system file is changed. It is also one of the only tools that will provide notification that a rootkit has been installed on your system.

In order to be assured that your system has not been attacked, Tripwire should be run on a regular basis. This can be done easily by using the cron function.

Changes detected by Tripwire should be investigated carefully. Generally, the alerts that are generated are the result of normal system operations. When the cause of an alert is identified and found to be legitimate, the Tripware database should be updated to reflect the system's new state.

  • + Share This
  • 🔖 Save To Your Account

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020