Verbesserungsvorschläge (7) zu IPFire :

You would like to contribute something for IPFire?
Post Reply
Mapa
Posts: 53
Joined: August 3rd, 2017, 10:25 am

Verbesserungsvorschläge (7) zu IPFire :

Post by Mapa » March 2nd, 2018, 9:29 am

Verbesserungsvorschläge (7) zu IPFire :

Code: Select all

#!/bin/sh
########################################################################
# Begin $rc_base/init.d/guardian
#
# Description : Guardian Initscript
#
# Authors     : Kim Wölfel for ipfire.org
#
# Version     : 01.00
#
# Notes       : Mod. at 05.03.2018 through Mapa
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

eval $(/usr/local/bin/readhash /var/ipfire/guardian/settings)

GUARDIAN_CAT=`cat /var/ipfire/guardian/guardian.drop`
GUARDIAN_DROP=/var/ipfire/guardian/guardian.drop
GUARDIAN_DROP_TMP1=/var/ipfire/guardian/guardian1.tmp
GUARDIAN_DROP_TMP2=/var/ipfire/guardian/guardian2.tmp

function guardian_is_enabled() {
	[ "${GUARDIAN_ENABLED}" = "on" ]
}

case "$1" in
        start)
		guardian_is_enabled || exit 0
		if [ -f /run/guardian/guardian.pid ]; then
			boot_mesg "Guardian is running..."
			exit 0
		else
			boot_mesg "Starting Guardian..."
			loadproc /usr/sbin/guardian -c /var/ipfire/guardian/guardian.conf
			boot_mesg "Loading guardian.drop list ..."
			iptables -vnL GUARDIAN | sed 's/\s\+/ /g' | grep -v Chain | grep -v pkts | cut -d' ' -f9 > $GUARDIAN_DROP_TMP1
			cat $GUARDIAN_DROP $GUARDIAN_DROP_TMP1 | sort -n | uniq > $GUARDIAN_DROP_TMP2
			rm $GUARDIAN_DROP
			sort $GUARDIAN_DROP_TMP2 -n | uniq > $GUARDIAN_DROP
			iptables -F GUARDIAN
			for drop in $GUARDIAN_CAT; do
				iptables -A GUARDIAN -s $drop -j DROP
				sleep 0.01
			done
			rm $GUARDIAN_DROP_TMP1
			rm $GUARDIAN_DROP_TMP2
		fi
	;;

	stop)
		if ([ -f /run/guardian/guardian.pid ]); then
			boot_mesg "Saving guardian.drop list ..."
			iptables -vnL GUARDIAN | sed 's/\s\+/ /g' | grep -v Chain | grep -v pkts | cut -d' ' -f9 > $GUARDIAN_DROP_TMP1
			cat $GUARDIAN_DROP_TMP1 | sort -n | uniq > $GUARDIAN_DROP_TMP2
			rm $GUARDIAN_DROP
			sort $GUARDIAN_DROP_TMP2 -n | uniq > $GUARDIAN_DROP
			rm $GUARDIAN_DROP_TMP1
			rm $GUARDIAN_DROP_TMP2
			boot_mesg "Stopping Guardian..."
			kill $(cat /run/guardian/guardian.pid)
			sleep 1;
		fi
	;;

        status)
		statusproc /usr/sbin/guardian
	;;

	restart)
		$0 stop
		sleep 2
		$0 start
	;;

	*)
		echo "Usage: $0 {start|stop|restart|status}"
		exit 1
	;;
esac

# End $rc_base/init.d/guardian

Code: Select all

#!/bin/bash
########################################################################
# Begin  /etc/fcron.hourly/guardian.cron
#
# Description : This scrip copies every one hour, actual through
# 		guardian dropped IPs, to guardian.drop file located in
# 		/var/ipfire/guardian/guardian.drop
#
# Authors     : Mapa for ipfire.org
#
# Version     : 01.00
#
# Notes       : 01.03.2018
#
########################################################################

GUARDIAN_DROP=/var/ipfire/guardian/guardian.drop
GUARDIAN_DROP_TMP1=/var/ipfire/guardian/guardian1.tmp
GUARDIAN_DROP_TMP2=/var/ipfire/guardian/guardian2.tmp

		if ([ -f /run/guardian/guardian.pid ]); then

#			echo "guardian.cron saving guardian.drop list ..."
			iptables -vnL GUARDIAN | sed 's/\s\+/ /g' | grep -v Chain | grep -v pkts | cut -d' ' -f9 > $GUARDIAN_DROP_TMP1
			cat $GUARDIAN_DROP_TMP1 | sort -n | uniq > $GUARDIAN_DROP_TMP2
			rm $GUARDIAN_DROP
			sort $GUARDIAN_DROP_TMP2 -n | uniq > $GUARDIAN_DROP
			rm $GUARDIAN_DROP_TMP1
			rm $GUARDIAN_DROP_TMP2
		fi

Erfolgt ein IPFire Neustart, werden die IP's wieder geladen .
Diese IP's im GUI, nur durch doppelten Eintrag, sich löschen lassen, für den Fall, dass jemand diese gesperrten löschen möchte oder löschen muss .
Habe leider nicht die Zeit, den Grund im GUI Script zu suchen .

Beispiel :
Guardian frisch geblockte IP-1.png
Guardian frisch geblockte IP-1.png (9.66 KiB) Viewed 274 times
Guardian frisch geblockte IP-2.png
Guardian frisch geblockte IP-2.png (8.27 KiB) Viewed 274 times
Guardian frisch geblockte IP-3.png
Guardian frisch geblockte IP-3.png (9.77 KiB) Viewed 274 times
Guardian frisch geblockte IP-4.png
Guardian frisch geblockte IP-4.png (10.27 KiB) Viewed 274 times
Guardian frisch geblockte IP-5.png
Guardian frisch geblockte IP-5.png (9.48 KiB) Viewed 274 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest