Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- cp /etc/apache2/conf-enabled/post-ip-bans.conf /etc/apache2/bak/post-ip-bans.conf.bak
- wget "http://list.iblocklist.com/?list=xoebmbyexwuiogmbyprb&fileformat=p2p&archiveformat=gz" -O tempProx.gz
- gzip -d tempProx.gz
- IPs1=($(grep ":.\+\-" tempProx -o | tr -d :-))
- rm tempProx
- wget "https://check.torproject.org/exit-addresses" -O tempProx
- IPs2=($(grep "ExitAddress" tempProx | cut -c 13- | sed 's/.\{20\}$//'))
- rm tempProx
- OLDIFS="$IFS"
- IFS=$'\n'
- combinedIPs=(`for R in "${IPs1[@]}" "${IPs2[@]}" ; do echo "$R" ; done | sort -du`)
- IFS="$OLDIFS"
- echo "<Location />" > /etc/apache2/conf-enabled/post-ip-bans.conf
- echo "<Limit POST PUT DELETE>" >> /etc/apache2/conf-enabled/post-ip-bans.conf
- echo "order allow,deny" >> /etc/apache2/conf-enabled/post-ip-bans.conf
- echo "allow from all" >> /etc/apache2/conf-enabled/post-ip-bans.conf
- for i in "${combinedIPs[@]}"
- do
- echo "deny from "$i"" >> /etc/apache2/conf-enabled/post-ip-bans.conf
- done
- echo "</Limit>" >> /etc/apache2/conf-enabled/post-ip-bans.conf
- echo "</Location>" >> /etc/apache2/conf-enabled/post-ip-bans.conf
- /etc/init.d/apache2 restart
- echo "Checking if apache2 started with our new config..."
- sleep 2
- apacheTest=$(pgrep apache)
- if [ -z "$apacheTest" ]; then
- echo "Apache2 failed to start! Applying previous config..."
- rm /etc/apache2/conf-enabled/post-ip-bans.conf
- mv /etc/apache2/bak/post-ip-bans.conf.bak /etc/apache2/conf-enabled/post-ip-bans.conf
- /etc/init.d/apache2 restart
- echo "Apache IP ban config failed to generate properly, or Apache2's configuration is broken!" >> /home/hunter/.ERRORS.txt
- else
- echo "Apache2 started with our new config! Yay!"
- rm /etc/apache2/bak/post-ip-bans.conf.bak
- fi
- exit 0
Add Comment
Please, Sign In to add comment