Skip to content

Instantly share code, notes, and snippets.

@ramit-mitra
Last active November 1, 2023 17:30
Show Gist options
  • Save ramit-mitra/5b9c93f8354f2a41ac94f09e3a38c517 to your computer and use it in GitHub Desktop.
Save ramit-mitra/5b9c93f8354f2a41ac94f09e3a38c517 to your computer and use it in GitHub Desktop.
Report abusive IPs to AbuseIPDB
#!/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