You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by gb...@apache.org on 2024/04/02 14:48:31 UTC

svn commit: r1916751 - /spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm

Author: gbechis
Date: Tue Apr  2 14:48:30 2024
New Revision: 1916751

URL: http://svn.apache.org/viewvc?rev=1916751&view=rev
Log:
restore phishstats feed

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm?rev=1916751&r1=1916750&r2=1916751&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Phishing.pm Tue Apr  2 14:48:30 2024
@@ -31,6 +31,7 @@ Mail::SpamAssassin::Plugin::Phishing - c
   ifplugin Mail::SpamAssassin::Plugin::Phishing
     phishing_openphish_feed /etc/mail/spamassassin/openphish-feed.txt
     phishing_phishtank_feed /etc/mail/spamassassin/phishtank-feed.csv
+    phishing_phishstats_feed /etc/mail/spamassassin/phishstats-feed.csv
     body     URI_PHISHING      eval:check_phishing()
     describe URI_PHISHING      Url match phishing in feed
   endif
@@ -47,6 +48,9 @@ The PhishTank free feed is updated every
 http://data.phishtank.com/data/online-valid.csv.
 To avoid download limits a registration is required.
 
+The PhishStats feed is updated every 90 minutes and can be downloaded from
+https://phishstats.info/phish_score.csv.
+
 =cut
 
 package Mail::SpamAssassin::Plugin::Phishing;
@@ -140,6 +144,40 @@ skipped.
 =back
 
 =cut
+    push(@cmds, {
+        setting => 'phishing_phishstats_feed',
+        is_admin => 1,
+        type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
+        }
+    );
+
+=over 4
+
+=item phishing_phishstats_feed
+
+Absolute path of the downloaded PhishStats datafeed.
+
+=back
+
+=cut
+    push(@cmds, {
+        setting => 'phishing_phishstats_minscore',
+        is_admin => 1,
+        default => 6,
+        type => $Mail::SpamAssassin::Conf::CONF_TYPE_NUMERIC,
+        }
+    );
+
+=over 4
+
+=item phishing_phishstats_minscore ( 0 - 10 ) (default: 6)
+
+Minimum score to take into consideration for phishing uris downloaded
+from PhishStats datafeed.
+
+=back
+
+=cut
     $conf->{parser}->register_commands(\@cmds);
 }
 
@@ -151,7 +189,7 @@ sub finish_parsing_end {
 sub _read_configfile {
   my ($self) = @_;
   my $conf = $self->{main}->{registryboundaries}->{conf};
-  my @phtank_ln;
+  my (@phtank_ln, @phstats_ln);
   my $stripped_cluri;
 
   local *F;
@@ -200,6 +238,40 @@ sub _read_configfile {
         }
     }
 
+    defined $_ || $!==0  or
+      $!==EBADF ? dbg("PHISHING: error reading config file: $!")
+                : die "error reading config file: $!";
+    close(F) or die "error closing config file: $!";
+  }
+
+  if ( defined($conf->{phishing_phishstats_feed}) && (-f $conf->{phishing_phishstats_feed} ) ) {
+    open(F, '<', $conf->{phishing_phishstats_feed});
+    for ($!=0; <F>; $!=0) {
+        #skip first line
+        next if ( $. eq 1);
+        chomp;
+        #lines that start with pound are comments
+        next if(/^\s*\#/);
+
+	# CSV: Date,Score,URL,IP
+        @phstats_ln = split(/,/, $_);
+        next if (not defined $phstats_ln[1] or not defined $phstats_ln[2]);
+        $phstats_ln[1] =~ s/\"//g;
+        $phstats_ln[2] =~ s/\"//g;
+	if ( $conf->{phishing_phishstats_minscore} >= $phstats_ln[1] ) {
+	  next;
+	}
+        $stripped_cluri = $phstats_ln[2];
+	if ( $conf->{phishing_uri_noparam} eq 1 ) {
+          $stripped_cluri =~ s/\?.*//;
+	}
+        my $phishdomain = $self->{main}->{registryboundaries}->uri_to_domain($phstats_ln[2]);
+        if ( defined $phishdomain ) {
+          push @{$self->{PHISHING}->{$stripped_cluri}->{phishdomain}}, $phishdomain;
+          push @{$self->{PHISHING}->{$stripped_cluri}->{phishinfo}->{$phishdomain}}, "PhishStats";
+        }
+    }
+
     defined $_ || $!==0  or
       $!==EBADF ? dbg("PHISHING: error reading config file: $!")
                 : die "error reading config file: $!";