quietcinsarmy.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. BADGUYS_FILE="" # The location (full path) where you want to download the list
  3. CHAIN_NAME="CINSARMY_IPS" # The firewall chain to hold the cinsarmy rules
  4. FIREWALL="/sbin/iptables" # The path to iptables
  5. ETH="" # The name of the ethernet port you'd like to apply these rules to. Example: eth1
  6. # echo "Downloading the cinsarmy bad guys list of IPs."
  7. wget -c https://cinsscore.com/list/ci-badguys.txt -q -O $BADGUYS_FILE
  8. # Check if the file exists
  9. if [[ ! -f "$BADGUYS_FILE" ]]; then
  10. echo "File not found: $BADGUYS_FILE"
  11. exit 1
  12. fi
  13. # echo "Making sure the file downloaded..."
  14. # Check if the chain exists, and creates it if it's not there
  15. if $FIREWALL -L $CHAIN_NAME -n &> /dev/null; then
  16. # echo "Chain $CHAIN_NAME already exists."
  17. $FIREWALL -F $CHAIN_NAME
  18. else
  19. # echo "Creating chain $CHAIN_NAME."
  20. $FIREWALL -N $CHAIN_NAME
  21. fi
  22. # echo "Processing the bad guys list..."
  23. # Read each line (IP address) from the file and block it
  24. while IFS= read -r ip; do
  25. # Check if the line is not empty
  26. if [[ -n "$ip" ]]; then
  27. # Block the IP address using $FIREWALL
  28. $FIREWALL -A $CHAIN_NAME -i $ETH -s "$ip" -j DROP
  29. # echo "Blocked IP: $ip"
  30. fi
  31. done < "$BADGUYS_FILE"
  32. # Jump to the our chain from the FORWARD CHAIN
  33. $FIREWALL -A FORWARD -j $CHAIN_NAME
  34. # Delete the bad guys file
  35. rm $BADGUYS_FILE
  36. # echo "Bad guys list has been processed, and deleted."