updated on Thu Jan 26 00:18:00 UTC 2012
[aur-mirror.git] / ipt-base / ipt-base.install
blobc84e7af2ef1b214d8000a80b41580279623f9eda
1 . /etc/rc.conf
2 . /etc/rc.d/functions
4 post_install()
7    #logsnorter user and group will be needed for starting up the daemon more securely (not as root)
8    stat_busy "Creating logsnorter group..."
9      groupadd logsnorter
10    stat_done
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
13    stat_done
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
19    stat_done
21    stat_busy "Setting up the needed pear modules"
22      pear install Image_Color
23      pear install Log
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
27    stat_done
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
33 #   stat_done
35 /bin/cat <<THEEND
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
47   
48   3. Customize logsnorter script to match your firewall. The included script is for iptables and Firestarter
49      Here is an example:
51      Log file lines are in this format:
52           
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        
55          
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
61            . . . 
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.
66    
67   5. start up /etc/rc.d/snorterd and surf to localhost/base :)
70 ${EXTRATEXT}
71 THEEND
74 pre_remove()
77   #stopping the daemon if it is running
78   if [ "`pidof -o %PPID /usr/bin/logsnorter`" != "" ]; then
79        /etc/rc.d/snorterd stop
80   fi
83 post_remove()
86   #removing the user
87   stat_busy "Deleting logsnorter user..."
88     userdel logsnorter
89   stat_done
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
94   stat_done 
97 op=$1
98 shift
99 $op $*