/
/
home
/
u523034047
/
domains
Server: in-mum-web1112.main-hosting.eu (62.72.28.111)
You: 216.73.216.4
PHP 8.3.16
Dir:
/home/u523034047/domains
Edit:
/home/u523034047/domains/file_watcher.php
<?php // 🔹 Base folder jaha saare domains hai $watchDir = "/home/u523034047/domains/"; // 🔹 Log file path $logFile = __DIR__ . "/file_watcher.log"; // 🔹 Allowed file extensions $allowedExtensions = [ // Core web files 'php', 'html', 'htm', 'css', 'js', 'txt','apk', // Images 'jpg', 'jpeg', 'png', 'gif', 'svg', 'webp', 'ico', // Text / Data 'txt', 'json', 'xml', 'csv', // Fonts 'woff', 'woff2', 'ttf', 'eot', // Documents 'pdf', // Config 'htaccess' ]; // 🔹 Ignore folders (add more if needed) $ignoreFolders = [ '/backups/', '/logs/', '/tmp/', '/cache/', '/redbridgeimmigration.com/' ]; // 🔹 Start log file_put_contents($logFile, "---- Scan Started: " . date('Y-m-d H:i:s') . " ----\n", FILE_APPEND); // 🔹 Recursive scan $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($watchDir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($iterator as $file) { if ($file->isFile()) { $filePath = $file->getPathname(); // 🚫 Check if file is inside any ignore folder $skip = false; foreach ($ignoreFolders as $ignore) { if (strpos($filePath, $ignore) !== false) { $skip = true; break; } } if ($skip) continue; $ext = strtolower($file->getExtension()); // 🚫 Not in allowed list → suspicious if (!in_array($ext, $allowedExtensions)) { $log = "⚠️ Suspicious file detected: {$filePath} | Extension: .$ext\n"; file_put_contents($logFile, $log, FILE_APPEND); // Try delete if (unlink($filePath)) { file_put_contents($logFile, "✅ Deleted: {$filePath}\n", FILE_APPEND); } else { file_put_contents($logFile, "❌ Failed to delete: {$filePath}\n", FILE_APPEND); } } } } // 🔹 End log file_put_contents($logFile, "---- Scan Finished: " . date('Y-m-d H:i:s') . " ----\n\n", FILE_APPEND); echo "✅ File Watcher Completed. Check file_watcher.log"; ?>
Ukuran: 2.2 KB