Jelajahi Sumber

#5402 Antispam: spamhaus DNSBL answer codes has changed

Aleksandr Trofimov 7 bulan lalu
induk
melakukan
2a45371423

+ 18 - 6
modules/boonex/antispam/classes/BxAntispamDNSBlacklists.php

@@ -136,15 +136,27 @@ class BxAntispamDNSBlacklists extends BxDol
 
 
         foreach ($servers as $r) {
         foreach ($servers as $r) {
             $resultaddr = gethostbyname ($key . "." . $r['zonedomain']);
             $resultaddr = gethostbyname ($key . "." . $r['zonedomain']);
-
             if ($resultaddr && $resultaddr != $key . "." . $r['zonedomain']) {
             if ($resultaddr && $resultaddr != $key . "." . $r['zonedomain']) {
+
+                bx_log('bx_antispam_dnsbl', $key . "." . $r['zonedomain'] . " => " . $resultaddr);
+
                 // we got some result from the DNS query, not NXDOMAIN. should we consider 'positive'?
                 // we got some result from the DNS query, not NXDOMAIN. should we consider 'positive'?
                 $postvresp = $r['postvresp'];	// check positive match criteria
                 $postvresp = $r['postvresp'];	// check positive match criteria
-                if (
-                    BX_DOL_DNSBL_MATCH_ANY == $postvresp ||
-                    (preg_match("/^\d+\.\d+\.\d+\.\d+$/", $postvresp) && $resultaddr == $postvresp) ||
-                    (is_numeric($postvresp) && (ip2long($resultaddr) & $postvresp))
-                ) {
+                $bPositive = false;
+                if (strpos($postvresp, ',') !== false) {
+                    $postvresp = explode(',', $postvresp);
+                    if (in_array($resultaddr, $postvresp)) {
+                        $bPositive = true;
+                    }
+                }
+                else {
+                    $bPositive = (
+                        BX_DOL_DNSBL_MATCH_ANY === $postvresp ||
+                        (preg_match("/^\d+\.\d+\.\d+\.\d+$/", $postvresp) && $resultaddr == $postvresp) ||
+                        (is_numeric($postvresp) && (ip2long($resultaddr) & $postvresp))
+                    );
+                }
+                if ($bPositive) {
                     $numpositive++;
                     $numpositive++;
                     if ($querymode == BX_DOL_DNSBL_ANYPOSTV_RETFIRST)
                     if ($querymode == BX_DOL_DNSBL_ANYPOSTV_RETFIRST)
                         return BX_DOL_DNSBL_POSITIVE;	// found one positive, returning single
                         return BX_DOL_DNSBL_POSITIVE;	// found one positive, returning single

+ 2 - 2
modules/boonex/antispam/install/sql/install.sql

@@ -16,7 +16,7 @@ CREATE TABLE `bx_antispam_dnsbl_rules` (
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `id` int(11) NOT NULL AUTO_INCREMENT,
   `chain` enum('spammers','whitelist','uridns') NOT NULL,
   `chain` enum('spammers','whitelist','uridns') NOT NULL,
   `zonedomain` varchar(255) NOT NULL,
   `zonedomain` varchar(255) NOT NULL,
-  `postvresp` varchar(32) NOT NULL,
+  `postvresp` varchar(255) NOT NULL,
   `url` varchar(255) NOT NULL,
   `url` varchar(255) NOT NULL,
   `recheck` varchar(255) NOT NULL,
   `recheck` varchar(255) NOT NULL,
   `comment` varchar(255) NOT NULL,
   `comment` varchar(255) NOT NULL,
@@ -26,7 +26,7 @@ CREATE TABLE `bx_antispam_dnsbl_rules` (
 );
 );
 
 
 INSERT INTO `bx_antispam_dnsbl_rules` (`chain`, `zonedomain`, `postvresp`, `url`, `recheck`, `comment`, `added`, `active`) VALUES
 INSERT INTO `bx_antispam_dnsbl_rules` (`chain`, `zonedomain`, `postvresp`, `url`, `recheck`, `comment`, `added`, `active`) VALUES
-('spammers', 'sbl.spamhaus.org.', 'any', 'http://www.spamhaus.org/sbl/', 'http://www.spamhaus.org/query/bl?ip=%s', '_bx_antispam_rule_note_spamhaus_org', 0, 1),
+('spammers', 'sbl.spamhaus.org.', '127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.9', 'http://www.spamhaus.org/sbl/', 'https://check.spamhaus.org/results/?query=%s', '_bx_antispam_rule_note_spamhaus_org', 0, 1),
 ('spammers', 'dnsbl.tornevall.org.', '230', 'http://dnsbl.tornevall.org/', '', '_bx_antispam_rule_note_dnsbl_tornevall_org', 0, 0),
 ('spammers', 'dnsbl.tornevall.org.', '230', 'http://dnsbl.tornevall.org/', '', '_bx_antispam_rule_note_dnsbl_tornevall_org', 0, 0),
 ('uridns', 'multi.surbl.org.', 'any', 'http://www.surbl.org/', 'https://surbl.org/surbl-analysis', '_bx_antispam_rule_note_surbl_org', 0, 1),
 ('uridns', 'multi.surbl.org.', 'any', 'http://www.surbl.org/', 'https://surbl.org/surbl-analysis', '_bx_antispam_rule_note_surbl_org', 0, 1),
 ('spammers', 'zomgbl.spameatingmonkey.net.', 'any', 'http://spameatingmonkey.com/index.html', '', '_bx_antispam_rule_note_zomgbl_spameatingmonkey_net', 0, 0);
 ('spammers', 'zomgbl.spameatingmonkey.net.', 'any', 'http://spameatingmonkey.com/index.html', '', '_bx_antispam_rule_note_zomgbl_spameatingmonkey_net', 0, 0);