From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <44a6a272ef706cf46bb77346bfe7a91b@sdgm.net> From: boyd@sdgm.net To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-lrrpithxycnandmrlygvsnkgpz" Subject: [9fans] spamoff Date: Thu, 25 Sep 2003 20:58:37 -0400 Topicbox-Message-UUID: 4e214b48-eacc-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-lrrpithxycnandmrlygvsnkgpz Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit here is a first cut. if you can read rc you can work it out. just change: user=boyd to be: user= stick it in $home/bin/rc and then: spamoff -c use it at your peril. bugs/flames to me. btw: it assumes $home/^(lib log) exist. bbtw: it's chucked away 1000's of spams and has been in use for a week. --upas-lrrpithxycnandmrlygvsnkgpz Content-Type: multipart/mixed; boundary="upas-hppntqrsuylqmportgfjbaszxe" Content-Disposition: inline This is a multi-part message in MIME format. --upas-hppntqrsuylqmportgfjbaszxe Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit The following attachment had content that we can't prove to be harmless. To avoid possible automatic execution, we changed the content headers. The original header was: Content-Disposition: attachment; filename=spamoff.bundle Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit --upas-hppntqrsuylqmportgfjbaszxe Content-Type: application/octet-stream Content-Disposition: attachment; filename="spamoff.bundle.suspect" # To unbundle, run this file echo spamoff sed 's/.//' >spamoff <<'//GO.SYSIN DD spamoff' -#!/bin/rc - -# -# spamoff addr mbox -# -# to setup: spamoff -c -# - -rfork en - -ramfs >[2] /dev/null - -# set user to be you -user=boyd - -lib=/usr/$user/lib/mail # somewhere to put the below -log=/usr/$user/log/mail -allow=$lib/allow # addr's you'll accept mail from -audit=$log/audit # audit trail -errors=$log/errors # error log -rejects=$log/rejects # list of addresses and codes - -upas=upas # upas bin -mp=/tmp/upasfs.$pid # upas mbox file-system mount point -ctl=$mp/ctl -mbox=$mp/mbox/1 - -myname=`{basename $0} - -# install like mail -c - -switch ($#*^$1) { -case 1-c - flag +e - - pipeto=/mail/box/$user/pipeto - - { - echo '#!/bin/rc' - echo - echo /usr/$user/bin/rc/$myname '$*' - } > $pipeto - - chmod +x $pipeto - - for (i in $lib $log) { - if (! test -d $i) - mkdir $i - } - - for (i in $audit $allow $errors $rejects) > $i - - for (i in $audit $errors $rejects) { - chmod 622 $i - chmod +al $i - } - - echo 'postmaster -'$user' -local!$user -' > $allow - - exit -} - -# get $upas/fs to smash the message into manageable pieces -mkdir $mp || exit mkdir -msgtmp=/tmp/pipeto.$pid -bind -ac /mail/tmp /tmp -cat > $msgtmp -$upas/fs -f $msgtmp -m $mp - -# try to cleanp the mess we have made -fn cleanup { - unmount $mp - rm -f $mp - rm -f $msgtmp - unmount /tmp -} - -# report error and give up -fn err { - echo $myname: $* > $errors - cleanup - exit '' -} - -# match $1 against a 'white list' -fn match { - awk -v 'addr='$1 ' -BEGIN { e = 1} - -$0 ~ /^#.*/ || $0 == "" { next } - -$0 == addr { - e = 0 - exit -} - -END { exit e } -' $allow -} - -# see if it had been rejected, but is ok now -fn reject { - awk -v 'addr='$1 -v 'code='$2 ' -BEGIN { e = 1 } - -$1 == addr && $2 == code { - e = 0 - exit -} - -END { exit e } -' $rejects > $audit -} - -# deliver it or bitch about it to the sender -fn bitch { - to=$1 - mfile=$2 - - # 822 addresses are case insensitive, so go for lower case - addr=`{tr A-Z a-z < $mbox/replyto >[2] /dev/null} - - # this had better be ok - if (~ $addr '') - err null reply address - - # spammers sometimes bounce 'em back - if (~ $addr /dev/null) - err bounce from '<'$addr'>' - - if (match $addr || reject $addr `{cat $mbox/subject >[2] /dev/null}) { - $upas/deliver $to $mbox/replyto $mfile < $mbox/raw - cleanup - exit '' - } - - code=`{echo $myname$pid$addr | md5sum} - - echo $code - - { - echo From: $user - echo Subject: $user''''s $myname autoresponder - echo - echo Either you''''re a spammer or I don''''t like you or I don''''t know you. - echo - echo Email me this rejected message with exactly this code: - echo - echo ' '$code - echo - echo in the Subject: line and I''''ll decide if I''''ll add you to my list - echo of people I''''ll accept mail from. - echo - echo ' ---- Original Message ----' - echo - cat $mbox/raw - - } | $upas/send $addr - - # so we can $upas/fs it later, if necessary - # - # this is lunacy, but correct - #$upas/deliver $to $mbox/replyto $audit < $mbox/raw - - # this is manageable, but not correct - $upas/deliver $to $mbox/replyto $audit < $mbox/rawheader - - echo $addr $code > $rejects - err rejected mail from $addr $code -} - -# these files had better be setup right - -if (! test -w $errors -a -A $errors -a -L $errors) { - echo $myname: $errors: existance/mode/permission problem >[1=2] - exit $errors -} - -for (i in $audit $rejects) { - if (! test -w $i -a -A $i -a -L $i) { - err $i: existance/permission problem - } -} - -if (! test -r $allow) { - err $allow: existance/permission problem -} - -switch ($#*) { -case 2 - bitch $* - -case * - err args: $* -} //GO.SYSIN DD spamoff --upas-hppntqrsuylqmportgfjbaszxe-- --upas-lrrpithxycnandmrlygvsnkgpz--