ScamNailer update STILL not working

Mark Sapiro mark at msapiro.net
Wed Jun 19 21:05:59 IST 2013


Mark Sapiro wrote:
> ScamNailer gets the information about current data by doing a DNS lookup
> of a TXT record for emails.msupdate.greylist.bastionmail.com. For over 6
> weeks, this has been returning "emails.2013-164.6", i.e. week 16, day 4
> update 6. It is currently week 23, day 0.


It's now even worse. Currently the only TXT record for
emails.msupdate.greylist.bastionmail.com is an SPF record "v=spf1 a
-all". This causes ScamNailer to die with "Failed to retrieve valid
current details\n".

I have attached the latest version of my patch which works around this.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
-------------- next part --------------
--- ScamNailer-2.10	2012-03-05 03:04:14.000000000 -0800
+++ ScamNailer.new	2013-06-19 12:46:23.000000000 -0700
@@ -18,6 +18,7 @@
 use LWP::UserAgent;
 use FileHandle;
 use DirHandle;
+use Time::Local;
 
 # Output filename, goes into SpamAssassin. Can be over-ridden by just
 # adding the output filename on the command-line when you run this script.
@@ -137,7 +138,8 @@
 sub GetPhishingUpdate {
   my $cache = $emailscurrent . 'cache/';
   my $status = $emailscurrent . 'status';
-  my $urlbase = "http://cdn.mailscanner.info/emails.";
+#  my $urlbase = "http://cdn.mailscanner.info/emails.";
+  my $urlbase = "http://www.mailscanner.eu/emails.";
   my $target= $emailscurrent . 'phishing.emails.list';
   my $query="emails.msupdate.greylist.bastionmail.com";
 
@@ -212,9 +214,23 @@
         last;
       }
     }
+    if ($currentbase == -1) {
+      $currentbase = 0;
+      $currentupdate = 0;
+      warn "No appropriate TXT found at $query.\n";
+    }
   }
 
-  die "Failed to retrieve valid current details\n" if $currentbase eq "-1";
+
+  my $day = (gmtime)[6];
+  my $year = (gmtime)[5] + 1900;
+  my $janone = (gmtime(timegm(0,0,0,1,0,$year-1900)))[6];
+  my $week = sprintf ("%02d", int (((gmtime)[7] + $janone) / 7));
+  my $mybase = "$year-$week$day";
+  if ($currentbase lt $mybase) {
+    $currentbase = $mybase;
+    $currentupdate = 99;
+  }
 
   print "I am working with: Current: $currentbase - $currentupdate and Status: $status_base - $status_update\n" unless $quiet;
 
@@ -273,8 +289,10 @@
         #print "Getting $urlbase . $currentbase.$i\n" unless $quiet;
         my $req = HTTP::Request->new(GET => $urlbase.$currentbase.".".$i);
         my $res = $ua->request($req);
-        warn "Failed to retrieve $urlbase$currentbase.$i"
-          unless $res->is_success;
+        unless ($res->is_success) {
+          warn "Failed to retrieve $urlbase$currentbase.$i";
+          $currentupdate = $i - 1;
+        }
         my $line;
         foreach $line (split("\n", $res->content)) {
           # Is it an addition?
@@ -299,6 +317,12 @@
           }
         }
       }
+     # Because of our guess and retrieve until error strategy, we could be
+     # here without having retrieved any new updates which will result in
+     # our cached $status_update being erased. This does no real harm, but
+     # it causes extra work on the next run. To avoid this we skip the next
+     # section in that case.
+     if (!($status_update eq $currentupdate)) {
       # OK do we have a previous version to work from?
       if ($status_update>0) {
         # Yes - we open the most recent version
@@ -341,6 +365,7 @@
         }
       }
       close (FILEOUT);
+     }
     }
 
   }


More information about the MailScanner mailing list