Last active
November 1, 2023 17:30
-
-
Save ramit-mitra/5b9c93f8354f2a41ac94f09e3a38c517 to your computer and use it in GitHub Desktop.
Report abusive IPs to AbuseIPDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Example: curl -sk https://gist.githubusercontent.com/ramit-mitra/5b9c93f8354f2a41ac94f09e3a38c517/raw/report_ips_to_abuseipdb.sh | bash | |
url="https://raw.githubusercontent.com/ramit-mitra/blocklist-ipsets/main/rottenIPs.json" | |
echo "-------------------------" | |
echo "Reading Banlist IPs" | |
blocked_ips=$(curl -s $url | jq -r '.[]') | |
echo "Reporting IPs to AbuseIPDB" | |
echo "-------------------------" | |
for ip in $blocked_ips; do | |
echo $ip | |
curl -sk https://api.abuseipdb.com/api/v2/report \ | |
--data-urlencode "ip=$ip" \ | |
-d categories=18,22 \ | |
--data-urlencode "comment=invalid SSH login attempted." \ | |
--data-urlencode "timestamp=$(date -u +%Y-%m-%dT%H:%M:%S+5:30)" \ | |
-H "Key: ${ABUSEIPDB_API_KEY}" \ | |
-H "Accept: application/json" | jq . | |
echo -e "\n" | |
done | |
echo "-------------------------" | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment