« IDS/Tripwire » : différence entre les versions

De TartareFR
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
== Installation ==
== Installation ==
L'installation est triviale car le paquet est présent dans les dépôts de base Fedora et dans les dépôts [[Distributions#D.C3.A9p.C3.B4ts_Additionnels_2|EPEL]] pour CentOS.
  yum install tripwire
  yum install tripwire


== First Setup ==
== Initialisation de l'application ==
=== By hands ===
 
The RPM comes with a default settings already configured.  You can see them if you browse to the /etc/tripwire directory on your system. There are a couple of steps that you have to follow before you can initialize the database, however.
L'installation via RPM installe un fichier de configuration et un fichier définissant la politique par défaut dans le dossier <path>/etc/tripwire</path>. Ces fichiers ne peuvent être utilisés directement par tripwire, car celui-ci travaille avec des fichiers cryptés.
 
La documentation (la page man de tripwire contient toutes les informations nécessaires) nous apprend qu'il va nous falloir 2 clés:
* '''site.key''': Une clé servant à encrypter le fichier de définition de la politique sur un ou plusieurs systèmes
* '''hostname-local.key'': Une autre clé servant uniquement à crypter les fichiers utilisés localement (il est donc unique sur chaque système)
Suivant l'opération à effectuer, une ou les deux clés seront requises.


As per the docs (the man pages have all the info you are looking for) you need to set up both a site and a local key.  The site key is used for encrypting the policy files across multiple systems.  The local key is used for encrypting files used only on the local machine.  The docs state that they one or both of the keys may be required based on what operation is being conducted.  I just set up both keys.  Remember to use strong pass-phrases.  The key locations are configured in the /etc/tripwire/twcfg.txt file, which will later be encrypted for use by the system.
=== Méthode manuelle ===
 
Génération de deux clés
<pre>
<pre>
twadmin -m G -v -S /etc/tripwire/site.key -Q passphrase
twadmin -m G -v -S /etc/tripwire/site.key -Q passphrase
Ligne 12 : Ligne 21 :
</pre>
</pre>


Now that you have the keys configured, you can go ahead and encrypt the configuration and policy files. Tripwire does this so that the files in use by the tripwire system cannot be modified.  If an attacker does get in, technically they can't modify those files.....
Une fois les clés générées, on va pouvoir encrypter le fichier de configuration et le fichier définissant la politique. C'est une protection contre la modification des fichiers par un éventuelle attaquant.
<pre>
<pre>
twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key -Q passphrase /etc/tripwire/twcfg.txt
twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key -Q passphrase /etc/tripwire/twcfg.txt
Ligne 18 : Ligne 27 :
</pre>
</pre>


=== With Script ===
=== Avec un Script ===
 
<pre>tripwire-setup-keyfiles</pre>
<pre>tripwire-setup-keyfiles</pre>
<pre>
----------------------------------------------
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:
Verify the site keyfile passphrase:
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:
Generating key (this may take several minutes)...Key generation complete.
----------------------------------------------
Signing configuration file...
Please enter your site passphrase:
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:
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.
</pre>
== Utilisation ==
=== Initialisation de la base de données ===


== Init ==
After that you can run the tripwire database init.
  tripwire -m i
  tripwire -m i


After that, you should be able to use tripwire open source.
=== Modification de la configuration ===
{{author|Shamir Charania||url=http://www.shamirc.com/2012/03/fedora-16-tripwireos-installation.html}}
 
Le premier rapport de tripwire va contenir beaucoup de faux-positif
<pre>
### Warning: File system error.
### Filename: /usr/sbin/fixrmtab
### Aucun fichier ou dossier de ce type
### Continuing...
</pre>
On va donc lister tous les fichiers inexistant
/usr/sbin/tripwire -m c | grep '### Filename' >> twtest.txt
et les commenter dans le fichier de définition de la politique <path>/etc/tripwire/twpol.txt</path>

Version du 17 décembre 2015 à 15:12

Installation

L'installation est triviale car le paquet est présent dans les dépôts de base Fedora et dans les dépôts EPEL pour CentOS.

yum install tripwire

Initialisation de l'application

L'installation via RPM installe un fichier de configuration et un fichier définissant la politique par défaut dans le dossier <path>/etc/tripwire</path>. Ces fichiers ne peuvent être utilisés directement par tripwire, car celui-ci travaille avec des fichiers cryptés.

La documentation (la page man de tripwire contient toutes les informations nécessaires) nous apprend qu'il va nous falloir 2 clés:

  • site.key: Une clé servant à encrypter le fichier de définition de la politique sur un ou plusieurs systèmes
  • 'hostname-local.key: Une autre clé servant uniquement à crypter les fichiers utilisés localement (il est donc unique sur chaque système)

Suivant l'opération à effectuer, une ou les deux clés seront requises.

Méthode manuelle

Génération de deux clés

twadmin -m G -v -S /etc/tripwire/site.key -Q passphrase
twadmin -m G -v -L /etc/tripwire/hostname-local.key -P passphrase

Une fois les clés générées, on va pouvoir encrypter le fichier de configuration et le fichier définissant la politique. C'est une protection contre la modification des fichiers par un éventuelle attaquant.

twadmin -m F -c /etc/tripwire/tw.cfg -S /etc/tripwire/site.key -Q passphrase /etc/tripwire/twcfg.txt
twadmin -m P -p /etc/tripwire/tw.pol -S /etc/tripwire/site.key -Q passphrase /etc/tripwire/twpol.txt

Avec un Script

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:
Verify the site keyfile passphrase:
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:
Generating key (this may take several minutes)...Key generation complete.

----------------------------------------------
Signing configuration file...
Please enter your site passphrase: 
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: 
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.

Utilisation

Initialisation de la base de données

tripwire -m i

Modification de la configuration

Le premier rapport de tripwire va contenir beaucoup de faux-positif

### Warning: File system error.
### Filename: /usr/sbin/fixrmtab
### Aucun fichier ou dossier de ce type
### Continuing...

On va donc lister tous les fichiers inexistant

/usr/sbin/tripwire -m c | grep '### Filename' >> twtest.txt

et les commenter dans le fichier de définition de la politique <path>/etc/tripwire/twpol.txt</path>