它在任何合理的黑客行为中都不起作用。
它唯一可行的方法是用全局变量对wp\\u logon核心函数本身进行攻击,而全局变量是不可分配的。
所以我选择了另一种解决方案。
我删除了身份验证功能并创建了自己的
remove_action(\'authenticate\', \'wp_authenticate_username_password\', 20);
add_filter(\'authenticate\', \'decrypt_and_authenticate\', 10, 3);
function decrypt_and_authenticate($user, $username, $password) {
// firs check if password needs to be decrypted
if ($_REQUEST[\'encryption_code\']) {
// Obtenemos la clave DES usando nuestra clave privada RSA
$key = new RSA(get_option(\'le_rsa_modulus\'), get_option(\'le_rsa_public_key\'), get_option(\'le_rsa_private_key\'));
$code = $key->decrypt($_REQUEST[\'encryption_code\']);
// Obtenemos la clave usando la clave DES
$pass = des ($code, hexToString($password), 0, 0, null, null);
preg_match("/^([\\s\\w]*)/", $pass, $res);
$password = $res[1];
$_REQUEST[\'encryption_code\'] = "";
}
if ( is_a($user, \'WP_User\') ) { return $user; }
if ( empty($username) || empty($password) ) {
$error = new WP_Error();
if ( empty($username) )
$error->add(\'empty_username\', __(\'<strong>ERROR</strong>: The username field is empty.\'));
if ( empty($password) )
$error->add(\'empty_password\', __(\'<strong>ERROR</strong>: The password field is empty.\'));
return $error;
}
$user = get_user_by(\'login\', $username);
if ( !$user )
return new WP_Error( \'invalid_username\', sprintf( __( \'<strong>ERROR</strong>: Invalid username. <a href="%s" title="Password Lost and Found">Lost your password</a>?\' ), wp_lostpassword_url() ) );
if ( is_multisite() ) {
// Is user marked as spam?
if ( 1 == $user->spam )
return new WP_Error( \'spammer_account\', __( \'<strong>ERROR</strong>: Your account has been marked as a spammer.\' ) );
// Is a user\'s blog marked as spam?
if ( !is_super_admin( $user->ID ) && isset( $user->primary_blog ) ) {
$details = get_blog_details( $user->primary_blog );
if ( is_object( $details ) && $details->spam == 1 )
return new WP_Error( \'blog_suspended\', __( \'Site Suspended.\' ) );
}
}
$user = apply_filters(\'wp_authenticate_user\', $user, $password);
if ( is_wp_error($user) )
return $user;
if ( !wp_check_password($password, $user->user_pass, $user->ID) )
return new WP_Error( \'incorrect_password\', sprintf( __( \'<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?\' ),
$username, wp_lostpassword_url() ) );
return $user;
}