#!/bin/bash #Copyright 2003 William Stearns #Released under the GPL. SaReportVer='0.1' echo "Spamassassin Report version $SaReportVer" echo "Permanent site for this tool: http://www.stearns.org/spamassassin/" #Here's where you make confiuration changes: #Spamassassin config files from which to read blacklist_from and #whitelist_from entries. Please use full paths. The user running this #script only needs read privileges to these. SaConfigs="/etc/mail/spamassassin/local.cf /home/wstearns/.spamassassin/user_prefs /usr/src/sa-blacklist/sa-blacklist" #How many sender email addresses there need to be in a given domain #before we care about it. MinSenders=2 #These are domains from which we might get ham or spam. Commonly, #although not exclusively, free email providers. CantColorDomains='@adelphia.net @aol.com @att.net @attbi.com @bigfoot.com @earthlink.net @email.com @eudoramail.com @excite.com @flashmail.com @hotmail.com @juno.com @lycos.com @mail.com @msn.com @pobox.com @rocketmail.com @verizon.com @verizon.net @yahoo.com' #How many individuals and tokens to display in the spammiest and #hammiest lists at the end TopN=300 #You shouldn't need to work with anything below here. #----------------------------------------------------------------------- requireutil () { while [ -n "$1" ]; do if ! type -path "$1" >/dev/null 2>/dev/null ; then echo Missing utility "$1". Please install it. >&2 return 1 #False, app is not available. fi shift done return 0 #True, app is there. } #End of requireutil requireutil cat check_bayes_db check_whitelist grep head sed sort tail uniq || exit 1 renice +15 -p $$ >/dev/null 2>&1 if [ -z "$LC_ALL" ]; then export LC_ALL=C fi check_whitelist ~/.spamassassin/auto-whitelist | sort -n >~/awl-raw check_bayes_db | sort -n >~/bayes-raw BlackDomains=`cat $SaConfigs | grep '^blacklist_from' | \ sed -e 's/.* \*@/@/' | grep -v blacklist_from | grep -v '\*' | sort | uniq` #echo BlackDomains are $BlackDomains #echo WhiteDomains=`cat $SaConfigs | grep '^whitelist_from' | \ sed -e 's/.* \*@/@/' | grep -v whitelist_from | grep -v '\*' | sort | uniq` #echo WhiteDomains are $WhiteDomains #echo echo ============================== echo Domains with $MinSenders or more senders echo ============================== TopDomains=`cat ~/awl-raw | sed -e 's/.*@//' -e 's/|.*//'| sort | uniq -c | \ sort -nr | while read COUNT DOMAIN ; do if [ $COUNT -ge $MinSenders ]; then \ echo $DOMAIN ; fi ; done` BlackListOut='' WhiteListOut='' CantColorOut='' OtherOut='' for Domain in $TopDomains ; do Handled='' for OneBlack in $BlackDomains ; do if [ "@$Domain" = "$OneBlack" ]; then Handled='yes' BlackListOut="$BlackListOut`echo ; echo ======== @$Domain \(Blacklisted\) ======== ; cat ~/awl-raw | grep @$Domain`" fi done for OneWhite in $WhiteDomains ; do if [ "@$Domain" = "$OneWhite" ]; then if [ -n "$Handled" ]; then echo "WARNING - $Domain is both blacklisted and whitelisted, please fix." fi Handled='yes' WhiteListOut="$WhiteListOut`echo ; echo ======== @$Domain \(Whitelisted\) ======== ; cat ~/awl-raw | grep @$Domain`" fi done for OneCantColor in $CantColorDomains ; do if [ "@$Domain" = "$OneCantColor" ]; then Handled='yes' CantColorListOut="$CantColorListOut`echo ; echo ======== @$Domain \(CantColor\) ======== ; cat ~/awl-raw | grep @$Domain`" fi done if [ -z "$Handled" ]; then OtherOut="$OtherOut`echo ; echo ======== @$Domain ======== ; cat ~/awl-raw | grep @$Domain ; echo`" fi #echo "======== @$Domain$BlackListed$WhiteListed ========" #cat ~/awl-raw | grep "@$Domain" done echo "================ Unclassified domains ================" echo "$OtherOut" echo echo "================ Blacklisted domains ================" echo "$BlackListOut" echo echo "================ Whitelisted domains ================" echo "$WhiteListOut" echo echo "================ CantColor domains ================" echo "$CantColorListOut" echo echo ============================ echo Top $TopN hammiest individuals echo ============================ cat ~/awl-raw | head -$TopN echo ============================= echo Top $TopN spammiest individuals echo ============================= cat ~/awl-raw | tail -$TopN echo ============================ echo Top $TopN hammiest tokens echo ============================ cat ~/bayes-raw | grep -v 'non-token data:' | head -$TopN echo ============================= echo Top $TopN spammiest tokens echo ============================= cat ~/bayes-raw | grep -v 'non-token data:' | tail -$TopN