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.

139 lines
5.0 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. \vspace{0.2in}
  12. This document is best read printed out on paper.
  13. %\textbf{Todo}
  14. \section{Overview}
  15. 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.
  16. \section{Steps}
  17. \subsection{Configuring Tripwire}
  18. First install Tripwire. This will depend on your package manager. The two examples I have will be either Gentoo, or Debian/Devuan.
  19. \begin{verbatim}
  20. apt-get install tripwire mailutils ssmtp
  21. OR
  22. emerge -av tripwire mailutils ssmtp
  23. \end{verbatim}
  24. \subsubsection{Devuan/Debian}
  25. 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.
  26. \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.}
  27. I use the same password for both.
  28. \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.
  29. \begin{verbatim}
  30. when whitelisting, this is what needs to be commented out in devuan jessie/ascii for /etc/tripwire/twpol.txt
  31. Filename: /etc/rc.boot
  32. Filename: /root/mail
  33. Filename: /root/Mail
  34. Filename: /root/.xsession-errors
  35. Filename: /root/.xauth
  36. Filename: /root/.tcshrc
  37. Filename: /root/.sawfish
  38. Filename: /root/.pinerc
  39. Filename: /root/.mc
  40. Filename: /root/.gnome_private
  41. Filename: /root/.gnome-desktop
  42. Filename: /root/.gnome
  43. Filename: /root/.esd_auth
  44. Filename: /root/.elm
  45. Filename: /root/.cshrc
  46. Filename: /root/.bash_profile
  47. Filename: /root/.bash_logout
  48. Filename: /root/.amandahosts
  49. Filename: /root/.addressbook.lu
  50. Filename: /root/.addressbook
  51. Filename: /root/.Xresources
  52. Filename: /root/.Xauthority
  53. Filename: /root/.ICEauthority
  54. Filename: /proc/6136/fd/3
  55. Filename: /proc/6136/fdinfo/3
  56. Filename: /proc/6136/task/6136/fd/3
  57. Filename: /proc/6136/task/6136/fdinfo/3
  58. \end{verbatim}
  59. 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.
  60. In /etc/tripwire/twcfg.txt we will change the following:
  61. \begin{verbatim}
  62. MAILMETHOD =SENDMAIL
  63. MAILPROGRAM =/root/script.sh
  64. \end{verbatim}
  65. script.sh is just a script: (make sure it is executable with chmod +x\footnote{This script appears to be required in this setup.})
  66. \begin{verbatim}
  67. #!/bin/bash
  68. /usr/sbin/sendmail -s youremail@domain.com
  69. \end{verbatim}
  70. 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
  71. \begin{verbatim}
  72. # Ruleset for Website
  73. (
  74. rulename = "Website Ruleset",
  75. severity= $(SIG_HI)
  76. )
  77. {
  78. /sites/ -> $(SEC_CRIT);
  79. }
  80. \end{verbatim}
  81. Now we will init, type
  82. \begin{verbatim}
  83. sudo tripwire --init
  84. sudo twadmin -m P /etc/tripwire/twpol.txt
  85. sudo tripwire --init
  86. \end{verbatim}
  87. to reconfigure twcfg.txt
  88. run
  89. \\
  90. \textbf{/usr/sbin/twadmin --create-cfgfile -S site.key /etc/tripwire/twcfg.txt}
  91. if you get:
  92. \begin{verbatim}
  93. root@site:~# /usr/sbin/twadmin --create-cfgfile -S site.key /etc/tripwire/twcfg.txt
  94. # Error: File could not be opened.
  95. # Filename: /root/site.key
  96. # No such file or directory
  97. # Exiting...
  98. \end{verbatim}
  99. You must cd to /etc/tripwire directory.
  100. \subsection{Configuring SSMTP}
  101. 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:
  102. \begin{verbatim}
  103. https://wiki.zoneminder.com/How_to_get_ssmtp_working_with_Zoneminder
  104. \end{verbatim}
  105. 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
  106. \\
  107. \\
  108. \textbf{echo "Hello, World" | mail -s "My email check" user@email.com}
  109. \\
  110. \\
  111. 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.
  112. 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.
  113. \\
  114. \\
  115. \textbf{tripwire --test --email user@email.com}
  116. \\
  117. \\
  118. Done.
  119. \end{document}