<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Regex on Evan Hoffman</title><link>https://evan.wtf/tags/regex/</link><description>Recent content in Regex on Evan Hoffman</description><generator>Hugo</generator><language>en-US</language><copyright>Evan Hoffman</copyright><lastBuildDate>Fri, 18 Nov 2011 14:06:03 +0000</lastBuildDate><atom:link href="https://evan.wtf/tags/regex/index.xml" rel="self" type="application/rss+xml"/><item><title>Graphing SSH dictionary attacks with HighCharts</title><link>https://evan.wtf/2011/11/18/graphing-ssh-dictionary-attacks-with-highcharts/</link><pubDate>Fri, 18 Nov 2011 14:06:03 +0000</pubDate><guid>https://evan.wtf/2011/11/18/graphing-ssh-dictionary-attacks-with-highcharts/</guid><description>&lt;p&gt;After my 10-year-old basement Linux server died this week from a power outage, I took the sad step of giving up on it. It&amp;rsquo;s died before and I&amp;rsquo;ve patched it back together with a new power supply here or an addon PCI SATA card there, but I finally decided to throw in the towel since I had a newer old computer that had been idle for several years. The one that died was an Athlon K7 750 MHz with 512 MB ram. The new one is an Athlon 2 GHz (3200+) with 1 gig. For my uses, specs don&amp;rsquo;t really matter that much, but it&amp;rsquo;s nice to have more power for free.&lt;/p&gt;</description></item><item><title>Blocking comment spammers by IP</title><link>https://evan.wtf/2010/08/13/blocking-comment-spammers-by-ip/</link><pubDate>Fri, 13 Aug 2010 11:59:27 +0000</pubDate><guid>https://evan.wtf/2010/08/13/blocking-comment-spammers-by-ip/</guid><description>&lt;p&gt;I use &lt;a href="http://akismet.com/"&gt;Akismet&lt;/a&gt; to block comment spam, but it still annoys me that it even exists. Last night I put a simple IP ban into my httpd config. But who to block?&lt;/p&gt;&#10;&lt;p&gt;I used a grep &amp;amp; Perl to get a rough guess of which IPs were submitting the most comments (working on the assumption that one IP address submits many spam comments) It took me about 20 minutes to write this mess but it does what I wanted to do:&#10;&lt;code&gt;[root@lunix ~]# zgrep POST /var/log/httpd/evanhoffman-access_log-201008??.gz | grep comment | perl -ne 'chomp; $_ =~ m/(?:\d{1,3}\.){3}\d{1,3}/; print &amp;quot;$&amp;amp;\n&amp;quot;;' | perl -e '%a = (); while (&amp;lt;&amp;gt;) { chomp; $a{$_} += 1; } while (my ($key, $value) = each (%a)) { if ($value &amp;gt; 1) { print &amp;quot;$value\t=&amp;gt;\t$key\n&amp;quot;;}}' 2 =&amp;gt; 218.6.9.140 180 =&amp;gt; 91.201.66.34 2 =&amp;gt; 213.5.67.41 2 =&amp;gt; 188.187.102.74 [root@lunix ~]#&lt;/code&gt;&lt;/p&gt;</description></item></channel></rss>