7 #logsnorter user and group will be needed for starting up the daemon more securely (not as root)
8 stat_busy "Creating logsnorter group..."
11 stat_busy "Creating logsnorter user that has the ability parse logs..."
12 useradd logsnorter -c "The iptables log parser user" -d /dev/null -g logsnorter -s /bin/false
15 #the following is not needed when a central logging server is implemented
16 stat_busy "Changing iptables.log's permissions - group to logsnorter and rights to 640"
17 chown root.logsnorter /var/log/iptables.log
18 chmod 640 /var/log/iptables.log
21 stat_busy "Setting up the needed pear modules"
22 pear install Image_Color
24 pear install Numbers_Roman
25 pear install http://pear.php.net/get/Numbers_Words-0.13.1.tgz
26 pear install http://pear.php.net/get/Image_Graph-0.3.0dev4.tgz
29 #the following would be needed only if the central logging server is implemented
30 # stat_busy "Securing /var/log/probes..."
31 # chown logsnorter.root /var/log/probes
32 # chmod 420 /var/log/probes
37 There is some more to do:
39 1. set password for the user logsnorter
41 2. to make faster analysis possible, event cache autoupdate has been disabled in the config file.
42 Instead add these lines to crontab (crontab -e)
44 */5 * * * * lwp-request http://localhost/base/base_maintenance.php?submit=Update+Alert+Cache > /dev/null
45 */5 * * * * lwp-request http://localhost/base/base_maintenance.php?submit=Update+IP+Cache > /dev/null
46 */5 * * * * lwp-request http://localhost/base/base_maintenance.php?submit=Update+Whois+Cache > /dev/null
48 3. Customize logsnorter script to match your firewall. The included script is for iptables and Firestarter
51 Log file lines are in this format:
53 Jul 27 15:05:53 localhost Inbound IN=eth0 OUT= MAC=00:0c:76:41:a7:04:00:11:bb:ee:d5:c4:08:00 SRC=61.152.158.105
54 DST=58.73.110.25 LEN=514 TOS=0x00 PREC=0x00 TTL=48 ID=0 DF PROTO=UDP SPT=45842 DPT=1027 LEN=498
56 A line that parses one entry from iptables.log in function parse_iptables_logs looks like this:
57 if (/^(\w+)\s+([0-9]+) ([0-9]+):([0-9]+):([0-9]+) ([^\s]+) Inbound IN=(\w+[0-9]+) OUT= (MAC=)?([a-f,0-9,:]*)\s?SRC=([0-9\.]+)
58 DST=([0-9\.]+) LEN=([0-9]+) TOS=(\w+) PREC=(\w+) TTL=([0-9]+) ID=([0-9]+) (DF\s)?PROTO=(\w+) SPT=([0-9]+) DPT=([0-9]+)
59 WINDOW=([0-9]+) ([\w+\s]+)/) {
60 #If we audited an incoming TCP packet
63 Look for those Inbound/Outbound texts on the first line and write there the prefix that your firewall inserts to log lines. In this
64 example case it is ' Inbound IN='.
65 See also the description below each parsing if - condition to write the right kind of prefix for each protocol.
67 5. start up /etc/rc.d/snorterd and surf to localhost/base :)
77 #stopping the daemon if it is running
78 if [ "`pidof -o %PPID /usr/bin/logsnorter`" != "" ]; then
79 /etc/rc.d/snorterd stop
87 stat_busy "Deleting logsnorter user..."
91 stat_busy "Changing iptables.log's permissions back to normal - group to root and rights to 600"
92 chown root.root /var/log/iptables.log
93 chmod 600 /var/log/iptables.log