Tripwire è un sistema di rilevamento delle intrusioni basato su host per Linux. Tripwire monitora il sistema Linux per rilevare e segnalare eventuali modifiche non autorizzate ai file e alle directory. Una volta creata una linea di base, tripwire monitora e rileva quale file viene aggiunto, quale file viene modificato, cosa viene modificato, chi lo ha modificato e quando è stato modificato. Se le modifiche sono legittime, puoi aggiornare il database di tripwire per accettare queste modifiche.
Inoltre, per la soluzione di monitoraggio, fare riferimento a tutti i nostri precedenti articoli su Nagios
Questa guida di istruzioni passo passo spiega come installare e configurare la versione open source di tripwire.
1. Scarica Tripwire
Scarica l'ultima versione open source di tripwire dal sito web del progetto sourceforget di tripwire. Estrarre il codice sorgente di tripwire nella directory /usr/src come mostrato di seguito.
# cd /usr/src # wget http://internap.dl.sourceforge.net/sourceforge/tripwire/tripwire-2.4.1.2-src.tar.bz2 # bzip2 -d tripwire-2.4.1.2-src.tar.bz2 # tar xvf tripwire-2.4.1.2-src.tar
2. Installa Tripwire
Utilizzare l'opzione del prefisso come mostrato di seguito per specificare la directory di installazione. In questo esempio, ho installato tripwire in /opt/tripwire. Durante l'installazione, ti verranno richiesti vari input utente, che sono evidenziati in rosso di seguito.
# cd tripwire-2.4.1.2-src # ./configure --prefix=/opt/tripwire # make # make install make[3]: Entering directory `/usr/src/tripwire-2.4.1.2-src' prefix="/opt/tripwire" sysconfdir="/opt/tripwire/etc" \ path_to_vi="/bin/vi" path_to_sendmail="/usr/sbin/sendmail" \ ./install/install.sh Installer program for: Tripwire(R) 2.4 Open Source LICENSE AGREEMENT for Tripwire(R) 2.4 Open Source Please read the following license agreement. You must accept the agreement to continue installing Tripwire. Press ENTER to view the License Agreement. [Note: Press enter key as instructed to view the license] Please type "accept" to indicate your acceptance of this license agreement. [do not accept] accept [Note: Type accept to accept the license] This program will copy Tripwire files to the following directories: TWBIN: /opt/tripwire/sbin TWMAN: /opt/tripwire/man TWPOLICY: /opt/tripwire/etc TWREPORT: /opt/tripwire/lib/tripwire/report TWDB: /opt/tripwire/lib/tripwire TWSITEKEYDIR: /opt/tripwire/etc TWLOCALKEYDIR: /opt/tripwire/etc CLOBBER is false. Continue with installation? [y/n] y [Note: Press y to continue the installation] The Tripwire site and local passphrases are used to sign a variety of files, such as the configuration, policy, and database 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: [Note: Assign a passphrase for site keyfile.] 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: [Note: Assign a passphrase for local keyfile.] Creating signed configuration file... Please enter your site passphrase: Wrote configuration file: /opt/tripwire/etc/tw.cfg [Note: Enter the site passphrase.] Creating signed policy file... Please enter your site passphrase: Wrote policy file: /opt/tripwire/etc/tw.pol [Note: Enter the site passphrase] The installation succeeded.
- Passphrase del sito proteggerà il file di configurazione di tw.cfg tripwire
e il file della politica di tw.pol tripwire. Devi assegnare una passphrase del sito
anche per una singola istanza tripwire. - Passphrase locale proteggerà il database di tripwire e i file di report.
3. Inizializza il database di Tripwire
Per il primo utilizzo, è necessario inizializzare il database di tripwire come mostrato di seguito.
# cd /opt/tripwire/sbin/ # ./tripwire --init Please enter your local passphrase: Parsing policy file: /opt/tripwire/etc/tw.pol Generating the database... *** Processing Unix File System *** The object: "/sys" is on a different file system...ignoring. ### Warning: File system error. ### Filename: /cdrom ### No such file or directory ### Continuing... ### Warning: File system error. ### Filename: /floppy ### No such file or directory ### Continuing... ### Warning: File system error. ### Filename: /initrd ### No such file or directory ### Continuing... ### Warning: File system error. Wrote database file: /opt/tripwire/lib/tripwire/prod-db-srv.twd The database was successfully generated.
4. Modifica il file della politica di Tripwire
Come mostrato sopra, durante l'inizializzazione del database di tripwire, è possibile che venga visualizzato il messaggio di errore "Nessun file o directory del genere" per alcuni dei file predefiniti menzionati nel file della politica di tripwire. Se il tuo sistema non ha questi file, modifica il file delle norme e commenta le voci.
Ad esempio, modifica /opt/tripwire/etc/twpol.txt file della politica di tripwire e commenta /cdrom e /floppy come mostrato di seguito.
( rulename = "OS Boot Files and Mount Points", ) { /boot -> $(ReadOnly) ; # /cdrom -> $(Dynamic) ; # /floppy -> $(Dynamic) ; /mnt -> $(Dynamic) ; }
Utilizzando i file delle politiche di tripwire puoi definire le directory e i file che devono essere monitorati per le modifiche. Puoi anche essere più dettagliato e specificare gli attributi del file che devono essere monitorati o ignorati.
Di seguito sono riportate alcune delle proprietà del sistema UNIX monitorate da tripwire.
- Aggiunta, eliminazione e modifica di file
- Autorizzazioni e proprietà dei file
- Data e ora di accesso
- Data e ora di modifica
- Tipo e dimensione del file
- ID utente del proprietario e ID gruppo del proprietario
- Verifica hash:verifica della ridondanza ciclica a 32 bit conforme a CRC-32, POSIX 1003.2; MD5, l'algoritmo RSA Security Message Digest; SHA, parte dell'algoritmo SHS/SHA; HAVAL, un potente algoritmo di firma a 128 bit
5. Aggiorna il file delle norme di Tripwire
Dopo aver modificato il file delle norme, è necessario aggiornarlo come mostrato di seguito.
# ./tripwire --update-policy --secure-mode low ../etc/twpol.txt Parsing policy file: /opt/tripwire/etc/twpol.txt Please enter your local passphrase: Please enter your site passphrase: ======== Policy Update: Processing section Unix File System. ======== Step 1: Gathering information for the new policy. The object: "/sys" is on a different file system...ignoring. ======== Step 2: Updating the database with new objects. ======== Step 3: Pruning unneeded objects from the database. Wrote policy file: /opt/tripwire/etc/tw.pol Wrote database file: /opt/tripwire/lib/tripwire/prod-db-srv.twd
Nota: se dei file sono stati modificati dal momento in cui hai eseguito l'inizializzazione di tripwire fino al criterio di aggiornamento di tripwire, saranno elencati nell'output del "Passaggio 1:raccolta di informazioni per la nuova politica" del comando precedente.
### Warning: Policy Update Changed Object. ### An object has been changed since the database was last updated. ### Object name: Conflicting properties for object ### /u01/app/oracle/oradata/dbfiles/prod01.dbf ### > Modify Time ### > CRC32 ### > MD5
6. Verifica eventuali modifiche ai file e aggiorna il database di tripwire.
Una volta completata la configurazione di tripwire, è necessario eseguire regolarmente dei controlli per scoprire quali file sono stati aggiunti o modificati dall'ultimo aggiornamento del database di tripwire. Puoi eseguire questo controllo in modo interattivo dalla riga di comando come mostrato di seguito.
# ./tripwire --check --interactive Parsing policy file: /opt/tripwire/etc/tw.pol *** Processing Unix File System *** Performing integrity check... Wrote report file: /opt/tripwire/lib/tripwire/report/prod-db-srv-20081204-114336.twr
Questo aprirà automaticamente il seguente file di report di tripwire in vi, dove puoi rivedere tutti i file che sono stati aggiunti o modificati al sistema. Come mostrato di seguito, i file "Aggiunti" e "Modificati" avranno un segno di spunta davanti a loro, indicando che stai accettando che queste modifiche vengano aggiornate al database di tripwire.
=============================================================================== Report Summary: =============================================================================== Host name: prod-db-srv Host IP address: 192.168.1.10 Host ID: None Policy file used: /opt/tripwire/etc/tw.pol Configuration file used: /opt/tripwire/etc/tw.cfg Database file used: /opt/tripwire/lib/tripwire/prod-db-srv.twd Command line used: ./tripwire --check --interactive Remove the "x" from the adjacent box to prevent updating the database with the new values for this object. Added: [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/trace/proddb_m000_11376.trc" [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/trace/proddb_m000_11376.trm" Modified: [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/metadata/INC_METER_CONFIG.ams" [x] "/u01/app/oracle/diag/rdbms/proddb/proddb/metadata/INC_METER_INFO.ams" Added object name: /u01/app/oracle/diag/rdbms/proddb/proddb/trace/proddb_m000_11376.trc Property: Expected Observed ------------- ----------- ----------- * Object Type --- Regular File * Device Number --- 2049 * Inode Number --- 12026017 * Mode --- -rw-r----- * Num Links --- 1 * UID --- oracle (1082) * GID --- oinstall (1083) * Size --- 837 * Modify Time --- Sat 06 Dec 2008 10:01:51 AM PST * Blocks --- 8 * CRC32 --- AYxMeo * MD5 --- AXSkOul8R/np0fQP4q3QLv Modified object name: /u01/app/oracle/diag/tnslsnr/proddb/listener/trace/listener.log Property: Expected Observed ------------- ----------- ----------- Object Type Regular File Regular File Device Number 2049 2049 Inode Number 2295281 2295281 Mode -rw-r----- -rw-r----- Num Links 1 1 UID oracle (1082) oracle (1082) GID oinstall (1083) oinstall (1083) * Size 5851880 5858608 * Modify Time Sat 06 Dec 2008 09:58:53 AM PST Sat 06 Dec 2008 11:39:56 AM PST * Blocks 11456 11472 * CRC32 ANdM8R CK+bWM * MD5 DCW84lCuD2YJOhQd/EuVsn CV8BMvZNJB9KQBXAf5yRDY Please enter your local passphrase: Incorrect local passphrase. Please enter your local passphrase: Wrote database file: /opt/tripwire/lib/tripwire/prod-db-srv.twd
7. Come visualizzare il file del rapporto twr?
Tutti i file di report di tripwire con estensione *.twr sono archiviati nella directory /opt/tripwire/lib/tripwire/report. file di rapporto di tripwire *.twr non è un file di testo, che puoi visualizzare direttamente. Per visualizzare il rapporto, utilizzare twprint e convertire il file *.twr in un formato di testo leggibile come mostrato di seguito.
# ./twprint --print-report --twrfile \ /opt/tripwire/lib/tripwire/report/prod-db-srv-20081204-114336.twr > \ /tmp/readable-output.txt
8. Monitora regolarmente l'integrità del sistema Linux
Aggiungi il controllo tripwire come cron job per monitorare e segnalare eventuali modifiche su base continuativa. Ad esempio, aggiungi la seguente riga al tuo crontab per eseguire il controllo tripwire ogni giorno alle 4:00.
# Tripwire Monitor process 00 4 * * * /opt/tripwire/sbin/tripwire --check
9. Configurazione di Tripwire e posizioni dei file delle politiche
Utilizzare twadmin per visualizzare i file delle politiche di tripwire correnti. Di seguito viene mostrata solo l'uscita parziale.
#./twadmin --print-polfile @@section GLOBAL TWDOCS="/opt/tripwire/doc/tripwire"; TWBIN="/opt/tripwire/sbin"; TWPOL="/opt/tripwire/etc"; TWDB="/opt/tripwire/lib/tripwire"; TWSKEY="/opt/tripwire/etc"; TWLKEY="/opt/tripwire/etc"; TWREPORT="/opt/tripwire/lib/tripwire/report"; HOSTNAME=prod-db-srv;
Usa twadmin per ottenere informazioni su tutti i file di configurazione di tripwire come mostrato di seguito.
# ./twadmin --print-cfgfile ROOT =/opt/tripwire/sbin POLFILE =/opt/tripwire/etc/tw.pol DBFILE =/opt/tripwire/lib/tripwire/$(HOSTNAME).twd REPORTFILE =/opt/tripwire/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr SITEKEYFILE =/opt/tripwire/etc/site.key LOCALKEYFILE =/opt/tripwire/etc/prod-db-srv-local.key EDITOR =/bin/vi LATEPROMPTING =false LOOSEDIRECTORYCHECKING =false MAILNOVIOLATIONS =true EMAILREPORTLEVEL =3 REPORTLEVEL =3 MAILMETHOD =SENDMAIL SYSLOGREPORTING =false MAILPROGRAM =/usr/sbin/sendmail -oi -t
Se ti è piaciuto questo articolo, aggiungilo ai segnalibri su delicious, Digg and Stumble it .