duy13 / vDDoS-Layer4-Mapping

Layer 3-4 Support (CSF & CloudFlare) for vDDoS Proxy Protection.
26 stars 17 forks source link

Line 27 CloudFlare-API-Remove-All-Rules.sh #1

Closed ChangeNick closed 5 years ago

ChangeNick commented 6 years ago

CloudFlare-API-Remove-All-Rules.sh Line 27: while [ $numberrule -gt $so_lan_vong_lap_lon ]

cfremove.sh: line 27: [: 284,: integer expression expected

juttbmw commented 6 years ago

im using this code for add country to Firewall rules when load go high about 0.10 im looking for code as same Remove or Whitelist country from Firewall rules when load go low about 0.6 or etc

!/bin/bash

loadavg=load.avg cat /proc/loadavg | colrm 6 > $loadavg grep -w "[0.00-10.00]" $loadavg > /dev/null if [ $? -eq 0 ] then exit else bash /root/cf-auto-uam/uam.sh fi

!/bin/bash

loadavg=load.avg cat /proc/loadavg | colrm 6 > $loadavg grep -w "[0.00-9.00]" $loadavg > /dev/null if [ $? -eq 0 ] then bash /root/cf-auto-uam/high.sh else exit fi

Firewall rules can be based on IP address, IP address range, Autonomous System Number (ASN) or country. i need code as same like thats to remove Captcha country

!/bin/bash

apikey='1123222202030303030300330' zone='22200203030' email='gmail.com'

mkdir -p countrylist_willcaptcha='countrylist-willcaptcha.txt' countrylist_captchated='countrylist-willcaptcha.txt'

################### Captcha cho country: ten_file_chua_list=$countrylist_willcaptcha echo "cat $ten_file_chua_list | grep ." > $ten_file_chua_list so_dong_file_chua_list=cat $ten_file_chua_list | grep . | wc -l dong=1

while [ $dong -le $so_dong_file_chua_list ] do delaytime=$(( $RANDOM % 9 ))

countrycaptcha_hientai=$(awk " NR == $dong " $ten_file_chua_list) (sleep $delaytime; curl -sSX POST "https://api.cloudflare.com/client/v4/zones/$zone/firewall/access_rules/rules" \ -H "X-Auth-Email: $email" \ -H "X-Auth-Key: $apikey" \ -H "Content-Type: application/json" \ --data "{\"mode\":\"challenge\",\"configuration\":{\"target\":\"country\",\"value\":\"$countrycaptcha_hientai\"},\"notes\":\"Captcha by Proxy Protection\"}" >/dev/null 2>&1 & )& echo "Captcha country: $countrycaptcha_hientai" dong=$((dong + 1)) done

echo > $countrylist_willcaptcha

echo > $countrylist_captchated

duy13 commented 5 years ago

https://github.com/duy13/vDDoS-Layer4-Mapping#3-cloudflare-api-control-command