update bad phishing sites broken?

Mark Sapiro mark at msapiro.net
Fri Jun 21 01:57:43 IST 2013


Matt Hampton wrote:
>
> renewed

But it still returns "v=spf1 a -all" as the only TXT record for
emails.msupdate.greylist.bastionmail.com. Is this ever going to be fixed?

Meanwhile, I have ported my Scamnailer patch to
update_bad_phishing_sites. The patch is attached.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
-------------- next part --------------
--- /usr/sbin/update_bad_phishing_sites.bak	2013-06-20 17:27:55.000000000 -0700
+++ /usr/sbin/update_bad_phishing_sites	2013-06-20 17:45:30.000000000 -0700
@@ -36,6 +36,7 @@
 use LWP::UserAgent;
 use FileHandle;
 use DirHandle;
+use Time::Local;
 
 # Work out Quarantine Directory from MailScanner.conf
 my $base = '/var/spool/MailScanner/quarantine'; # Default value
@@ -132,7 +133,22 @@
 		}
 }
 
-die "Failed to retrieve valid current details\n" unless (!($currentbase eq "-1"));
+#die "Failed to retrieve valid current details\n" unless (!($currentbase eq "-1"));
+if ($currentbase == -1) {
+  $currentbase = 0;
+  $currentupdate = 0;
+  warn "No appropriate TXT found at $query.\n";
+}
+
+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"; 
 
@@ -196,7 +212,10 @@
 			print "Retrieving $urlbase$currentbase.$i\n";
 			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?
@@ -223,6 +242,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
@@ -264,6 +289,7 @@
 			}
 		}
 		close (FILEOUT);
+	    }
 	}
 		
 }


More information about the MailScanner mailing list