Ma per utilizzare Snort come IDS è necessario servirzi di un hardware dedicato: uno switch che abbia una porta in Mirroring.
Questo tipo di porte vengono anche chiamate TAP o Span port.
C’è chi si costruisce le sue span port “home made”, ma per essere un po’ più industriali e spendere poco possiamo comprare il Netgear GS105E che permette di mettere in mirroriing le porte su di un’altra.
# Reputation preprocessor. For more information see README.reputation
preprocessor reputation: \
memcap 500, \
priority whitelist, \
nested_ip inner, \
whitelist $WHITE_LIST_PATH/whitelist.rule, \
blacklist $BLACK_LIST_PATH/blacklist.rule
portarsi nella directory
/etc/snort/rules/etc
e lanciare il comando
snort -d -h 192.168.0.0/24 -l ./log -c snort.conf
I parametri dipendono ovviamente dal tipo di LAN che volete monitorare.
Per i dettagli leggere il manuale di Snort su Snort.org.
A questo punto per testarlo andiamo a mettere in
/etc/snort/rules/local.rules
la seguente regola
# $Id: local.rules,v 1.11 2004/07/23 20:15:44 bmc Exp $
# ----------------
# LOCAL RULES
# ----------------
# This file intentionally does not come with signatures. Put your local
# additions here.
# Test ping
#alert ip any any -> any any (msg: "IP Packet detected"; sid: 8888888)
alert icmp any any -> any any (msg: "TEST PING *** ^^ *** ICMP Packet found"; sid: 888888)
Che testa anche il PING essendo una richiesta echo ICMP.
Lanciamo snort e pinghiamo il nostro gateway:
ping 192.168.0.1
andiamo quindi ad analizzare i nostri alert
more ./log/alert
e vediamo che la nostra regola ha fatto scattare l’allarme!!! 😀
In questo articolo vedremo come installare un software per l’intrusion detection della nostra rete sul nostro Raspberry Pi.
Per prima cosa ci serve un sistema operativo opportuno da installare sul nostro Raspberry PI. Per questo tipo di applicazione ho scelto Kali linux il successore della distro linux BackTrack, famosissima nel campo della sicurezza IT.
Scarichiamo quindi l’immagine per processore ARM dal sito ufficiale:
Una volta scaricato occorre copiare l’immagine sull’SD card che volete utilizzare sul Raspberry con i comandi che trovare anche sull’articolo in questo blog relativo al backup e ripristino del vostro Raspberry PI.
Riporto qui i passi fatti sul mio MacBook Air:
Fabios-MacBook-Air:~ shadowsheep$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_HFS Macintosh HD 75.0 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
4: Microsoft Basic Data BOOTCAMP 45.5 GB disk0s4
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *8.1 GB disk1
1: DOS_FAT_32 CHIAVINA 8.1 GB disk1s1
Fabios-MacBook-Air:~ shadowsheep$ diskutil unmountDisk /dev/disk1
Unmount of all volumes on disk1 was successful
Fabios-MacBook-Air:~ shadowsheep$ cd Downloads/
Fabios-MacBook-Air:Downloads shadowsheep$ xz -d kali-1.1.0-rpi.img.xz
Fabios-MacBook-Air:Downloads shadowsheep$ sudo dd bs=1m if=kali-1.1.0-rpi.img of=/dev/disk1
Password:
3000+0 records in
3000+0 records out
3145728000 bytes transferred in 2055.895717 secs (1530101 bytes/sec)
Fabios-MacBook-Air:Downloads shadowsheep$
Il comando dd ci metterà un po’ a terminare. Una volta terminato avremo la nostra immagine installata sull’SD.
Una volta installata la nostra distro possiamo inseriamo l’SD card sul Raspberry e accendiamolo.
In questo tutorial io accederò al nostro Raspberry Pi solamente tramite SSH.
Ma prima occorre verificare che la dietro abbia ottenuto un IP valido e inoltre voglio ricreare una signature SSH differente da quella standard.
Per utilizzare il mio nuovo Raspberry Pi con Kali quindi attacchiamo una tastiera USB e un monitor che abbia l’ingresso HDMI.
L’utente root ha password “toor”. Cambiamola subito con “passwd”
root@kali:~# passwd
Enter new UNIX password:
Rigeneriamo quindi anche le chiave per l’SSH server
root@kali:~# cd /etc/ssh
root@kali:/etc/ssh# mkdir ssh_default_keys
root@kali:/etc/ssh# mv ssh_host* ssh_default_keys/
root@kali:/etc/ssh# dpkg-reconfigure openssh-server
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
[ ok ] Restarting OpenBSD Secure Shell server: sshd.
root@kali:/etc/ssh#
Da adesso possiamo collegarci tramite SSH.
Non avendo installato una versione di linux apposta per il Raspberry ci viene a mancare la comoda utility raspi-config. Andiamo quindi ad aggiungerla manualmente alla nostra installazione di Kali linux.
Una volta installato lanciamolo per espandere il nostro filesystem. Infatti l’immagine di Kali linux installata è stata fatta per essere ospitata da una SD da 4GB e quindi se ne abbiamo una più grande (come nel mio caso 8GB) dobbiamo appropriarci dello spazio mancante! 🙂
Se voltete installare l’ultima versione di Snort a partire dai sorgenti ufficiali sul sito potete seguire le istruzioni sul sito snort.org:
Se la configurazione del daq vi da errore perché manca la libreria libpcap allora dovete installarla:
apt-get install libpcap-dev
Al termine della compilazione e installazione del daq dovreste vedere un report simile a questo.
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib/daq
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Se la configurazione di snort vi da errore perché non trova le librerie libpcre e libante allora installatele con il comando:
Al termine invece di snort dovreste vedere un report simile a questo assieme a molte altre cose (tante!)
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib/snort/dynamic_output
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
A questo punto avete il vostro Snort installato!
root@kali:~/tmp/snort-2.9.7.2# snort -V
,,_ -*> Snort! <*-
o" )~ Version 2.9.7.2 GRE (Build 177)
'''' By Martin Roesch & The Snort Team: http://www.snort.org/contact#team
Copyright (C) 2014 Cisco and/or its affiliates. All rights reserved.
Copyright (C) 1998-2013 Sourcefire, Inc., et al.
Using libpcap version 1.3.0
Using PCRE version: 8.30 2012-02-04
Using ZLIB version: 1.2.7