· 6 years ago · Dec 22, 2019, 07:52 PM
1#!/bin/bash
2# Author: Mike
3# Source: WP Bullet Guides https://guides.wp-bullet.com
4
5#remove old
6cd /root/cf_rules
7php remove_old_blacklist.php
8
9# cloudflare email
10CFEMAIL="tarnhosting@mail.com"
11# cloudflare API key
12CFAPIKEY="d927ab744bcfc98b460207dc80aab88751e09"
13
14cd /tmp
15# grab IP list
16curl https://sblam.com/blacklist.txt>/tmp/MANAGEWPTXT
17#curl https://raw.githubusercontent.com/ktsaou/blocklist-ipsets/master/stopforumspam_7d.ipset>>/tmp/MANAGEWPTXT
18curl https://iplists.firehol.org/files/stopforumspam_7d.ipset>>/tmp/MANAGEWPTXT
19
20# Turn text file into array
21MANAGEWPIPS=$(</tmp/MANAGEWPTXT)
22
23# Loop through array and add IPs to Cloudflare whitelist
24for MANAGEWPIP in ${MANAGEWPIPS[@]}; do
25# trim the \r or it breaks the JSON format
26MANAGEWPIP=$(echo $MANAGEWPIP| sed "s#\r##g")
27echo $MANAGEWPIP
28curl -s -j100 parallel -X POST "https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules" \
29 -H "X-Auth-Email: $CFEMAIL" \
30 -H "X-Auth-Key: $CFAPIKEY" \
31 -H "Content-Type: application/json" \
32 --data '{"mode":"js_challenge","configuration":{"target":"ip","value":"'"${MANAGEWPIP}"'"},"notes":"spam_blacklist_auto_bot"}'
33done
34
35# delete the temporary ManageWP IPs file
36rm -rf /tmp/MANAGEWPTXT