From c56397035521df2d34ece3cfcae9e72cf4e8de14 Mon Sep 17 00:00:00 2001 From: ChiefGyk Date: Wed, 29 Jun 2016 14:45:36 -0400 Subject: [PATCH] added dialog and blocks for korea as well as China --- blacklist => conf/blacklist | 0 conf/china | 7 +++++ conf/dialog.sh | 53 +++++++++++++++++++++++++++++++++++++ conf/korea | 7 +++++ conf/sinokorea | 7 +++++ dialog.sh | 33 ----------------------- install.sh | 5 ++-- 7 files changed, 77 insertions(+), 35 deletions(-) rename blacklist => conf/blacklist (100%) create mode 100644 conf/china create mode 100755 conf/dialog.sh create mode 100644 conf/korea create mode 100644 conf/sinokorea delete mode 100644 dialog.sh diff --git a/blacklist b/conf/blacklist similarity index 100% rename from blacklist rename to conf/blacklist diff --git a/conf/china b/conf/china new file mode 100644 index 00000000..5924bb83 --- /dev/null +++ b/conf/china @@ -0,0 +1,7 @@ +#!/bin/bash +curl http://www.okean.com/antispam/iptables/rc.firewall.china > /tmp/china.sh +chmod +x /tmp/china.sh +source /tmp/china.sh +rm -f /tmp/china.sh +ipset save > /etc/ipset.up.rules +iptables-save > /etc/iptables.up.rules diff --git a/conf/dialog.sh b/conf/dialog.sh new file mode 100755 index 00000000..7d500569 --- /dev/null +++ b/conf/dialog.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +HEIGHT=15 +WIDTH=40 +CHOICE_HEIGHT=4 +BACKTITLE="Do you want to block China and/or Korea?" +TITLE="Country Block" +MENU="A lot of spam originates from Korea and China. If you don't plan on having to ever have those countries connect to your server you may block them. \ + This will update weekly, and block all IP blocks to those countries \ + Choose one of the following options:" + +OPTIONS=(1 "China" + 2 "Korea" + 3 "China and Korea") + +CHOICE=$(dialog --clear \ + --backtitle "$BACKTITLE" \ + --title "$TITLE" \ + --menu "$MENU" \ + $HEIGHT $WIDTH $CHOICE_HEIGHT \ + "${OPTIONS[@]}" \ + 2>&1 >/dev/tty) + +clear +case $CHOICE in + 1) + echo "Bombing China" + echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections + echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections + cp china /etc/cron.weekly/china + chmod +x /etc/cron.weekly/china + time /etc/cron.weekly/china + apt-get install -y iptables-persistent + ;; + 2) + echo "Starting the Korean war again" + echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections + echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections + cp korea /etc/cron.weekly/korea + chmod +x /etc/cron.weekly/korea + time /etc/cron.weekly/korea + apt-get install -y iptables-persistent + ;; + 3) + echo "Blocking almost 1/3 of the world" + echo iptables-persistent iptables-persistent/autosave_v4 boolean true | debconf-set-selections + echo iptables-persistent iptables-persistent/autosave_v6 boolean true | debconf-set-selections + cp sinokorea /etc/cron.weekly/sinokorea + chmod +x /etc/cron.weekly/sinokorea + time /etc/cron.weekly/sinokorea + apt-get install -y iptables-persistent + ;; +esac \ No newline at end of file diff --git a/conf/korea b/conf/korea new file mode 100644 index 00000000..bad21291 --- /dev/null +++ b/conf/korea @@ -0,0 +1,7 @@ +#!/bin/bash +curl http://www.okean.com/antispam/iptables/rc.firewall.korea > /tmp/korea.sh +chmod +x /tmp/korea.sh +source /tmp/korea.sh +rm -f /tmp/korea.sh +ipset save > /etc/ipset.up.rules +iptables-save > /etc/iptables.up.rules diff --git a/conf/sinokorea b/conf/sinokorea new file mode 100644 index 00000000..75ca14d0 --- /dev/null +++ b/conf/sinokorea @@ -0,0 +1,7 @@ +#!/bin/bash +curl http://www.okean.com/antispam/iptables/rc.firewall.sinokorea > /tmp/sinokorea.sh +chmod +x /tmp/sinokorea.sh +source /tmp/sinokorea.sh +rm -f /tmp/sinokorea.sh +ipset save > /etc/ipset.up.rules +iptables-save > /etc/iptables.up.rules diff --git a/dialog.sh b/dialog.sh deleted file mode 100644 index fb177587..00000000 --- a/dialog.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -HEIGHT=15 -WIDTH=40 -CHOICE_HEIGHT=4 -BACKTITLE="Backtitle here" -TITLE="Title here" -MENU="Choose one of the following options:" - -OPTIONS=(1 "China" - 2 "Korea" - 3 "China and Korea") - -CHOICE=$(dialog --clear \ - --backtitle "$BACKTITLE" \ - --title "$TITLE" \ - --menu "$MENU" \ - $HEIGHT $WIDTH $CHOICE_HEIGHT \ - "${OPTIONS[@]}" \ - 2>&1 >/dev/tty) - -clear -case $CHOICE in - 1) - echo "You chose Option 1" - ;; - 2) - echo "You chose Option 2" - ;; - 3) - echo "You chose Option 3" - ;; -esac \ No newline at end of file diff --git a/install.sh b/install.sh index ed938074..0c0d9d08 100755 --- a/install.sh +++ b/install.sh @@ -13,13 +13,14 @@ if [[ $EUID -ne 0 ]]; then exit fi apt-get update -apt-get install -y ipset +apt-get install -y ipset dialog mkdir /etc/ipset ipset create blacklist hash:net iptables -I INPUT -m set --match-set blacklist src -j DROP -cp blacklist /etc/cron.daily/blacklist +cp conf/blacklist /etc/cron.daily/blacklist chmod a+x /etc/cron.daily/blacklist time /etc/cron.daily/blacklist +source conf/dialog.sh iptables-save > /etc/iptables.up.rules sed -i -e "\$apre-up ipset restore < /etc/ipset.up.rules" /etc/network/interfaces sed -i -e "\$apre-up iptables-restore < /etc/iptables.up.rules" /etc/network/interfaces