<?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>PSEiBlog &#187; Fail2Ban</title>
	<atom:link href="http://www.pseiko.nl/blog/tag/fail2ban/feed" rel="self" type="application/rss+xml" />
	<link>http://www.pseiko.nl/blog</link>
	<description>But why?</description>
	<lastBuildDate>Fri, 07 May 2010 14:02:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Countering PHPMyAdmin scanners with Fail2Ban</title>
		<link>http://www.pseiko.nl/blog/367/countering-phpmyadmin-scanners-with-fail2ban</link>
		<comments>http://www.pseiko.nl/blog/367/countering-phpmyadmin-scanners-with-fail2ban#comments</comments>
		<pubDate>Wed, 09 Dec 2009 14:44:40 +0000</pubDate>
		<dc:creator>Remco</dc:creator>
				<category><![CDATA[Computer & Technology Related]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Fail2Ban]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expression]]></category>

		<guid isPermaLink="false">http://www.pseiko.nl/blog/?p=367</guid>
		<description><![CDATA[While examining my webserver statistics, I noticed that quite a lot 404&#8217;s are being served on most of my domains to scan bots that are trying to find exploits in possible running PHPMyAdmin configurations.
Though harmless if you keep a clean ship with a decently configured PHPMyAdmin and the latest updates like I do, I still [...]]]></description>
			<content:encoded><![CDATA[<p>While examining my webserver statistics, I noticed that quite a lot 404&#8217;s are being served on most of my domains to scan bots that are trying to find exploits in possible running PHPMyAdmin configurations.<br />
Though harmless if you keep a clean ship with a decently configured PHPMyAdmin and the latest updates like I do, I still decided I couldn&#8217;t let this behaviour unanswered. So I took action, and wrote a small fail2ban filter that permanently drops all traffic from the IP addresses these scans originate from, like I do with every address that misbehaves in any way.</p>
<p>The regex used won&#8217;t capture all attempts, but with my configuration only 1 hit is enough to get you banned (the scripts these scans call are main.php and config.inc.php, which aren&#8217;t to be called directly, especially not when they fail with a 404 like these), and all scanning attempts I&#8217;ve seen so far cycle through at least 20 different combinations.</p>
<p>Well, enough talk, here is the filter.d file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Fail2Ban configuration file
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;"># Author: Remco Overdijk
</span><span style="color: #666666; font-style: italic;">#
</span><span style="color: #666666; font-style: italic;"># $Revision: 4 $
</span><span style="color: #666666; font-style: italic;">#
</span>
<span style="color: #009900;">&#91;</span>Definition<span style="color: #009900;">&#93;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Option:  failregex
</span><span style="color: #666666; font-style: italic;"># Notes.:  regex to match the 404'ed PMA file in the logfile. The
</span><span style="color: #666666; font-style: italic;">#          host must be matched by a group named &quot;host&quot;. The tag &quot;&lt;HOST&gt;&quot; can
</span><span style="color: #666666; font-style: italic;">#          be used for standard IP/hostname matching and is only an alias for
</span><span style="color: #666666; font-style: italic;">#          (?:::f{4,6}:)?(?P&lt;host&gt;\S+)
</span><span style="color: #666666; font-style: italic;"># Values:  TEXT
</span><span style="color: #666666; font-style: italic;">#
</span>failregex <span style="color: #339933;">=</span> <span style="color: #339933;">&lt;</span>HOST<span style="color: #339933;">&gt;</span> <span style="color: #339933;">-.*</span><span style="color: #0000ff;">&quot;GET .*(php|pma|PMA|p/m/a|db|sql|admin).*/(config/config\.inc|main)\.php.*&quot;</span><span style="color: #339933;">.*</span><span style="color:#800080;">404.</span><span style="color: #339933;">*</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Option:  ignoreregex
</span><span style="color: #666666; font-style: italic;"># Notes.:  regex to ignore. If this regex matches, the line is ignored.
</span><span style="color: #666666; font-style: italic;"># Values:  TEXT
</span><span style="color: #666666; font-style: italic;">#
</span>ignoreregex <span style="color: #339933;">=</span></pre></div></div>

<p>And this is of course accompanied by a bit in jail.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>apache<span style="color: #339933;">-</span>pma<span style="color: #009900;">&#93;</span>
&nbsp;
enabled <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span>
filter <span style="color: #339933;">=</span> apache<span style="color: #339933;">-</span>pma
action <span style="color: #339933;">=</span> iptables<span style="color: #339933;">-</span>allports<span style="color: #009900;">&#91;</span>name<span style="color: #339933;">=</span>pma<span style="color: #009900;">&#93;</span>
mail<span style="color: #339933;">-</span>whois<span style="color: #009900;">&#91;</span>name<span style="color: #339933;">=</span>pma<span style="color: #339933;">,</span> dest<span style="color: #339933;">=&lt;</span>YOURADDRHERE<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#93;</span>
logpath <span style="color: #339933;">=</span> <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span><span style="color: #990000;">log</span><span style="color: #339933;">/</span>apache2<span style="color: #339933;">/</span>access_log
bantime <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span>
maxretry <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span></pre></div></div>

<p>Works for me, another 20 additional IPs/day onto the shitlist!</p>
<blockquote><p><b>Update:</b> It seems another variation of these scans are hitting the NIC&#8217;s quite often; One for Zen Cart to be more precise.<br />
You can easily add support countering this scanner as well, simply by expanding the failregex with this line:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">^<span style="color: #339933;">&lt;</span>HOST<span style="color: #339933;">&gt;</span> <span style="color: #339933;">-.*</span><span style="color: #0000ff;">&quot;GET .*(cart|boutique|catalog|butik|shop|zen|store).*/install\.txt.*&quot;</span><span style="color: #339933;">.*</span><span style="color:#800080;">404.</span><span style="color: #339933;">*</span></pre></div></div>

<p>You can put multiple regexes within one failregex, just put each one on a new line.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.pseiko.nl/blog/367/countering-phpmyadmin-scanners-with-fail2ban/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Persistent Iptables bans from Fail2Ban</title>
		<link>http://www.pseiko.nl/blog/288/persistent-iptables-bans-from-fail2ban</link>
		<comments>http://www.pseiko.nl/blog/288/persistent-iptables-bans-from-fail2ban#comments</comments>
		<pubDate>Tue, 18 Aug 2009 13:53:23 +0000</pubDate>
		<dc:creator>Remco</dc:creator>
				<category><![CDATA[Blogs & Hersenspinsels]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Fail2Ban]]></category>
		<category><![CDATA[Firewall]]></category>
		<category><![CDATA[Iptables]]></category>

		<guid isPermaLink="false">http://www.pseiko.nl/blog/?p=288</guid>
		<description><![CDATA[On my servers I use the nifty program Fail2Ban to perform logbased automatic fire walling of &#8216;bad&#8217; ip&#8217;s.
The idea behind this is easy: Some IP performs an action I don&#8217;t approve of. This can be any number of things, e.g. requesting pages in Apache that are commonly accessed by bots and/or scanners, or trying to [...]]]></description>
			<content:encoded><![CDATA[<p>On my servers I use the nifty program <a href="http://www.fail2ban.org/wiki/index.php/Main_Page">Fail2Ban</a> to perform logbased automatic fire walling of &#8216;bad&#8217; ip&#8217;s.</p>
<p>The idea behind this is easy: Some IP performs an action I don&#8217;t approve of. This can be any number of things, e.g. requesting pages in Apache that are commonly accessed by bots and/or scanners, or trying to log in to SSH with accounts that do not exist on the system. This bad behavior gets logged, and Fail2Ban keeps tabs on those logs, and using a number of rules it determines if a host is &#8216;bad&#8217; enough to temporarily or permanently ban all access to the server. It does so by adding a few chains to Iptables (one for each thing it checks for), and dynamically adding/removing IP&#8217;s to/from these chains.</p>
<p>This all works perfectly. However, there&#8217;s one issue; When Iptables gets reloaded, it restores its default rules, removing the Fail2Ban chains and all the rules they contain, even if the ip&#8217;s in the chain were marked as permanent.<br />
<span id="more-288"></span></p>
<p>I created a workaround for this problem, consisting of two simple steps:<br />
- When a &#8216;bad&#8217; ip gets banned, it&#8217;s added to the Iptables chain, but also written to a file, containing all collected &#8216;bad&#8217; ip&#8217;s. (I use /etc/shitlist for this purpose).<br />
- Whenever Iptables gets reloaded, I run a PHP script that checks the /etc/shitlist file for &#8217;safe&#8217; and duplicate ip&#8217;s, and writes all other ip&#8217;s to the permanent Blocklist chain. (The checking for &#8217;safe&#8217; ip&#8217;s might be a bit unneeded, but with my Fail2Ban rules it&#8217;s possible that one of my own ip&#8217;s gets banned for 10 minutes if a SSH login attempt fails for 5 times. Though it&#8217;s a temporary ban, the ip will still get written to the shitlist, and would end up in the permanent Blocklist).</p>
<p>To make this work, I made the following changes:</p>
<p>Every &#8216;jail&#8217; in Fail2Ban uses an &#8216;action.d&#8217; script to perform (un)banning. I defaulted all actions to an action script called &#8216;iptables-allports.conf&#8217;. Basically this action drops everything in Iptables if a package originates from the &#8216;bad&#8217; IP.<br />
I updated the ban action such that:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">actionban = iptables <span style="color: #660033;">-I</span> fail2ban-<span style="color: #000000; font-weight: bold;">&lt;</span>name<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ip<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">-j</span> DROP
                 <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #000000; font-weight: bold;">&lt;</span>ip<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shitlist</pre></td></tr></table></div>

<p>After that I created a PHP script that updates Iptables with the ip&#8217;s contained in the shitlist:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/** script that loads a shitlist file into iptables
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//CONFIG</span>
<span style="color: #000088;">$shitlists</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/root/list.txt&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;/etc/shitlist&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$chain</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Blocklist&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$safelist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;x.x.x.x&quot;</span>
                 <span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;y.y.y.y&quot;</span>
                 <span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;z.z.z.z&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Reading current IPTABLES state<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'iptables -S '</span><span style="color: #339933;">.</span><span style="color: #000088;">$chain</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$iparr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$j</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$ref</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span>sizeof<span style="color: #009900;">&#40;</span><span style="color: #000088;">$iparr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr_count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$iparr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$ref</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$j</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$iparr</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                        <span style="color: #000088;">$j</span><span style="color: #339933;">++;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$shitlists</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$shitlist</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Reading shitlist at <span style="color: #006699; font-weight: bold;">$shitlist</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//READ FILE</span>
        <span style="color: #000088;">$fh</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$shitlist</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'r'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$itt</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$iparr</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">feof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">fgets</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array_search</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #339933;">,</span><span style="color: #000088;">$iparr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">===</span>false<span style="color: #339933;">&amp;&amp;</span>array_search<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #339933;">,</span><span style="color: #000088;">$safelist</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">===</span>false<span style="color: #339933;">&amp;&amp;</span>array_search<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/32&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$ref</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">===</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                        <span style="color: #000088;">$iparr</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">;</span>
                                        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Now adding <span style="color: #006699; font-weight: bold;">$ip</span> to <span style="color: #006699; font-weight: bold;">$chain</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                                        <span style="color: #000088;">$ins</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">18</span><span style="color: #339933;">+</span><span style="color: #000088;">$itt</span><span style="color: #339933;">;</span>
                                        <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;iptables -I &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$chain</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ins</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; -s &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$ip</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/32 -j DROP&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                        <span style="color: #000088;">$itt</span><span style="color: #339933;">++;</span>
                                <span style="color: #009900;">&#125;</span>
                        <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fh</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Finished adding <span style="color: #006699; font-weight: bold;">$itt</span> ip's from list <span style="color: #006699; font-weight: bold;">$shitlist</span> to chain <span style="color: #006699; font-weight: bold;">$chain</span> . Bye!<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$total</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$itt</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Could not open shitlist file <span style="color: #006699; font-weight: bold;">$shitlist</span> . Skipping this list<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Finished adding <span style="color: #006699; font-weight: bold;">$total</span> ip's to chain <span style="color: #006699; font-weight: bold;">$chain</span> from &quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$shitlists</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; shitlists.<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>You can run the script from the commandline (as root!) simply by stating &#8220;php shitlist.php&#8221;, or add it to the startup script of your Iptables installation.</p>
<p>Hope this helps keeping your NIC&#8217;s available for VALID traffic!</p>
<p><b>Update:</b> Made some changes to the script to check for already existing bans, to keep your chains clean!<br />
<b>Update 2:</b> Little tweak to the script so it now loads an array of lists, in case you have various sources.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pseiko.nl/blog/288/persistent-iptables-bans-from-fail2ban/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
