From 5fc4aa46a65757ce93ffe9d8d0f83396bb956fed Mon Sep 17 00:00:00 2001 From: Jens Falk Date: Fri, 28 Aug 2026 18:47:22 +0200 Subject: [PATCH] =?UTF-8?q?Scripte=20hinzugef=C3=BCgt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blitzbestaetigung_process.php | 88 +++++++++++++++++++++++++++++++++ blocklist_update.php | 72 +++++++++++++++++++++++++++ config_snippets.php | 93 +++++++++++++++++++++++++++++++++++ spam_report.php | 80 ++++++++++++++++++++++++++++++ 4 files changed, 333 insertions(+) create mode 100644 blitzbestaetigung_process.php create mode 100644 blocklist_update.php create mode 100644 config_snippets.php create mode 100644 spam_report.php diff --git a/blitzbestaetigung_process.php b/blitzbestaetigung_process.php new file mode 100644 index 0000000..196a9f6 --- /dev/null +++ b/blitzbestaetigung_process.php @@ -0,0 +1,88 @@ +prepare($sql); +$stmt->execute(['blitzId' => $attrBlitzId, 'threshold' => $thresholdSeconds]); +$candidates = $stmt->fetchAll(PDO::FETCH_ASSOC); + +foreach ($candidates as $c) { + // 1. Abonnent auf "unbestaetigt" zuruecksetzen + $reset = $pdo->prepare("UPDATE phplist_user_user SET confirmed = 0 WHERE id = :uid"); + $reset->execute(['uid' => $c['id']]); + + // 2. IP zur Sperrliste vormerken (nutzt bestehende Infrastruktur aus blocklist_update.php) + $blk = $pdo->prepare("INSERT INTO phplist_user_user_attribute (userid, attributeid, value) + VALUES (:uid, :aid, 'on') + ON DUPLICATE KEY UPDATE value = 'on'"); + $blk->execute(['uid' => $c['id'], 'aid' => $attrIpBlockId]); + + // 3. Nur die IP an SFS melden - NICHT die moeglicherweise fremde E-Mail-Adresse + $data = http_build_query([ + 'ip_addr' => $c['conf_ip'], + 'username' => 'blitzbestaetigung-bot', + 'api_key' => $sfsApiKey, + 'evidence' => "Automatisiert erkannt: Bestaetigung nach nur {$c['diff_seconds']}s von abweichender IP (Anmelde-IP: {$c['sub_ip']})", + ]); + $ch = curl_init('https://www.stopforumspam.com/add.php'); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_exec($ch); + curl_close($ch); + + // 4. Als bearbeitet markieren (Duplikatschutz) + $mark = $pdo->prepare("INSERT INTO phplist_user_user_attribute (userid, attributeid, value) + VALUES (:uid, :aid, 'on') + ON DUPLICATE KEY UPDATE value = 'on'"); + $mark->execute(['uid' => $c['id'], 'aid' => $attrBlitzId]); + + echo "Zurueckgesetzt & IP vorgemerkt: userid {$c['id']} ({$c['diff_seconds']}s, sub_ip: {$c['sub_ip']}, conf_ip: {$c['conf_ip']})\n"; + sleep(1); +} diff --git a/blocklist_update.php b/blocklist_update.php new file mode 100644 index 0000000..edcff0d --- /dev/null +++ b/blocklist_update.php @@ -0,0 +1,72 @@ +prepare($sql); +$stmt->execute(['ipBlockId' => $attrIpBlockId, 'honeypotId' => $attrHoneypotId, 'blockedId' => $attrBlockedId]); +$candidates = $stmt->fetchAll(PDO::FETCH_COLUMN); + +function getSubscriberIp($pdo, $userid) { + $stmt = $pdo->prepare("SELECT ip FROM phplist_user_user_history + WHERE userid = :uid AND ip IS NOT NULL AND ip != '' + ORDER BY date ASC LIMIT 1"); + $stmt->execute(['uid' => $userid]); + return $stmt->fetchColumn(); +} + +$currentBlocklist = file_exists($blocklistFile) ? include $blocklistFile : []; + +$newlyBlocked = []; +foreach ($candidates as $userid) { + $ip = getSubscriberIp($pdo, $userid); + if ($ip && !in_array($ip, $currentBlocklist, true)) { + $currentBlocklist[] = $ip; + $newlyBlocked[] = $ip; + } + $upd = $pdo->prepare("INSERT INTO phplist_user_user_attribute (userid, attributeid, value) + VALUES (:uid, :aid, 'on') + ON DUPLICATE KEY UPDATE value = 'on'"); + $upd->execute(['uid' => $userid, 'aid' => $attrBlockedId]); +} + +if (!empty($newlyBlocked)) { + $currentBlocklist = array_values(array_unique($currentBlocklist)); + $content = "prepare(" + SELECT COUNT(*) FROM phplist_user_user_history h + JOIN phplist_user_user u ON u.id = h.userid + WHERE u.email = :email + AND h.summary IN ('Subscription', 'Re-Subscription') + AND h.date >= (NOW() - INTERVAL 24 HOUR) + "); + $stmt->execute(['email' => $targetEmail]); + $recentAttempts = (int) $stmt->fetchColumn(); + + if ($recentAttempts >= 2) { + header('HTTP/1.1 429 Too Many Requests'); + exit('Please wait before trying again.'); + } + } catch (Exception $e) { + // Bei DB-Fehler nicht blockieren, normal weiterlaufen lassen + } +} diff --git a/spam_report.php b/spam_report.php new file mode 100644 index 0000000..ce9c0f7 --- /dev/null +++ b/spam_report.php @@ -0,0 +1,80 @@ +prepare($sql); +$stmt->execute(['honeypotId' => $attrHoneypotId, 'reportedId' => $attrReportedId]); +$subscribers = $stmt->fetchAll(PDO::FETCH_ASSOC); + +function getSubscriberIp($pdo, $userid) { + $stmt = $pdo->prepare("SELECT ip FROM phplist_user_user_history + WHERE userid = :uid AND ip IS NOT NULL AND ip != '' + ORDER BY date ASC LIMIT 1"); + $stmt->execute(['uid' => $userid]); + return $stmt->fetchColumn(); +} + +foreach ($subscribers as $sub) { + $botIp = getSubscriberIp($pdo, $sub['id']); + if (!$botIp) { + echo "Uebersprungen (keine IP in History): {$sub['email']}\n"; + continue; + } + + $data = http_build_query([ + 'email' => $sub['email'], + 'ip_addr' => $botIp, + 'username' => $sub['email'], + 'api_key' => $sfsApiKey, + 'evidence' => 'Automatisch erkannt: Honeypot-Feld auf phpList-Anmeldeseite befuellt', + ]); + + $ch = curl_init('https://www.stopforumspam.com/add.php'); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $response = curl_exec($ch); + curl_close($ch); + + if (strpos($response, 'success') !== false) { + $upd = $pdo->prepare("INSERT INTO phplist_user_user_attribute (userid, attributeid, value) + VALUES (:uid, :aid, 'on') + ON DUPLICATE KEY UPDATE value = 'on'"); + $upd->execute(['uid' => $sub['id'], 'aid' => $attrReportedId]); + + $blk = $pdo->prepare("UPDATE phplist_user_user SET blacklisted = 1 WHERE id = :uid"); + $blk->execute(['uid' => $sub['id']]); + + echo "Gemeldet & geblacklistet: {$sub['email']} (IP: $botIp)\n"; + } else { + echo "Fehler bei: {$sub['email']} - $response\n"; + } + sleep(1); +}