scanAlert.pl INSTALL

Installation instructions (simple version):

First copy scanAlert.pl, scanAlert.conf, and optionally rc.scanAlert 
to somewhere on your system.  The recomenended setup is:

 # cp scanAlert.pl /usr/local/sbin
 # cp scanAlert.conf /etc
 # cp rc.scanAlert /etc/rc.d


1. Configure IPTables to log suspicious packets.  
   
   Simply this could be something like this:

      iptables -A INPUT -m state --state INVALID -j LOG --log-prefix "INVALID packet: "
      iptables -A INPUT -m state --state NEW -p tcp -j LOG --log-prefix "NEW TCP packet: "
      iptables -A INPUT -m state --state NEW -p udp -j LOG --log-prefix "NEW UDP packet: "
      
   A little more advanced example would be something like this:   
   
      echo "First shut off everything"
                iptables -P INPUT DROP
                iptables -P OUTPUT DROP
                iptables -P FORWARD DROP

      echo "Allow loopback (localhost) traffic"
                iptables -A INPUT -i lo -d 127.0.0.0/8 -j ACCEPT
                iptables -A OUTPUT -o lo -d 127.0.0.0/8 -j ACCEPT

      echo "Allow outbound traffic, with sanity checks"
                iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

      echo "Allow related inbound traffic"
                iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

      echo "Allow incoming connections on tcp ports that you need"
                iptables -A INPUT -p tcp -m multiport --destination-port 22,80,631 -j ACCEPT

      echo "Log anything that we aren't expecting or that seems strange"
                iptables -A INPUT -m state --state INVALID -j LOG --log-prefix "INVALID packet: "
                iptables -A INPUT -p tcp -j LOG --log-prefix "UNMATCHED TCP packet: "
                iptables -A INPUT -p udp -j LOG --log-prefix "UNMATCHED UDP packet: "




2. Create a fifo for scanAlert.pl to receive messages on:
      
      mkfifo /var/log/fifo.scanAlert
      chmod 600 /var/log/fifo.scanAlert
      


3. Configure syslogd to send the messages generated in the step above to scanAlert.pl.
   You need to add a line like this to your /etc/syslog.conf:
   
      # Send iptable's log messages to scanAlert
      kern.*                                       |/var/log/fifo.scanAlert
   
   

4. Restart syslogd with a command like this: 
      
      killall -HUP syslogd

      
      
5. Start scanAlert.pl with a command like this:      
      
      /etc/rc.d/rc.scanAlert start
      

6. Monitor the scanAlert log file (usually /var/log/scanAlert.log) for activity 
   to ensure that it has started and is running correctly.  When a portscan is
   detected a message will be logged though syslogd (usually ending up in /var/log/messages)
   that will let you know something strange is going on.
   
   
7. If thresholds are too low/high or you need to ignore certian hosts or ports 
   simply edit the scanAlert.conf configuration file and then send a HUP signal
   to scanAlert to tell it to re-read its configuration file.
   
   