Huntereb

Auto-download proxy and tor nodes

Jul 17th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.70 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. cp /etc/apache2/conf-enabled/post-ip-bans.conf /etc/apache2/bak/post-ip-bans.conf.bak
  4.  
  5. wget "http://list.iblocklist.com/?list=xoebmbyexwuiogmbyprb&fileformat=p2p&archiveformat=gz" -O tempProx.gz
  6. gzip -d tempProx.gz
  7. IPs1=($(grep ":.\+\-" tempProx -o | tr -d :-))
  8. rm tempProx
  9.  
  10. wget "https://check.torproject.org/exit-addresses" -O tempProx
  11. IPs2=($(grep "ExitAddress" tempProx | cut -c 13- | sed 's/.\{20\}$//'))
  12. rm tempProx
  13.  
  14. OLDIFS="$IFS"
  15. IFS=$'\n'
  16. combinedIPs=(`for R in "${IPs1[@]}" "${IPs2[@]}" ; do echo "$R" ; done | sort -du`)
  17. IFS="$OLDIFS"
  18.  
  19. echo "<Location />" > /etc/apache2/conf-enabled/post-ip-bans.conf
  20. echo "<Limit POST PUT DELETE>" >> /etc/apache2/conf-enabled/post-ip-bans.conf
  21. echo "order allow,deny" >> /etc/apache2/conf-enabled/post-ip-bans.conf
  22. echo "allow from all" >> /etc/apache2/conf-enabled/post-ip-bans.conf
  23.  
  24. for i in "${combinedIPs[@]}"
  25.     do
  26.         echo "deny from "$i"" >> /etc/apache2/conf-enabled/post-ip-bans.conf
  27. done
  28.    
  29. echo "</Limit>" >> /etc/apache2/conf-enabled/post-ip-bans.conf
  30. echo "</Location>" >> /etc/apache2/conf-enabled/post-ip-bans.conf
  31.  
  32. /etc/init.d/apache2 restart
  33. echo "Checking if apache2 started with our new config..."
  34. sleep 2
  35. apacheTest=$(pgrep apache)
  36.  
  37. if [ -z "$apacheTest" ]; then
  38.     echo "Apache2 failed to start! Applying previous config..."
  39.     rm /etc/apache2/conf-enabled/post-ip-bans.conf
  40.     mv /etc/apache2/bak/post-ip-bans.conf.bak /etc/apache2/conf-enabled/post-ip-bans.conf
  41.     /etc/init.d/apache2 restart
  42.     echo "Apache IP ban config failed to generate properly, or Apache2's configuration is broken!" >> /home/hunter/.ERRORS.txt
  43. else
  44.     echo "Apache2 started with our new config! Yay!"
  45.     rm /etc/apache2/bak/post-ip-bans.conf.bak
  46. fi
  47.  
  48. exit 0
Add Comment
Please, Sign In to add comment