Utilizzare Snort

Se non avete installato Snort, potete leggere questo nostro articolo su come installarlo su Raspberry Pi.

Se lo avete installato con il comando

apt-get install snort

Allora vi basta diminuire solamente il numero di max_tcp e lanciare il comando (vedi sotto)

snort -dev -l ./log -h 192.168.1.0/24 -c /etc/snort/snort.conf

Se lo avete installato compilando i sorgenti invece, la questione diventa più briosa in quanto occorre settare bene lo snort.config come di seguito.

Una volta installato occorre però aggiornarlo.

Seguiamo quindi i passi che ci dice la guida ufficiale su Snort.org allo Step 3:

0. Creare se non esistono le directory
root@kali:~/tmp# mkdir /etc/snort
root@kali:~/tmp# mkdir /etc/snort/rules
1. Community Rules
wget https://www.snort.org/rules/community
tar -xvfz community.tar.gz -C /etc/snort/rules
2. Registered Rules
wget https://www.snort.org/rules/snortrules-snapshot-2962.tar.gz?oinkcode=
wget https://www.snort.org/rules/snortrules-snapshot-2970.tar.gz?oinkcode=
wget https://www.snort.org/rules/snortrules-snapshot-2972.tar.gz?oinkcode=
tar -xvfz snortrules-snapshot-.tar.gz -C /etc/snort/rules
3. Subscriber Rules
... sono a pagamento ...

Creare la directory:

/usr/local/lib/snort_dynamicrules

Ridurre il max_tcp altrimenti il Raspberry non ce la fa… poverone! 😀

# Target-Based stateful inspection/stream reassembly.  For more inforation, see README.stream5
preprocessor stream5_global: track_tcp yes, \
   track_udp yes, \
   track_icmp no, \
   max_tcp 26214, \
   max_udp 131072, \
   max_active_responses 2, \
   min_response_seconds 5

cambiare i file di whitelist e blacklist:

white_list.rules -> whitelist.rule
black_list.rules -> blacklist.rule

# 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!!! 😀

[**] [1:888888:0] TEST PING *** ^^ *** ICMP Packet found [**]
[Priority: 0] 
03/27-21:14:27.294037 A8:20:66:27:D5:F6 -> E0:91:F5:F9:2D:4E type:0x800 len:0x62
192.168.0.6 -> 192.168.0.1 ICMP TTL:64 TOS:0x0 ID:12623 IpLen:20 DgmLen:84
Type:8  Code:0  ID:3591   Seq:0  ECHO
Utilizzare Snort