#!/bin/bash
ipFile=/tmp/ipfile.txt
outputPath=/tmp/bulkip_abuse_check.txt
apiUserInput=adxxxxxxxxxxxxxxxxxxxxxxxxxxa
maxAge=30
cat $ipFile | while read line
do
echo "IP #" $i "of" $numIps"," $line
/usr/bin/curl -G https://api.abuseipdb.com/api/v2/check \
--data-urlencode "ipAddress=$line" \
-d maxAgeInDays=$maxAge \
-H "Key: $apiUserInput" \
-H "Accept: application/json" \
-o "/tmp/currentip.json" > /dev/null 2>&1
cat /tmp/currentip.json | /usr/bin/jq -r '.[] | "\(.ipAddress), \(.abuseConfidenceScore), \(.totalReports), \(.isp), \(.countryCode), \(.domain), \(.numDistinctUsers), \(.lastReportedAt)"' >> $outputPath #Selects fields to write to output file
i=$[$i+1] #Increments line to be read
done