/* Plugin Name: COMPACT Cache Autopsy Extended Description: Überwacht Cache-Schreibvorgänge und protokolliert verdächtigen Code inkl. Backtrace, Ursprung und Metadaten – mit Duplikatschutz. Version: 1.4 Author: COMPACT */ add_action('shutdown', function () { $cache_dir = WP_CONTENT_DIR . '/cache/'; $log_file = WP_CONTENT_DIR . '/compact-cache-autopsy-log.txt'; $hash_log = WP_CONTENT_DIR . '/compact-cache-autopsy-hashes.txt'; $patterns = [ 'window\.location\.href' => 'Redirect: window.location.href', 'go_redirect\s*\(' => 'Redirect: go_redirect()', 'eval\s*\(\s*atob\s*\(' => 'Obfuskation: eval(atob(...))', 'setTimeout\s*\(.*location\.href' => 'Verdächtiger Timeout-Redirect' ]; // Lade bereits bekannte Hashes (Duplikate vermeiden) $known_hashes = file_exists($hash_log) ? file($hash_log, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : []; $rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($cache_dir)); foreach ($rii as $file) { if ($file->isDir() || strtolower($file->getExtension()) !== 'html') continue; $content = file_get_contents($file->getPathname()); $hash = sha1($content); if (in_array($hash, $known_hashes)) continue; $lines = explode("\n", $content); foreach ($lines as $i => $line) { foreach ($patterns as $pattern => $description) { if (preg_match('/' . $pattern . '/i', $line)) { $excerpt = substr(trim($line), 0, 150); $file_rel_path = str_replace(ABSPATH, '', $file->getPathname()); $file_size = filesize($file->getPathname()); $html_excerpt = substr(trim($content), 0, 500); $theme = wp_get_theme(); $active_plugins = get_option('active_plugins'); // Backtrace $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); $trace_info = ''; $origin = 'nicht ermittelbar'; foreach ($trace as $step) { if (isset($step['file'])) { $trace_info .= $step['file'] . ':' . $step['line'] . "\n"; if (strpos($step['file'], WP_CONTENT_DIR . '/plugins/') !== false || strpos($step['file'], WP_CONTENT_DIR . '/themes/') !== false) { $origin = str_replace(ABSPATH, '', $step['file']); break; } } } $log_entry = sprintf( "📅 Zeit: %s (Unix: %d) 📄 Datei: %s 📏 Größe: %d Bytes 🔢 Zeile: %d 🔍 Code: %s 💬 Muster: %s 💾 SHA1: %s 🧾 HTML-Ausschnitt (500 Zeichen): %s 🌐 URL: %s ↩️ Referer: %s 🖥 Server: %s | PHP %s 🧠 UA: %s 🍪 Cookie: %s 🧩 Plugins: %s 📦 Theme: %s 🚨 Verursacher: %s 🔁 Methode: %s 🧠 Backtrace: %s ------------------\n", date("Y-m-d H:i:s"), time(), $file_rel_path, $file_size, $i + 1, $excerpt, $description, $hash, $html_excerpt, $_SERVER['REQUEST_URI'] ?? '-', $_SERVER['HTTP_REFERER'] ?? '-', $_SERVER['SERVER_SOFTWARE'] ?? '-', phpversion(), $_SERVER['HTTP_USER_AGENT'] ?? '-', substr($_SERVER['HTTP_COOKIE'] ?? '-', 0, 300), implode(', ', $active_plugins), $theme->get('Name') . ' ' . $theme->get('Version'), $origin, $_SERVER['REQUEST_METHOD'] ?? '-', $trace_info ); file_put_contents($log_file, $log_entry, FILE_APPEND); file_put_contents($hash_log, $hash . "\n", FILE_APPEND); break 2; } } } } }); COMPACT Shop jetzt alle Artikel bei uns finden › COMPACT-Magazin - Der Shop
Shop
Zeige:
Scroll To Top
Close
Close

Anmelden

Registrieren

Ein Link zum Erstellen eines neuen Passwort wird an deine E-Mail-Adresse gesendet.

Warenkorb

Close

Es befinden sich keine Produkte im Warenkorb.