janeiro 29, 2003
spam2web

notice the new thing on the right side of fif3? shows the latest spams dropped into my box (hopefully i've got it filtered right so no pr0n shows up) get it here if you want. oh it requires a line in ~/.procmailrc too.

here's the procmail part. have new messages dropped into a directory

:0 HBci
* ! (naughty|words|that|you|dont|want|on|your|website)
/path/to/web/spam/folder

then set up the spam2web script to run once every couple minutes in cron. oh and you'll need to also need a way to post it to the webpage. i've used server-side includes. go google go.

here's the program from http://www.fif3.com/code/spam2url

#!/usr/local/bin/bash
## by skp v.2 Dec 30 2004 ##
##
## i use this to generate a list of spam i've received and
## randomly pick one to use as a title for my website
##
## first you need to shim off spam using procmail:
## :0 HBci
## /apache/virtualhost.fif3/htdocs/spam2web
##
## then in html, add a server side include
## and i use an include in the body for the list

RDIR=/apache/htdocs/spam2web
WDIR=/spam2web # path for website viewers
FILE1=$RDIR/results # file listing all the spam one subject per line
FILE2=$RDIR/results2 # file with just one spam subject

/sbin/chown www.daemon ${RDIR}/msg* ${RDIR}/*.txt 1>/dev/null 2>/dev/null
/bin/chmod a+rw ${RDIR}/msg* ${RDIR}/*.txt 1>/dev/null 2>/dev/null

while (( `ls -tr ${RDIR}/msg*txt |wc -w` > 7 )) ;do
rm `ls -trm ${RDIR}/msg*txt |tr -d "\r"|tr -d "\n" |cut -d',' -f -1`
done

for i in `ls -t ${RDIR}/msg* |grep -vi .txt`
#do if [[ ! -a $i.txt ]] ;then
do cat $i |/usr/local/bin/formail -k -X From: -X Subject: > ${i}.txt
rm $i
#fi
done

rm $FILE1
for i in `ls -t ${RDIR}/msg*txt`
do SUB=`cat ${i} |grep -e '^Subject:' |tr -cd "[:print:]" |grep -A50 -C1 Subject |cut -d' ' -f2- |cut -c -40`
WFILE=`echo ${i}|cut -d'/' -f6`
if [[ $SUB ]] ;then
echo "${SUB}
" >> $FILE1
fi
done

## pull a random line out just for our headline
RANDOM=$$ ; let number=0 ; let RANGE=5
while [ $number -eq 0 ]
do number=$RANDOM ; let "number %= $RANGE" ;done
cat $FILE1 |tail -"$number" |head -n1 > $FILE2

rm -f `ls ${RDIR}/msg* |grep -ve 'txt$'` 1>/dev/null 2>/dev/null

Posted by skp at janeiro 29, 2003 10:38 AM | TrackBack
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?