#!/bin/sh # # Construct a new receivedIP database, by adding the IP addresses # contained in the "Received: " headers of e-mail in an archive of spam. # # The lower level directory, archive, is an archive of spam e-mail, # organized by month; for example archive/0107 would be spam that was # received in July 2001, archive/0108 in August, and so on. # # The file ~/.procmail.reject is the current IP address database, and # will be updated with the "Received: " IP addresses in headers of # e-mail found in the archive directory. # # The file ~/.procmail.hosts is a list of IP addresses that can not be # rejected-they must be removed from the receivedIP database; these # include IP addresses of up stream e-mail providers, the private # network IPs, etc. # # The new receivedIP database is named ~/procmail.reject.new, (note no # leading period,) and must be copied over the obsolete version by hand. # # Usage: # # extract.addresses # retval="0" rm -f "${HOME}/receivedIP.add.$$" # # Extract the IP addresses from the headers in the archive directory to # make a new database. # for i in archive/* do if ! receivedIPdb -P "${HOME}/.procmail.reject" $i/* >> "${HOME}/receivedIP.add.$$" then echo "receivedIPdb -P ${HOME}/.procmail.reject $i/* >> ${HOME}/receivedIP.add.$$ failed" retval="1" break fi done # # Remove any IP addresses that are in the ~/.procmail.hosts file from the # new database. # # Uniquly sort the new database. # # Dedup the new database, writing the new database to the # ~/procmail.reject.new file. # if [ "${retval}" = "0" ] then retval="1" rm -f "${HOME}/receivedIP.rm.$$" # if receivedIPdbrm "${HOME}/.procmail.hosts" "${HOME}/.procmail.reject" "${HOME}/receivedIP.add.$$" > "${HOME}/receivedIP.rm.$$" then rm -f "${HOME}/receivedIPdb.usort.$$" # if receivedIPdbusort "${HOME}/receivedIP.rm.$$" > "${HOME}/receivedIPdb.usort.$$" then if receivedIPdbdedup "${HOME}/receivedIPdb.usort.$$" "${HOME}/receivedIPdb.usort.$$" > "${HOME}/procmail.reject.new" then retval="0" else echo "receivedIPdbdedup ${HOME}/receivedIPdb.usort.$$ ${HOME}/receivedIPdb.usort.$$ > ${HOME}/procmail.reject.new failed" fi else echo "receivedIPdbusort ${HOME}/receivedIP.rm.$$ > ${HOME}/receivedIPdb.usort.$$ failed" fi else echo "receivedIPdbrm ${HOME}/.procmail.hosts ${HOME}/.procmail.reject ${HOME}/receivedIP.add.$$ > ${HOME}/receivedIP.rm.$$ failed" fi fi # rm -f "${HOME}/receivedIP.add.$$" "${HOME}/receivedIP.rm.$$" "${HOME}/receivedIPdb.usort.$$"