#!/bin/bash # # Read a receivedIPdb database on stdin, making an update to stdout by # verifying that each record in the database is in one of the black # lists. # # Requires Edward S. Marshall's rblcheck(1) program to validate each of # the IP addresses. # # Usage: # # receivedIP.validate < receivedIP.db > temp # cp temp receivedIP.db # # where receivedIP.db is a receivedIPdb database. # # Note: For Class A, Class B, and Class C, database records, only two IP # addresses are verified; 0 and 255. # while read quad do QUAD4=`echo "${quad}" | egrep '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'` # verify the record as a dotted quad notation IP # if [ "${QUAD4}" != "" ] # if dotted quad notation, check the IP against the black lists, and if it is found, print the dotted quad notation to stdout then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD4}" then echo "${QUAD4}" fi else QUAD3=`echo "${quad}" | egrep '[0-9]+\.[0-9]+\.[0-9]+\.'` # verify the record as a dotted quad notation IP, but contains only three of the dotted quads # if [ "${QUAD3}" != "" ] # if dotted quad notation, check the IP against the black lists, and if it is found, print the dotted quad notation to stdout then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD3}0" then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD3}255" then echo "${QUAD3}" fi fi else QUAD2=`echo "${quad}" | egrep '[0-9]+\.[0-9]+\.'` # verify the record as a dotted quad notation IP, but contains only two of the dotted quads # if [ "${QUAD2}" != "" ] # if dotted quad notation, check the IP against the black lists, and if it is found, print the dotted quad notation to stdout then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD2}0.0" then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD2}255.255" then echo "${QUAD2}" fi fi else QUAD1=`echo "${quad}" | egrep '[0-9]+\.'` # verify the record as a dotted quad notation IP, but contains only one of the dotted quads # if [ "${QUAD1}" != "" ] # if dotted quad notation, check the IP against the black lists, and if it is found, print the dotted quad notation to stdout then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD1}0.0.0" then if ! /usr/local/bin/rblcheck -q -s rss.maps.vix.com -s dul.maps.vix.com -s relays.ordb.org "${QUAD1}255.255.255" then echo "${QUAD1}" fi fi else echo "ERROR: ${quad}" # not dotted quad, print it as an error fi fi fi fi # done