OpenBSD spamd: create a fake MTA

From WTFwiki
Jump to navigation Jump to search

Openbsd comes with a greylisting daemon called "spamd". To run a fake MTA and distribute that list to real working MTA.. This article will show you how;

First we need to add a few tables to pf.conf;

table <spamd> persist
pass in log on em1 proto tcp from any to any port 25 rdr-to port spamd
pass in log on em1 inet proto tcp from <spamd> to any port smtp divert-to port spamd

So all traffic from port 25 will be directed to spamd All traffic in the table spamd will be redirected to spamd

Add the following to /etc/rc.conf.local

spamd_flags="-4 -G25:4:864 -h -l127.0.0.1 -n \"Sendmail 8.11.4/8.11.1\" -S10 -s1 -v -w1"
spamlogd_flags="-I -i lo0"

This will set arguments on spamd, for more information you can man spamd. I'm setting spamd to whitelist everything knowing that they will be blacklisted. Spamd does have a blacklist mode but it doesn't store information into the spamdb database for logging purposes.

In this case if we;

mrt1# spamdb

We can see that some address have already connected to our fake email server. Mostly by port scanning 25 and see if they can send email? (who knows). We know these address are considered bad so we can simply;

spamdb | grep WHITE | awk -F "|" '{print $2}' >> ip.txt

This will send/parse all the IP's into a file.

We can host this txt file via a webserver or scp it to other working MTA's to be put into their block list. If we wanted to trap all these ips into a working MTA running PF and opensmtpd we could;

cat ip.txt | xargs -n 1 spamdb -t -a

Or send it to a block list in PF;

cat file.txt | xargs pfctl -t blockedspammers -T add