<?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>tolaris.com &#187; security</title>
	<atom:link href="http://www.tolaris.com/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tolaris.com</link>
	<description>When the going gets tough, the tough sniff packets.</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:47:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Sniffing on a switch</title>
		<link>http://www.tolaris.com/2010/11/26/sniffing-on-a-switch/</link>
		<comments>http://www.tolaris.com/2010/11/26/sniffing-on-a-switch/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 21:34:36 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[wireshark]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=937</guid>
		<description><![CDATA[I&#8217;m an IP network engineer. When something goes wrong, the first thing I do is sniff packets. Got a SIP phone that won&#8217;t register? Forget reading logs; sniff 5060/udp and read the SIP chatter directly. A customer complains that &#8220;Yahoo chat doesn&#8217;t work&#8221;? Sniff 5050/tcp and look for TCP hangups, login failures, or ICMP &#8220;port [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m an IP network engineer. When something goes wrong, the <em>first</em> thing I do is sniff packets. Got a SIP phone that won&#8217;t register? Forget reading logs; sniff 5060/udp and read the SIP chatter directly. A customer complains that &#8220;Yahoo chat doesn&#8217;t work&#8221;? Sniff 5050/tcp and look for TCP hangups, login failures, or ICMP &#8220;port unreachable&#8221; messages.</p>
<p>Sniffing is easy when you have access to the intermediate router, but that isn&#8217;t always the case. What if you&#8217;re just another PC on the same switch? That&#8217;s impossible, right?</p>
<p><span id="more-937"></span>I&#8217;m not the <a href="http://www.linuxjournal.com/article/5869">first</a> <a href="http://www.irongeek.com/i.php?page=security/ettercapfilter">person</a> <a href="http://www.irongeek.com/i.php?page=security/arpspoof">to</a> <a href="http://seclists.org/pen-test/2005/Oct/235">write</a> about this. Switches are not immune to sniffing. There are three techniques for sniffing traffic on an Ethernet switch:</p>
<ol>
<li>Use a monitor port. With a managed switch, configure one port to receive copies of data sent to other port(s). Useful if you have administrator access to a managed switch.</li>
<li>MAC flooding. Fill up the switch&#8217;s MAC table with false entries, causing it to failover into broadcast mode. All packets will be sent to all ports. Easy to detect and hard to do on modern switches.</li>
<li><a href="http://en.wikipedia.org/wiki/ARP_spoofing">ARP poisoning</a>. Send unsolicited ARP responses to the target devices (for instance, a PC and its default gateway), telling them to direct traffic to you. Silently route their traffic so they don&#8217;t notice an interruption.</li>
</ol>
<p>It is the last technique that I want to discuss. Many tools exist to poison ARP, from simple command line utilities like arpspoof (part of <a href="http://en.wikipedia.org/wiki/DSniff">dsniff</a>), <a href="http://www.securiteam.com/tools/5QP0I2AC0I.html">seringe</a>, and <a href="http://sid.rstack.org/arp-sk/">arp-sk</a>, to full-featured man-in-the-middle attack suites like <a href="http://ettercap.sourceforge.net/">Ettercap</a>. Ettercap can poison ARP caches, sniff packets and write them to files, route traffic, and filter/change traffic content. You can find a very helpful <a href="http://openmaniak.com/ettercap_arp.php">step-by-step Ettercap tutorial here</a>, so I won&#8217;t cover the same ground. I&#8217;d rather explain what these tools do.</p>
<p>ARP poisoning attacks work by sending gratuitous ARP replies to two targets, informing each of them that the attacker&#8217;s PC is the opposite target. For instance, suppose I have three devices:</p>
<ol>
<li><em>gateway</em>, a router on 192.168.0.1, with MAC 00:1d:73:36:ad:0c</li>
<li><em>alice</em>, a PC on 192.168.0.101, with MAC 00:13:02:02:56:da</li>
<li>My PC on 192.168.0.102, with MAC 00:17:09:d2:30:25</li>
</ol>
<p>Alice knows Gateway&#8217;s MAC address:</p>
<pre>user@alice:~$ ip neigh show
192.168.0.1 dev wlan0 lladdr 00:1d:73:36:ad:0c REACHABLE</pre>
<p>Gateway knows Alice&#8217;s MAC address:</p>
<pre>user@gateway:~$ ip neigh show
192.168.0.101 dev eth1 lladdr 00:13:02:02:56:da REACHABLE</pre>
<p>When I start the ARP poisoning attack, both Alice and Gateway learn different MAC addresses for each other:</p>
<pre>user@alice:~$ ip neigh show
192.168.0.1 dev wlan0 lladdr 00:17:09:d2:30:25 REACHABLE

user@gateway:~$ ip neigh show
192.168.0.101 dev eth1 lladdr 00:17:09:d2:30:25 REACHABLE</pre>
<p>Now Alice will send traffic for Gateway (probably all Internet traffic) to my PC, and Gateway will do the same for traffic intended for Alice. If we stop here, we&#8217;ll be able to see what Alice is trying to do, but Alice will quickly realise something is wrong because traffic will stop without explanation.</p>
<p>This is the second part of ARP poisoning (and of any Man-in-the-Middle attack): silently routing traffic onward. You can use the kernel&#8217;s IP forwarding to do this:</p>
<p><code>echo 1 > /proc/sys/net/ipv4/ip_forward</code></p>
<p>But if you do, you&#8217;ll appear in Alice&#8217;s traceroute path:</p>
<pre> 1  192.168.0.102   2.580 ms  2.754 ms  3.312 ms
 2  192.168.0.1  1.530 ms  2.321 ms  2.964 ms
 3  192.168.1.254  60.537 ms  60.028 ms  59.573 ms
 4  79.86.25.1  19.854 ms  16.007 ms  17.413 ms
 5  ....</pre>
<p>If you use &#8220;unified sniffing&#8221; with Ettercap, it will silently route traffic in software. Other tools, such as fragrouter (also part of dsniff), can do the same thing from the command line. Both of these tools forward traffic without decrementing the TTL, which makes them invisible to traceroute.</p>
<p>ARP poisoning is not silent. It can be detected by both hosts, because you are manipulating their ARP tables. These gratuitous ARP replies are easily visible with a sniffer:</p>
<pre> 0.636848 00:17:09:d2:30:25 -> 00:1d:73:36:ad:0c ARP 192.168.0.1 is at 00:17:09:d2:30:25
 0.637622 00:17:09:d2:30:25 -> 00:13:02:02:56:da ARP 192.168.0.101 is at 00:17:09:d2:30:25
 10.680712 00:17:09:d2:30:25 -> 00:1d:73:36:ad:0c ARP 192.168.0.1 is at 00:17:09:d2:30:25
 10.684618 00:17:09:d2:30:25 -> 00:13:02:02:56:da ARP 192.168.0.101 is at 00:17:09:d2:30:25</pre>
<p>Most tools send these ARP replies regularly, to keep ARP table entries from timing out. For instance, Ettercap sends them every 10 seconds. This is suspicious, as ARP requests are normally only seen when a host is first discovering another one. It is necessary to prevent true ARP requests from briefly changing the ARP table back to its correct state. Several tools exist to detect or prevent ARP poisoning, like <a href="http://arpon.sourceforge.net/">ArpON</a>, <a href="http://en.wikipedia.org/wiki/Arpwatch">arpwatch</a>, and <a href="http://en.wikipedia.org/wiki/DHCP_snooping">DHCP snooping</a>.</p>
<p>I&#8217;ve used traditional security terms like &#8220;victim&#8221; and &#8220;attacker&#8221; in this post, and of course ARP poisoning is a useful technique for unauthorised spying. However, it has legitimate uses. I&#8217;ve used it a number of times in situations where I had to sniff but couldn&#8217;t interrupt the physical cabling or didn&#8217;t have a managed switch. Whatever the problem, there is no faster way to understand a network problem than sniffing the raw data.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2010/11/26/sniffing-on-a-switch/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Securing laptops with ecryptfs, cryptsetup, and tmpfs</title>
		<link>http://www.tolaris.com/2009/11/14/securing-laptops-with-ecryptfs-cryptsetup-and-tmpfs/</link>
		<comments>http://www.tolaris.com/2009/11/14/securing-laptops-with-ecryptfs-cryptsetup-and-tmpfs/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 00:17:03 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[karmic]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=618</guid>
		<description><![CDATA[One of the awesome features of the last several Ubuntu releases is support for ecryptfs, an encrypted filesystem. At Talia we depend heavily on GPG, OTR, SSH keys and other forms of encryption and secure identification. Loss of those keys and other confidential data to laptop theft, corporate espionage, or the US Customs Service is [...]]]></description>
			<content:encoded><![CDATA[<p>One of the awesome features of the last several Ubuntu releases is support for <a href="http://www.linuxjournal.com/article/9400">ecryptfs</a>, an <a href="http://ecryptfs.sourceforge.net/ecryptfs-faq.html">encrypted</a> filesystem.  At Talia we depend heavily on GPG, OTR, SSH keys and other forms of encryption and secure identification.  Loss of those keys and other confidential data to laptop theft, corporate espionage, or the <a href="http://www.boingboing.net/2008/02/07/tsa-confiscating-lap.html">US Customs Service</a> is a big concern for us.  This week I secured my laptop, as a prototype of our new corporate laptop setup.  Here is how I did it.</p>
<p><span id="more-618"></span>Nothing in this process is specific to KDE, so Ubuntu or Xubuntu users can use this as well.  Steps:</p>
<ol>
<li>Choose a strong password</li>
<li>Create an encrypted ~/Private directory</li>
<li>Copy home directory files into ~/Private</li>
<li>Move ~/Private to $HOME</li>
<li>Encrypt swap</li>
<li>Make /tmp a tmpfs</li>
</ol>
<p>Caveat emptor: If you encrypt your home directory, then later forget your password and fail to write down the mount passphrase, you are screwed.  There is no practical chance that you will recover your files.  As always, make a backup.</p>
<p><strong>Step 1: Choose a strong password</strong></p>
<p>If you aren&#8217;t already doing this, you&#8217;re not likely to use this guide.  Security is a mindset, not a tool.  Get used to keeping strong passwords in your head.  Ubuntu makes using encryption <em>really</em> easy, but it is only as effective as the strength of the password you choose.</p>
<p>My recommendation is to use <a href="http://sourceforge.net/projects/pwgen/">pwgen</a> with -B or even -By:</p>
<p><code>pwgen -By</code></p>
<pre>
Ohz:ah7s aiT7gex% AhNae)Z3 Ohph*i9e va9eZuo[ Mei7ieZ~ Ohb7Za]o Piek+ai3
fa!m3Sho ua~ch7Wa tom?oh9U do{i4Aep tuF4oof} Na#a4eiH epe\G3oh aR3ahp^i
...
Aip$aim9 Eph%a3pu gae7aY`a Ie^cah4t sha+uY3v ove3aeZ= Wie4yei| Oc\aeb9e
</pre>
<p>The -B option tends to generate passwords that are balanced between hands and at least partly pronouncible, so this isn&#8217;t as hard as you think.  If you do use -y (special characters like +), consider the keyboards you might have to use.  If you use both British and American keyboards, don&#8217;t use £, @, &#8220;, `, #, ~, \, or |, as all of these are in different locations.</p>
<p>Pick one and and make a mnemonic to help you remember it.  Write it on a piece of paper, put it in your wallet, and burn it once you memorise it.  Write it on your belly with a sharpie; whatever it takes.  Change your password now:</p>
<p><code>passwd</code></p>
<p>Your password will later become the passphrase that protects the encryption keys to your home directory.  ecryptfs includes excellent PAM support, so if you change your password later it will update the key too.</p>
<p><strong>Step 2: Create an encrypted ~/Private directory</strong></p>
<p>Since I upgraded from an earlier install without an encrypted home or ~/Private directory, I had to create one.  If you are about to install 9.10 from a CD, the installer has an option to encrypt your home directory.  Just use that.  Or create a new user:</p>
<p><code>adduser --encrypt-home username</code></p>
<p>If you&#8217;ve already got an encrypted home, congratulations!  The hardest part is done.  Skip to step 5.</p>
<p>If not, let&#8217;s get started.  Linux Mag&#8217;s Dustin Kirkland has written an <a href="http://www.linux-mag.com/id/7568/2/">excellent guide</a> to this process.  Much of my process is based on his, but I include a few corrections.  For most of this you can remain logged in to your Desktop, but the process is simpler from the Linux console.  The initial copy process will make you want to get up and do something else while it finishes anyway.</p>
<p>Logout from the Desktop, which should return you to the login screen.  If your login screen is configured to log you in automatically, cancel it.  Then press Ctrl+Alt+F1 to go to the first Linux virtual console.</p>
<p>Login at the prompt, and create an encrypted $HOME/Private directory:</p>
<p><code>ecryptfs-setup-private</code></p>
<pre>Enter your login passphrase:
Enter your mount passphrase [leave blank to generate one]:</pre>
<p>At the first prompt enter your user password.  At the second, press Enter.  Now record the mount passphrase which was just generated:</p>
<p><code>ecryptfs-unwrap-passphrase $HOME/.ecryptfs/wrapped-passphrase</code></p>
<p>Print it out and put it with your birth certificate in your fire-proof document safe.  You do have one, right?  If something goes wrong you will need this later.</p>
<p>Log out, and log in again.</p>
<p><strong>Step 3: Copy home directory files into ~/Private</strong></p>
<p>Make sure you have at least 50% free on /home, or this may fail.</p>
<p><code>rsync -aP --exclude=.Private --exclude=Private --exclude=.ecryptfs $HOME/ $HOME/Private/</code></p>
<p>If you don&#8217;t have 50% free, first move some files from $HOME to $HOME/Private, and rsync the rest.</p>
<p><code>cd<br />
mv -v Videos Music Pictures DirectoryOfBigFiles $HOME/Private/<br />
rsync -aP --exclude=.Private --exclude=Private --exclude=.ecryptfs $HOME/ $HOME/Private/</code></p>
<p>This will take a long time to complete.  Every file is being encrypted as it is copied or moved.  If you have a lot of files and an under-powered CPU (such as on a netbook), it will take even longer.  I moved 178 GB of data on my Dell Vostro 1500 (Intel Core2 Duo 2 GHz, 4GB RAM) in about 5 hours.  Get a coffee, walk the plants, shave the cat, come back later.</p>
<p>When done, logout to sync any remaining changes to disk.</p>
<p><strong>Step 4: Move ~/Private to $HOME</strong></p>
<p>Now we need to do some things with sudo.    Still on console, login again.   Unmount $HOME/Private:</p>
<p><code>ecryptfs-umount-private<br />
cd /<br />
sudo mkdir -p /home/.ecryptfs/$USER<br />
sudo chown $USER:$USER /home/.ecryptfs/$USER<br />
sudo mv $HOME/.ecryptfs /home/.ecryptfs/$USER/</code></p>
<p>Create a new home and populate it with the ecryptfs files:</p>
<p><code>sudo mkdir -p -m 700 /home/$USER.new<br />
sudo chown $USER:$USER /home/$USER.new<br />
sudo mv $HOME/.Private /home/.ecryptfs/$USER/<br />
sudo ln -s /home/.ecryptfs/$USER/.ecryptfs /home/$USER.new/.ecryptfs<br />
sudo ln -s /home/.ecryptfs/$USER/.Private /home/$USER.new/.Private<br />
sudo ln -s /usr/share/ecryptfs-utils/ecryptfs-mount-private.txt /home/$USER.new/README.txt<br />
</code></p>
<p>Switch to the new home, tell ecryptfs that we&#8217;ll mount it at login, and make it read-only (until it is mounted):</p>
<p><code>sudo mv $HOME $HOME.old<br />
sudo mv $HOME.new $HOME<br />
echo $HOME > $HOME/.ecryptfs/Private.mnt<br />
sudo chmod 500 $HOME</code></p>
<p>Now for the moment of truth.  Still on console, logout, and login again.  Your home directory should mount:</p>
<p><code>mount | grep ecryptfs</code></p>
<pre>/home/username/.Private on /home/username type ecryptfs (ecryptfs_sig=9cec4d81c9bcb6e0,ecryptfs_fnek_sig=c735e6facb299611,ecryptfs_cipher=aes,ecryptfs_key_bytes=16)</pre>
<p>Create some convenient links:</p>
<p><code>ln -s /home/.ecryptfs/$USER/.ecryptfs $HOME/.ecryptfs<br />
ln -s /home/.ecryptfs/$USER/.Private $HOME/.Private</code></p>
<p>Once you verify that all your user data is there, securely wipe any files that have important data, and then remove the old home.</p>
<p><code>cd $HOME.old<br />
find .kde .gnupg .ssh PathsToDirectoriesOfImportantFiles -print -exec shred -u {} \;<br />
rm -rf $HOME.old</code></p>
<p><strong>Step 5: Encrypt swap</strong></p>
<p>Your home directory isn&#8217;t the only place your private data may be written to disk.  When your computer doesn&#8217;t have enough RAM for everything it wants to have open, it swaps.  This means some RAM is written to disk to be read back later.  Thus, swap can contain anything you have ever have open.  Swap does not need normally to survive reboots *, so we&#8217;ll encrypt this with a random key every time we boot up.</p>
<p>* The one exception to this is hibernate mode (suspend to disk).  If you want to use hibernate, don&#8217;t encrypt swap, or use a (less secure) <a href="http://sysphere.org/~anrxc/j/articles/ecryptfs/index.html#top-5">static key</a>.  Encrypting swap has no impact on sleep mode (suspend to RAM).  I never use hibernate.</p>
<p>Thankfully, this is a very easy process with Ubuntu.  Despite the misleading name, this uses cryptsetup, not ecryptfs:</p>
<p><code>sudo apt-get install cryptsetup<br />
sudo ecryptfs-setup-swap</code></p>
<p><strong>Step 6: Make /tmp a tmpfs</strong></p>
<p>The last place your private data is commonly written is the temp directory, /tmp.  The contents of this directory don&#8217;t need to survive reboot either, and are commonly cleared at bootup.  It is possible to encrypt it using cryptsetup just as with swap, but we don&#8217;t need to.  Instead we&#8217;ll make this a <a href="http://en.wikipedia.org/wiki/Tmpfs">tmpfs</a>.  This means /tmp will be an auto-resizing virtual RAM disk.  By default it is allowed to grow to up to 50% of RAM.</p>
<p>Don&#8217;t worry about this consuming your RAM.  If the contents of RAM is swapped to disk, static content like /tmp will be the first to go.  And it isn&#8217;t much data anyway; my /tmp <a href="http://osdir.com/ml/kde-bugs-dist/2009-09/msg15164.html">rarely</a> grows beyond 200 MB.  Plus, using a tmpfs will save power when in battery mode.</p>
<p>Add one line to your /etc/fstab:</p>
<p><code>echo "tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0" >> /etc/fstab</code></p>
<p>If you are logged in to the desktop, log out completely.  Then login on console one last time, and run:</p>
<p><code>sudo rm -rf /tmp/*<br />
reboot</code></p>
<p>That&#8217;s it!  You are now running a cryptographically secure laptop, protected against all but the <a href="http://xkcd.com/538/">rubber-hose attack</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/11/14/securing-laptops-with-ecryptfs-cryptsetup-and-tmpfs/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Logging out of HTTP Authentication with Firefox</title>
		<link>http://www.tolaris.com/2009/09/08/logging-out-of-http-auth-with-firefox/</link>
		<comments>http://www.tolaris.com/2009/09/08/logging-out-of-http-auth-with-firefox/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 20:44:19 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=498</guid>
		<description><![CDATA[Firefox has a very annoying &#8220;feature&#8221; &#8211; it remembers any HTTP authentication tokens for as long as Firefox remains open. Any by &#8220;open&#8221;, I mean &#8220;the browser is running&#8221;, not &#8220;the tab/window is open&#8221;. Why is this bad? For several reasons. One, it makes cross-site scripting attacks easier. Once you login to a web site [...]]]></description>
			<content:encoded><![CDATA[<p>Firefox has a very annoying &#8220;feature&#8221; &#8211; it remembers any HTTP authentication tokens for as long as Firefox remains open.  Any by &#8220;open&#8221;, I mean &#8220;the browser is running&#8221;, not &#8220;the tab/window is open&#8221;.</p>
<p>Why is this bad?  For several reasons.<span id="more-498"></span>  One, it makes <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">cross-site scripting</a> attacks easier.  Once you login to a web site that uses HTTP authentication, you&#8217;ll stay logged in.  If you leave Firefox running for days, you&#8217;re vulnerable for days.</p>
<p>Two, suppose you want to login to the same site with different credentials.  Perhaps you have both an admin account and a regular user account, and you want to switch between them.  Or perhaps you are setting up a site and need to test another user&#8217;s login.  The only way to do this with Firefox now (as of 3.0.13) is to completely quit the browser and restart.</p>
<p>Enter: the <a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer</a> extension.  This is a great extension, but it has far more features than you&#8217;re likely to need.  On the other hand, it is great for dissecting web sites, viewing table borders, and eliminating annoying CSS themes.  And it has a way to clear HTTP authentication tokens.</p>
<p>Install the extension.  If you prefer, hide the &#8220;Web Developer&#8221; tool bar.  Now to log out of HTTP auth, navigate through the menus Tools -> Web Developer -> Miscellaneous -> Clear Private Data -> HTTP Authentication.</p>
<p>Warning: basic HTTP authentication is not secure. Digest HTTP authentication is better.  You should only use either of these with HTTPS, so your transport is encrypted end to end.</p>
<p><em>Update 2009-11-25:</em> Since upgrading to Firefox 3.5, you no longer need this extension to log out of HTTP auth.  As noted in the comments below, go to Tools -> Clear Recent History -> Details, check only &#8220;Active Logins&#8221;, and then press &#8220;Clear Now&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/09/08/logging-out-of-http-auth-with-firefox/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Stopping spam botnets with fail2ban</title>
		<link>http://www.tolaris.com/2009/07/15/stopping-spam-botnets-with-fail2ban/</link>
		<comments>http://www.tolaris.com/2009/07/15/stopping-spam-botnets-with-fail2ban/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 19:26:26 +0000</pubDate>
		<dc:creator>Tyler Wagner</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.tolaris.com/?p=432</guid>
		<description><![CDATA[In the last 3 weeks our company mail servers have been slammed with a massive increase in spam relay attempts. Logs showed many failures like so. Jul 12 14:15:26 mailserver.example.com postfix/smtpd[19885]: NOQUEUE: reject: RCPT from 206.12.0.10.in-addr.arpa[10.0.12.206]: 554 5.7.1 &#60;symons@yahoo.co.uk&#62;: Relay access denied; from=&#60;yyjaqveh@lpsb.com&#62; to=&#60;symons@yahoo.co.uk&#62; proto=ESMTP helo=&#60;206.12.0.10.in-addr.arpa&#62; IP addresses have been obscured to protect the guilty [...]]]></description>
			<content:encoded><![CDATA[<p>In the last 3 weeks our company mail servers have been slammed with a massive increase in spam relay attempts.  Logs showed many failures like so.</p>
<blockquote><p>Jul 12 14:15:26 mailserver.example.com postfix/smtpd[19885]: NOQUEUE: reject: RCPT from 206.12.0.10.in-addr.arpa[10.0.12.206]: 554 5.7.1 &lt;symons@yahoo.co.uk&gt;: Relay access denied; from=&lt;yyjaqveh@lpsb.com&gt; to=&lt;symons@yahoo.co.uk&gt; proto=ESMTP helo=&lt;206.12.0.10.in-addr.arpa&gt;</p></blockquote>
<p>IP addresses have been obscured to protect the guilty (or ignorant, as this is certainly a botnet).  Unfortunately, a large number of the IP addresses in question belonged to my own satellite customers.  Mail servers for our other domains were almost entirely unaffected.  Which tells me that some bastard has written a botnet spam client that looks up its own public IP, finds the reverse DNS entry, looks up the MX record of the corresponding domain, and then attempts to relay mail through that server.  This is particularly mean, as it will encourage your own ISP to shut you down.</p>
<p><span id="more-432"></span>I ignored these attempts at first.  The server was rejecting them and the botnet didn&#8217;t appear to be trying to relay through anyone else (according to traffic logs).  With our Postfix settings it was unlikely they&#8217;d ever succeed.  Then the log entries moved from &#8220;annoying&#8221; to &#8220;problematical&#8221;:</p>
<blockquote><p>Jul 13 20:34:50 mailserver.example.com postfix/master[18904]: warning: service &#8220;smtp&#8221; (25) has reached its process limit &#8220;200&#8243;: new clients may experience noticeable delays<br />
Jul 13 20:34:50 mailserver.example.com postfix/master[18904]: warning: to avoid this condition, increase the process count in master.cf or reduce the service time per client<br />
Jul 13 20:34:50 mailserver.example.com postfix/master[18904]: warning: see http://www.postfix.org/STRESS_README.html for examples of stress-adapting configuration settings</p></blockquote>
<p>Time to do something about it.  We already use <a href="http://www.fail2ban.org">fail2ban</a> to protect other services, so I enabled the postfix rules.  In /etc/fail2ban/jail.local:</p>
<pre>[postfix]
enabled  = true
ignoreip = 127.0.0.1/8   # suggest listing your valid server IP ranges here
port     = smtp,ssmtp
filter   = postfix
logpath  = /var/log/mail.log
bantime  = 3600</pre>
<p>I then reloaded fail2ban, and waited for results.  Within a few minutes (fail2ban takes time to parse existing logs), 65 IP addresses were banned.  Here are my results 24 hours later, edited for brevity:</p>
<p><code>root@mailserver:/etc/fail2ban# fail2ban-client status postfix</code></p>
<pre>Status for the jail: postfix
|- filter
|  |- File list:        /var/log/mail.log
|  |- Currently failed: 49
|  `- Total failed:     58171
`- action
   |- Currently banned: 68
   |  `- IP list: ...
   `- Total banned:     3883</pre>
<p>Now to hunt down the customers with botnet infections and start sending &#8220;violation of terms of service&#8221; warnings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tolaris.com/2009/07/15/stopping-spam-botnets-with-fail2ban/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

