<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BenV&#039;s notes &#187; spamdyke</title>
	<atom:link href="http://notes.benv.junerules.com/tag/spamdyke/feed/" rel="self" type="application/rss+xml" />
	<link>http://notes.benv.junerules.com</link>
	<description>Rants and notes</description>
	<lastBuildDate>Sun, 29 Aug 2010 14:36:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Qmail + Spamdyke and fail2ban</title>
		<link>http://notes.benv.junerules.com/all/software/qmail-spamdyke-and-fail2ban/</link>
		<comments>http://notes.benv.junerules.com/all/software/qmail-spamdyke-and-fail2ban/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 09:52:09 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Morons]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[fail2ban]]></category>
		<category><![CDATA[qmail]]></category>
		<category><![CDATA[spamdyke]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=539</guid>
		<description><![CDATA[Yesterday evening I was curiously looking at some tcpdump traffic that went through our dom0 of Xenbro. There seemed to be a ton of weird DNS requests. And with weird I mean spamlike domains, like familiesfirstmedical.com. After wondering for a bit I realized they were coming from our service domU that runs mail for the [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday evening I was curiously looking at some tcpdump traffic that went through our dom0 of Xenbro. There seemed to be a ton of weird DNS requests. And with weird I mean spamlike domains, like familiesfirstmedical.com. After wondering for a bit I realized they were coming from our service domU that runs mail for the junerules.com domain.<span id="more-539"></span><br />
I logged in and was surprised to see more than 50 active connections busy trying to deliver mostly spam to us. Fortunately I have some anti spam things enabled like <a href="http://spamassassin.apache.org/">spamassassin</a> and reverse DNS checking (which is where the DNS requests came from) and some more things using <a href="http://www.spamdyke.org/">Spamdyke</a>. However, checking the maillog I noticed that there were over 300000 denied connections from a day earlier! Time to become a bit more agressive in getting rid of zombie machines trying to spam us.</p>
<p>As a side story, since we moved our junerules.com domain from our very kind previous host to our own Xenbro machine, the amount of spam we receive plummeted. Apparently not because they stopped spamming on the domain though. I&#8217;m sure our previous host is glad he doesn&#8217;t have to deal with all the attention and traffic anymore <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .<br />
The main reason for this spam drop seems to be spamdyke. I&#8217;m sure you have your own opinion about how nice or acceptable it is to run graylisting and reverse DNS checking and all that, but my opinion is that if you have a badly configured mailserver (read: windows zombie machine) you can die in a fire for all I care. Fix your mailserver and then I&#8217;ll accept your mail.<br />
Too bad for the few properly configured mailservers out there that now have to try twice to get through the graylisting&#8230;. then again, it&#8217;s a small price to pay.</p>
<p>Anyway, to get rid of assholes trying to bruteforce their way into my ssh daemon I run <a href="http://www.fail2ban.org/">fail2ban</a>, which lets you try to get in a few times and then blocks your IP for a week. That&#8217;s how much I like them. So I decided to add a new filter to fail2ban, which gets rid of asshole mailservers that will fail their next attempts anyway. Those are the mailservers that spamdyke denies with the following errors:</p>
<ul>
<li><span style="color:#FF00FF">DENIED_RDNS_MISSING</span> &#8211; in other words, the mailserver doesn&#8217;t have a reverse DNS entry. You can&#8217;t be serious, that has to be a zombie.</li>
<li><span style="color:#FF00FF">DENIED_IP_IN_CC_RDNS</span> &#8211; means the mailserver probably has a dynamic IP address from their local ISP. Mostly zombies. Sorry for the 2 mailservers our there that are legitimate that mail like this. I&#8217;ll whitelist you whenever I see complaints.</li>
<li><span style="color:#FF00FF">DENIED_RDNS_RESOLVE</span> &#8211; means the reverse DNS does not resolve to the IP address it connected from. Get lost. However, this one should be used with care, because if the DNS resolver fails for whatever reason spamdyke will also issue this. So make a real good consideration if you want to use this in the fail2ban filter.</li>
</ul>
<p>Since above failures will keep coming back if they retry, I block these asshole servers for a week.<br />
Here&#8217;s my <span style="color:#FFFF00">/etc/fail2ban/filter.d/spamdyke.conf</span>:<br />
<a href="http://notes.benv.junerules.com/wp-content/plugins/download-monitor/download.php?id=spamdyke.conf" title="Downloaded 139 times">Fail2ban spamdyke filter</a> - Version 0.1 - SHA: 1ee23545d87998d0314d2683eb8f2a099cf9fca9</p>
<p>Simply put it in /etc/fail2ban/filter.d and edit <span style="color:#00FFFF">/etc/fail2ban/jail.local</span> and add something like this:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span>spamdyke-rdns<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
enabled &nbsp;= <span style="color: #c20cb9; font-weight: bold;">true</span><br />
filter &nbsp; = spamdyke<br />
action &nbsp; = iptables-allports<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #007800;">name</span>=SPAM, <span style="color: #007800;">protocol</span>=all<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
logpath &nbsp;= <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>maillog<br />
maxretry = <span style="color: #000000;">2</span><br />
bantime &nbsp;= <span style="color: #000000;">604800</span></div></div>
<p>Then reload fail2ban:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># fail2ban-client reload</span></div></div>
<p>After enabling it about 12 hours ago, this is the result:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">root<span style="color: #000000; font-weight: bold;">@</span>service<span style="color: #666666; font-style: italic;"># fail2ban-client status spamdyke-rdns</span><br />
Status <span style="color: #000000; font-weight: bold;">for</span> the jail: spamdyke-rdns<br />
<span style="color: #000000; font-weight: bold;">|</span>- filter<br />
<span style="color: #000000; font-weight: bold;">|</span> &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- File list: &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>maillog<br />
<span style="color: #000000; font-weight: bold;">|</span> &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- Currently failed: <span style="color: #000000;">72</span><br />
<span style="color: #000000; font-weight: bold;">|</span> &nbsp;<span style="color: #000000; font-weight: bold;">`</span>- Total failed: &nbsp; &nbsp; <span style="color: #000000;">10065</span><br />
<span style="color: #000000; font-weight: bold;">`</span>- action<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- Currently banned: <span style="color: #000000;">1987</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">|</span>- <span style="color: #000000; font-weight: bold;">&lt;</span>BenV<span style="color: #000000; font-weight: bold;">&gt;</span> too many to list<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">`</span>- Total banned: &nbsp; &nbsp; <span style="color: #000000;">1987</span></div></div>
<p>Simply amazing. We&#8217;ll end up blocking half the internet. Oh well, it&#8217;s only the bad part of internet anyway.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/qmail-spamdyke-and-fail2ban/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
