Articles I've written for customers on IT issues.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
5.2 KiB

4 years ago
  1. \documentclass[11pt]{article}
  2. %Gummi|065|=)
  3. \title{\textbf{Setting up Tripwire with SSMTP}}
  4. \usepackage{graphicx}
  5. \usepackage{caption }
  6. \author{Steak Electronics}
  7. \date{06/4/19}
  8. \begin{document}
  9. %\maketitle
  10. \textbf{Setting up Tripwire with SSMTP}
  11. \tableofcontents
  12. \vspace{0.2in}
  13. This document is best read printed out on paper.
  14. %\textbf{Todo}
  15. \section{Overview}
  16. Tripwire is intrusion detection software for GNU Linux \& BSD. Let's document how to set it up on a server with SSMTP configured for email notifications. Tripwire isn't too hard to setup, but I had to jump through a hoop for email notifications. Here I cover install, and how to get SSMTP working.
  17. \section{Steps}
  18. \subsection{Configuring Tripwire}
  19. First install Tripwire. This will depend on your package manager. The two examples I have will be either Gentoo, or Debian/Devuan.
  20. \begin{verbatim}
  21. apt-get install tripwire mailutils ssmtp
  22. OR
  23. emerge -av tripwire mailutils ssmtp
  24. \end{verbatim}
  25. \subsubsection{Devuan/Debian}
  26. Devuan will prompt you for a few things in an ncurses gui. Answer all of the defaults (yes for a site key, yes for a user key, etc...). Record your password.
  27. \footnote{For a full walkthrough of this process see this URL:https://www.howtoforge.com/tutorial/how-to-monitor-and-detect-modified-files-using-tripwire-on-ubuntu-1604/ This process includes most, but not all of what you need to know.}
  28. I use the same password for both.
  29. \textbf{After install:}The goal when setting this up is to init, as little as possible. Each init is about 2-3 minutes, so time can be avoided, if you know what configs you need. Let's first edit the configs as much as possible.
  30. \begin{verbatim}
  31. when whitelisting, this is what needs to be commented out in devuan jessie/ascii for /etc/tripwire/twpol.txt
  32. Filename: /etc/rc.boot
  33. Filename: /root/mail
  34. Filename: /root/Mail
  35. Filename: /root/.xsession-errors
  36. Filename: /root/.xauth
  37. Filename: /root/.tcshrc
  38. Filename: /root/.sawfish
  39. Filename: /root/.pinerc
  40. Filename: /root/.mc
  41. Filename: /root/.gnome_private
  42. Filename: /root/.gnome-desktop
  43. Filename: /root/.gnome
  44. Filename: /root/.esd_auth
  45. Filename: /root/.elm
  46. Filename: /root/.cshrc
  47. Filename: /root/.bash_profile
  48. Filename: /root/.bash_logout
  49. Filename: /root/.amandahosts
  50. Filename: /root/.addressbook.lu
  51. Filename: /root/.addressbook
  52. Filename: /root/.Xresources
  53. Filename: /root/.Xauthority
  54. Filename: /root/.ICEauthority
  55. Filename: /proc/6136/fd/3
  56. Filename: /proc/6136/fdinfo/3
  57. Filename: /proc/6136/task/6136/fd/3
  58. Filename: /proc/6136/task/6136/fdinfo/3
  59. \end{verbatim}
  60. For proc, you simply comment out the whole directory. (you'll see an entry in the file for /proc, put a \# before that). After twpol, we are not done. We also need to edit the email settings.
  61. In /etc/tripwire/twcfg.txt we will change the following:
  62. \begin{verbatim}
  63. MAILMETHOD =SENDMAIL
  64. MAILPROGRAM =/root/script.sh
  65. \end{verbatim}
  66. script.sh is just a script: (make sure it is executable with chmod +x\footnote{This script appears to be required in this setup.})
  67. \begin{verbatim}
  68. #!/bin/bash
  69. /usr/sbin/sendmail -s youremail@domain.com
  70. \end{verbatim}
  71. Finally, the last change we might make, will be for any special directories we want to watch. I put websites in the root at /sites/ so I will append the following to /etc/tripwire/twpol.txt
  72. \begin{verbatim}
  73. # Ruleset for Website
  74. (
  75. rulename = "Website Ruleset",
  76. severity= $(SIG_HI)
  77. )
  78. {
  79. /sites/ -> $(SEC_CRIT);
  80. }
  81. \end{verbatim}
  82. Now we will init, type
  83. \begin{verbatim}
  84. sudo tripwire --init
  85. sudo twadmin -m P /etc/tripwire/twpol.txt
  86. sudo tripwire --init
  87. \end{verbatim}
  88. to reconfigure twcfg.txt
  89. run
  90. \\
  91. \textbf{/usr/sbin/twadmin --create-cfgfile -S site.key /etc/tripwire/twcfg.txt}
  92. if you get:
  93. \begin{verbatim}
  94. root@site:~# /usr/sbin/twadmin --create-cfgfile -S site.key /etc/tripwire/twcfg.txt
  95. # Error: File could not be opened.
  96. # Filename: /root/site.key
  97. # No such file or directory
  98. # Exiting...
  99. \end{verbatim}
  100. You must cd to /etc/tripwire directory.
  101. \subsection{Configuring SSMTP}
  102. SSMTP is a program you configure once, and can reuse the configuration everywhere\footnote{This is a strength of FOSS and let it remain that way.}. For starters, I'd recommend you install SSMTP according to this guide here:
  103. \begin{verbatim}
  104. https://wiki.zoneminder.com/How_to_get_ssmtp_working_with_Zoneminder
  105. \end{verbatim}
  106. This is a thorough guide that explains debugging. Some steps are superfluous (given that the instructions pertain to different software) but the general directions are sound. And afterwards sending an email is as easy as
  107. \\
  108. \\
  109. \textbf{echo "Hello, World" | mail -s "My email check" user@email.com}
  110. \\
  111. \\
  112. This guide assumes you have configured SSMTP according to this guide correctly, tested it, and are able to mail from the command line. Once you've setup SSMTP once, you can reproduce this setup on other computers, simply by copying over the revaliases and ssmtp.conf of a valid configuration.
  113. So let's do that. Copy over revaliases, and ssmtp.conf. test the configuration from the command line using the above echo and mail. Once that works, test out tripwire.
  114. \\
  115. \\
  116. \textbf{tripwire --test --email user@email.com}
  117. \\
  118. \\
  119. Done.
  120. \end{document}