← cd ~/blog

less fuzzyocr-fight-image-spam.md

FuzzyOCR: Fight Image Spam

#Bash#Debian & Sysadmin archive

# historical archive — written years ago, kept as it was. Some info is dated.

In this article I will describe the steps needed to install and configure FuzzyOCR on Debian Wheezy so that the emails passing through our server are analyzed in search of SPAM images.

FuzzyOCR is nothing more than a plugin for SpamAssassin which analyzes emails and in particular the images contained in their body.
What’s under the hood?! (What is all this about?)
Thanks to the use of various methodologies, the images contained in the emails passing through are analyzed. If SpamAssassin considers an email clean, the images are passed to FuzzyOCR; otherwise, if the email is already flagged as spam, the image scanner check is not performed. In this way the workload on the server is greatly reduced, since a lot of unnecessary work is eliminated.

Make sure your system is up to date! (if it isn’t… well, now is the time to do it!!!)

LET’S ENABLE FUZZYOCR

Let’s install what is needed

apt-get install netpbm gocr giflib-tools libpng3 libgif4 gifsicle ocrad libstring-approx-perl libmldbm-perl libmldbm-sync-perl liblog-agent-perl libpng12-dev libtiff4-dev libsvga1-dev libx11-dev tesseract
apt-get install fuzzyocr

Let’s take a look at our configuration file

vi /etc/mail/spamassassin/FuzzyOcr.cf

Make sure the following directives are enabled and that they are similar to these. In any case I’ll leave you my configuration file for comparison with yours.

focr_enable_image_hashing 2
focr_db_hash /etc/mail/spamassassin/FuzzyOcr.db
focr_db_safe /etc/mail/spamassassin/FuzzyOcr.safe.db
focr_db_max_days 15

LET’S APPLY AND TEST THE CHANGES

The time has come to restart our service, provided that the SpamAssassin daemon is active (in some circumstances SpamAssassin is called to perform its task by AMaViS, in which case there is no need to restart anything)

/etc/init.d/spamassassin restart

Let’s now test that our plugin works

spamassassin --debug FuzzyOcr < /usr/share/doc/fuzzyocr/examples/ocr-animated.eml >/dev/null

To check the “live” operation of the system we can also resort to the following command

spamassassin -D