Free Web space and hosting from 2itb.com
Search the Web

 1  #!/bin/sh
 2  #
 3  # Einfache dynamische Firewall
 4  # benoetigt wird Netcat (nc)
 5  #
 6  # Kommandosyntax: dynfw.sh [stop]
 7  #
 8  # (c) 1999 by Robert Manea, DB4RM
 9
10  # Auf diesem Port wird gelauscht
11  PORT=139
12  MEINEIP="192.168.0.1"
13  # Mailadresse fuer Statusmeldungen
14  MAILTO="robert@localhost"
15
16  if [ $UID -ne 0 ]
17          echo "Nur root darf dieses Script ausfuehren"
18          exit 1
19  fi
20
21  case "$1" in
22       stop)
23          rm /tmp/dynfw.lock
24          killall -9 nc
25          ;;
26       *)
27          MALIP=`tail -1 dynfw.log|cut -d" " -f3|cut -d"[" -f2|cut -d"]" -f1`
28          # Hier die ipchains sachen
29          if [ -e /tmp/dynfw.lock ]; then
30            ipchains -A input -s $MALIP -d $MEINEIP 80 -j DENY
31            echo "ipchains -D -s $MALIP -d $MEINEIP 80 -j DENY" | at now + 2 hours
32            echo "Verbindung auf Port $PORT von $MALIP, setze DENY Regel !" | mail -s Netcat $MAILTO
33          fi
34
35          nc -v -l -p $PORT -s $MEINEIP -e dynfw.sh < /dev/null >> dynfw.log 2>&1 &
36          touch /tmp/dynfw.lock
37          ;;
38  esac