diff --git a/rublock/README.md b/rublock/README.md new file mode 100644 index 0000000..36178cc --- /dev/null +++ b/rublock/README.md @@ -0,0 +1,3 @@ +# ruBlock + +bash script para bloquear rusia con iptables \ No newline at end of file diff --git a/rublock/ruBlock.sh b/rublock/ruBlock.sh new file mode 100755 index 0000000..64a67aa --- /dev/null +++ b/rublock/ruBlock.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# fanta +# ru block - Para bloquear toda Rusia con iptables. Ejecutar como root +# dependencies: bash wget curl iptables + +ipListUrl="https://www.ipdeny.com/ipblocks/data/countries/ru.zone" + +function main(){ + checkURL + downloadIPList + blockIP +} + +function checkURL(){ + errorCode=$(curl -kiss $ipListUrl | head -1 | cut -d " " -f 2) + if [ $errorCode != 200 ]; then echo "URL not found $ipListUrl"; exit; fi +} + +function downloadIPList(){ + wget -q "$ipListUrl" -O /tmp/.ips > /dev/null 2>&1 +} + +function blockIP(){ + while read -r ip; do echo "DROP $ip"; iptables -A INPUT -s $ip -j DROP; done < /tmp/.ips +} + +main